1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
3 # Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 from django.shortcuts import get_object_or_404
13 from django.views.generic import TemplateView
14 from django.shortcuts import render
15 from django.http import HttpResponseRedirect
17 from booking.models import Booking
18 from account.models import Lab
20 from resource_inventory.models import *
21 from workflow.views import *
22 from workflow.workflow_manager import *
25 def lab_list_view(request):
26 labs = Lab.objects.all()
27 context = {"labs": labs}
29 return render(request, "dashboard/lab_list.html", context)
32 def lab_detail_view(request, lab_name):
34 if request.user.is_authenticated:
37 lab = get_object_or_404(Lab, name=lab_name)
39 images = Image.objects.filter(from_lab=lab).filter(public=True)
41 images = images | Image.objects.filter(from_lab=lab).filter(owner=user)
43 return render(request, "dashboard/lab_detail.html",
44 {'title': "Lab Overview",
46 'hostprofiles': lab.hostprofiles.all(),
50 def host_profile_detail_view(request):
52 return render(request, "dashboard/host_profile_detail.html",
53 {'title': "Host Types",
57 def landing_view(request):
59 manager_detected = False
60 if 'manager_session' in request.session:
63 manager = ManagerTracker.managers[request.session['manager_session']]
69 if manager is not None:
70 #no manager detected, don't display continue button
71 manager_detected = True
73 if request.method == 'GET':
74 return render(request, 'dashboard/landing.html', {'manager': manager_detected, 'title': "Welcome!"})
76 if request.method == 'POST':
78 create = request.POST['create']
80 if manager is not None:
83 mgr_uuid = create_session(create, request=request,)
84 request.session['manager_session'] = mgr_uuid
85 return HttpResponseRedirect('/wf/')
91 class LandingView(TemplateView):
92 template_name = "dashboard/landing.html"
94 def get_context_data(self, **kwargs):
95 context = super(LandingView, self).get_context_data(**kwargs)
99 for host_profile in HostProfile.objects.all():
100 name = host_profile.name
101 description = host_profile.description
102 in_labs = host_profile.labs
104 interfaces = host_profile.interfaceprofile
105 storage = host_profile.storageprofile
106 cpu = host_profile.cpuprofile
107 ram = host_profile.ramprofile
109 host = (name, description, in_labs, interfaces, storage, cpu, ram)
112 context.update({'hosts': hosts})