aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/account/tasks.py2
-rw-r--r--src/account/views.py2
-rw-r--r--src/api/migrations/0013_manual_20200218_1536.py2
-rw-r--r--src/api/models.py16
-rw-r--r--src/api/views.py2
-rw-r--r--src/resource_inventory/migrations/0012_auto_20200103_1850.py2
-rw-r--r--src/templates/base/dashboard/landing.html3
-rw-r--r--src/workflow/resource_bundle_workflow.py8
8 files changed, 21 insertions, 16 deletions
diff --git a/src/account/tasks.py b/src/account/tasks.py
index 53fbaf5..df98c73 100644
--- a/src/account/tasks.py
+++ b/src/account/tasks.py
@@ -28,7 +28,7 @@ def sync_jira_accounts():
continue
try:
user.email = user_dict['emailAddress']
- except:
+ except KeyError:
pass
user.userprofile.url = user_dict['self']
user.userprofile.full_name = user_dict['displayName']
diff --git a/src/account/views.py b/src/account/views.py
index 1cb2275..d11a199 100644
--- a/src/account/views.py
+++ b/src/account/views.py
@@ -130,7 +130,7 @@ class JiraAuthenticatedView(RedirectView):
email = ""
try:
email = jira.user(username).emailAddress
- except:
+ except AttributeError:
email = ""
url = '/'
# Step 3. Lookup the user or create them if they don't exist.
diff --git a/src/api/migrations/0013_manual_20200218_1536.py b/src/api/migrations/0013_manual_20200218_1536.py
index 0b76e84..3ac427e 100644
--- a/src/api/migrations/0013_manual_20200218_1536.py
+++ b/src/api/migrations/0013_manual_20200218_1536.py
@@ -1,6 +1,6 @@
# Generated by Django 2.2 on 2020-02-18 15:36
-from django.db import migrations, models
+from django.db import migrations
class Migration(migrations.Migration):
diff --git a/src/api/models.py b/src/api/models.py
index addc02d..960fc26 100644
--- a/src/api/models.py
+++ b/src/api/models.py
@@ -176,12 +176,12 @@ class LabManager(object):
def format_user(self, userprofile):
return {
- "id": userprofile.user.id,
- "username": userprofile.user.username,
- "email": userprofile.email_addr,
- "first_name": userprofile.user.first_name,
- "last_name": userprofile.user.last_name,
- "company": userprofile.company
+ "id": userprofile.user.id,
+ "username": userprofile.user.username,
+ "email": userprofile.email_addr,
+ "first_name": userprofile.user.first_name,
+ "last_name": userprofile.user.last_name,
+ "company": userprofile.company
}
def get_users(self):
@@ -190,7 +190,9 @@ class LabManager(object):
return json.dumps({"users": userlist})
def get_user(self, user_id):
- profile = get_object_or_404(UserProfile, pk=user_id)
+ user = User.objects.get(pk=user_id)
+
+ profile = get_object_or_404(UserProfile, user=user)
return json.dumps(self.format_user(profile))
diff --git a/src/api/views.py b/src/api/views.py
index 4e0d058..75a0db3 100644
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -97,11 +97,13 @@ def lab_status(request, lab_name=""):
return JsonResponse(lab_manager.set_status(request.POST), safe=False)
return JsonResponse(lab_manager.get_status(), safe=False)
+
def lab_users(request, lab_name=""):
lab_token = request.META.get('HTTP_AUTH_TOKEN')
lab_manager = LabManagerTracker.get(lab_name, lab_token)
return HttpResponse(lab_manager.get_users(), content_type="text/plain")
+
def lab_user(request, lab_name="", user_id=-1):
lab_token = request.META.get('HTTP_AUTH_TOKEN')
lab_manager = LabManagerTracker.get(lab_name, lab_token)
diff --git a/src/resource_inventory/migrations/0012_auto_20200103_1850.py b/src/resource_inventory/migrations/0012_auto_20200103_1850.py
index 569e433..65d8f85 100644
--- a/src/resource_inventory/migrations/0012_auto_20200103_1850.py
+++ b/src/resource_inventory/migrations/0012_auto_20200103_1850.py
@@ -54,6 +54,6 @@ class Migration(migrations.Migration):
model_name='vlan',
name='network',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING,
- to='resource_inventory.PhysicalNetwork', null=True),
+ to='resource_inventory.PhysicalNetwork', null=True),
),
]
diff --git a/src/templates/base/dashboard/landing.html b/src/templates/base/dashboard/landing.html
index dd09dc4..ed50638 100644
--- a/src/templates/base/dashboard/landing.html
+++ b/src/templates/base/dashboard/landing.html
@@ -35,7 +35,7 @@
{% block btnGrp %}
<p>To get started, book a server below:</p>
<a class="btn btn-primary btn-lg d-flex flex-column justify-content-center align-content-center border text-white p-4" href="/booking/quick/">
- Book a Server
+ Book a Resource
</a>
<p class="mt-4">PTLs can use our advanced options to book multi-node pods. If you are a PTL, you may use the options
below:
@@ -43,7 +43,6 @@
<div class="btn-group-vertical w-100">
<button class="btn btn-primary" onclick="create_workflow(0)">Book a Pod</button>
<button class="btn btn-primary" onclick="create_workflow(1)">Design a Pod</button>
- <button class="btn btn-primary" onclick="create_workflow(2)">Configure a Pod</button>
</div>
{% endblock btnGrp %}
{% endif %}
diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py
index 391d33e..006f481 100644
--- a/src/workflow/resource_bundle_workflow.py
+++ b/src/workflow/resource_bundle_workflow.py
@@ -10,6 +10,7 @@
from django.conf import settings
from django.forms import formset_factory
+from django.core.exceptions import ValidationError
from typing import List
@@ -251,20 +252,21 @@ class Define_Software(WorkflowStep):
# TODO: fix headnode in form, currently doesn't return a selected one
# models['headnode_index'] = post_data.get("headnode", 1)
formset = self.create_hostformset(hosts, data=post_data)
- has_headnode = False
if formset.is_valid():
for i, form in enumerate(formset):
host = hosts[i]
image = form.cleaned_data['image']
hostname = form.cleaned_data['host_name']
headnode = form.cleaned_data['headnode']
- if headnode:
- has_headnode = True
host.is_head_node = headnode
host.name = hostname
host.image = image
host.save()
+ if not has_headnode:
+ self.set_invalid("No headnode. Please set a headnode.")
+ return
+
self.set_valid("Completed")
else:
self.set_invalid("Please complete all fields")