From ecadb07367d31c0929212618e120130f54af78da Mon Sep 17 00:00:00 2001 From: Justin Choquette Date: Tue, 8 Aug 2023 11:33:57 -0400 Subject: MVP Change-Id: Ib590302f49e7e66f8d04841fb6cb97baf623f51a Signed-off-by: Justin Choquette --- src/dashboard/tasks.py | 3 --- src/dashboard/views.py | 28 ++++++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/dashboard') diff --git a/src/dashboard/tasks.py b/src/dashboard/tasks.py index ac4b006..281db92 100644 --- a/src/dashboard/tasks.py +++ b/src/dashboard/tasks.py @@ -17,9 +17,7 @@ from api.views import liblaas_end_booking # todo - make a task to check for expired bookings @shared_task def end_expired_bookings(): - print("Celery task for end_expired_bookings() has been triggered") cleanup_set = Booking.objects.filter(end__lte=timezone.now(), ).filter(complete=False) - print("Newly expired bookings: ", cleanup_set) for booking in cleanup_set: booking.complete = True if (booking.aggregateId): @@ -28,4 +26,3 @@ def end_expired_bookings(): else: print("booking " + str(booking.id) + " has no agg id") booking.save() - print("Finished end_expired_bookings()") diff --git a/src/dashboard/views.py b/src/dashboard/views.py index f250a3c..909b695 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - +import json from django.shortcuts import get_object_or_404 from django.views.generic import TemplateView from django.shortcuts import render @@ -21,7 +21,7 @@ from api.utils import get_ipa_migration_form, ipa_query_user from api.views import ipa_conflict_account from booking.models import Booking from dashboard.forms import * - +from api.views import list_flavors, list_hosts from laas_dashboard import settings @@ -40,14 +40,18 @@ def lab_detail_view(request, lab_name): user = request.user lab = get_object_or_404(Lab, name=lab_name) - - # images = Image.objects.filter(from_lab=lab).filter(public=True) - images = [] - # if user: - # images = images | Image.objects.filter(from_lab=lab).filter(owner=user) - - # hosts = ResourceQuery.filter(lab=lab) - hosts = [] + flavors_list = json.loads(list_flavors(request).content) + host_list = json.loads(list_hosts(request).content) + flavor_map = {} + for flavor in flavors_list: + flavor_map[flavor['flavor_id']] = flavor['name'] + + + # Apparently Django Templating lacks many features that regular Jinja offers, so I need to get creative + for host in host_list: + id = host["flavor"] + name = flavor_map[id] + host["flavor"] = {"id": id, "name": name} return render( request, @@ -56,8 +60,8 @@ def lab_detail_view(request, lab_name): 'title': "Lab Overview", 'lab': lab, # 'hostprofiles': ResourceProfile.objects.filter(labs=lab), - 'images': images, - 'hosts': hosts + 'flavors': flavors_list, + 'hosts': host_list } ) -- cgit 1.2.3-korg