diff options
Diffstat (limited to 'src/dashboard')
-rw-r--r-- | src/dashboard/testing_utils.py | 25 | ||||
-rw-r--r-- | src/dashboard/views.py | 41 |
2 files changed, 25 insertions, 41 deletions
diff --git a/src/dashboard/testing_utils.py b/src/dashboard/testing_utils.py index a96b6d0..0f52daa 100644 --- a/src/dashboard/testing_utils.py +++ b/src/dashboard/testing_utils.py @@ -103,12 +103,16 @@ def make_config_bundle(grb, owner, topology={}, host_set={}, cb = ConfigBundle.objects.create( owner=owner, name="config bundle " + str(ConfigBundle.objects.count()), - description="cb generated by make_config_bundle() method" + description="cb generated by make_config_bundle() method", + bundle=grb ) + scen = scenario or Scenario.objects.first() or make_scenario() + inst = installer or Installer.objects.first() or make_installer([scen]) + opnfv_config = OPNFVConfig.objects.create( - installer=installer, - scenario=scenario, + installer=inst, + scenario=scen, bundle=cb ) @@ -194,7 +198,8 @@ def make_generic_host(grb, host_profile, hostname): def make_user(is_superuser=False, username="testuser", password="testpassword", email="default_email@user.com"): - user = User.objects.create_user(username=username, email=email, password=password) + user = User.objects.get_or_create(username=username, email=email, password=password)[0] + user.is_superuser = is_superuser user.save() @@ -204,14 +209,14 @@ def make_user(is_superuser=False, username="testuser", def make_user_profile(user=None, email_addr="email@email.com", company="company", full_name="John Doe", booking_privledge=True, ssh_file=None): - user = user or User.objects.first() or make_user() - profile = UserProfile.objects.create( + user = user or make_user() + profile = UserProfile.objects.get_or_create( email_addr=email_addr, company=company, full_name=full_name, booking_privledge=booking_privledge, user=user - ) + )[0] profile.ssh_public_key.save("user_ssh_key", ssh_file if ssh_file else ContentFile("public key content string")) return profile @@ -238,7 +243,7 @@ def make_lab(user=None, name="Test_Lab_Instance", vlan_manager = make_vlan_manager() if not user: - user = make_user() + user = make_user(username=name + " user") lab = Lab.objects.create( lab_user=user, @@ -354,7 +359,9 @@ def make_installer(scenarios, name="test installer"): return installer -def make_os(installers, name="test OS"): +def make_os(installers=None, name="test OS"): + if not installers: + installers = [make_installer([make_scenario()])] os = Opsys.objects.create(name=name) for installer in installers: os.sup_installers.add(installer) diff --git a/src/dashboard/views.py b/src/dashboard/views.py index aaad7ab..c387251 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -12,12 +12,10 @@ from django.shortcuts import get_object_or_404 from django.views.generic import TemplateView from django.shortcuts import render -from django.http import HttpResponseRedirect from account.models import Lab from resource_inventory.models import Image, HostProfile -from workflow.views import create_session from workflow.workflow_manager import ManagerTracker @@ -63,36 +61,15 @@ def host_profile_detail_view(request): def landing_view(request): - manager = None - manager_detected = False - if 'manager_session' in request.session: - - try: - manager = ManagerTracker.managers[request.session['manager_session']] - - except KeyError: - pass - - if manager is not None: - # no manager detected, don't display continue button - manager_detected = True - - if request.method == 'GET': - return render(request, 'dashboard/landing.html', {'manager': manager_detected, 'title': "Welcome to the Lab as a Service Dashboard"}) - - if request.method == 'POST': - try: - create = request.POST['create'] - - if manager is not None: - del manager - - mgr_uuid = create_session(create, request=request,) - request.session['manager_session'] = mgr_uuid - return HttpResponseRedirect('/wf/') - - except KeyError: - pass + manager = ManagerTracker.managers.get(request.session.get('manager_session')) + return render( + request, + 'dashboard/landing.html', + { + 'manager': manager is not None, + 'title': "Welcome to the Lab as a Service Dashboard" + } + ) class LandingView(TemplateView): |