From a6250e99eaa3a3525ea58904d77bbfcd555f208c Mon Sep 17 00:00:00 2001
From: Sawyer Bergeron
Date: Fri, 1 Dec 2017 12:11:12 -0500
Subject: Add Dashboard OS Selection Menu on Booking
JIRA: PHAROS-326
Implement dropdown menu on pod booking page for user to
select base OS, as well as associated support in API and
pod status/booking status views
This patch includes the migration file mentioned by Parker Berbarian
Change-Id: I46a7b0e5e7020a89bc8fa0fe53c10bbda14a2e2d
Signed-off-by: Sawyer Bergeron
---
dashboard/src/api/serializers.py | 3 ++-
dashboard/src/booking/admin.py | 3 ++-
dashboard/src/booking/forms.py | 7 +++---
.../booking/migrations/0002_auto_20171213_1506.py | 28 ++++++++++++++++++++++
dashboard/src/booking/models.py | 7 ++++++
dashboard/src/booking/views.py | 3 ++-
.../src/templates/booking/booking_calendar.html | 3 ++-
.../src/templates/booking/booking_detail.html | 5 +++-
dashboard/src/templates/booking/booking_table.html | 6 ++++-
9 files changed, 56 insertions(+), 9 deletions(-)
create mode 100644 dashboard/src/booking/migrations/0002_auto_20171213_1506.py
(limited to 'dashboard/src')
diff --git a/dashboard/src/api/serializers.py b/dashboard/src/api/serializers.py
index 237ca02..23b41ec 100644
--- a/dashboard/src/api/serializers.py
+++ b/dashboard/src/api/serializers.py
@@ -16,10 +16,11 @@ from dashboard.models import Server, Resource, ResourceStatus
class BookingSerializer(serializers.ModelSerializer):
installer_name = serializers.CharField(source='installer.name')
scenario_name = serializers.CharField(source='scenario.name')
+ opsys_name = serializers.CharField(source='opsys.name')
class Meta:
model = Booking
- fields = ('id', 'resource_id', 'start', 'end', 'installer_name', 'scenario_name', 'purpose')
+ fields = ('id', 'resource_id', 'start', 'end', 'opsys_name', 'installer_name', 'scenario_name', 'purpose')
class ServerSerializer(serializers.ModelSerializer):
diff --git a/dashboard/src/booking/admin.py b/dashboard/src/booking/admin.py
index d883be1..51e1031 100644
--- a/dashboard/src/booking/admin.py
+++ b/dashboard/src/booking/admin.py
@@ -13,5 +13,6 @@ from django.contrib import admin
from booking.models import *
admin.site.register(Booking)
+admin.site.register(Opsys)
admin.site.register(Installer)
-admin.site.register(Scenario)
\ No newline at end of file
+admin.site.register(Scenario)
diff --git a/dashboard/src/booking/forms.py b/dashboard/src/booking/forms.py
index 2dbfacb..1f09c05 100644
--- a/dashboard/src/booking/forms.py
+++ b/dashboard/src/booking/forms.py
@@ -10,14 +10,15 @@
import django.forms as forms
-from booking.models import Installer, Scenario
+from booking.models import Installer, Scenario, Opsys
class BookingForm(forms.Form):
- fields = ['start', 'end', 'purpose', 'installer', 'scenario']
+ fields = ['start', 'end', 'purpose', 'opsys', 'installer', 'scenario']
start = forms.DateTimeField()
end = forms.DateTimeField()
purpose = forms.CharField(max_length=300)
+ opsys = forms.ModelChoiceField(queryset=Opsys.objects.all(), required=False)
installer = forms.ModelChoiceField(queryset=Installer.objects.all(), required=False)
- scenario = forms.ModelChoiceField(queryset=Scenario.objects.all(), required=False)
\ No newline at end of file
+ scenario = forms.ModelChoiceField(queryset=Scenario.objects.all(), required=False)
diff --git a/dashboard/src/booking/migrations/0002_auto_20171213_1506.py b/dashboard/src/booking/migrations/0002_auto_20171213_1506.py
new file mode 100644
index 0000000..3e0a5fa
--- /dev/null
+++ b/dashboard/src/booking/migrations/0002_auto_20171213_1506.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10 on 2017-12-13 15:06
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('booking', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Opsys',
+ fields=[
+ ('id', models.AutoField(primary_key=True, serialize=False)),
+ ('name', models.CharField(max_length=100)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='booking',
+ name='opsys',
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Opsys'),
+ ),
+ ]
diff --git a/dashboard/src/booking/models.py b/dashboard/src/booking/models.py
index 0b3fa3b..0bf5961 100644
--- a/dashboard/src/booking/models.py
+++ b/dashboard/src/booking/models.py
@@ -31,6 +31,12 @@ class Scenario(models.Model):
def __str__(self):
return self.name
+class Opsys(models.Model):
+ id = models.AutoField(primary_key=True)
+ name = models.CharField(max_length=100)
+
+ def __str__(self):
+ return self.name
class Booking(models.Model):
id = models.AutoField(primary_key=True)
@@ -41,6 +47,7 @@ class Booking(models.Model):
jira_issue_id = models.IntegerField(null=True)
jira_issue_status = models.CharField(max_length=50)
+ opsys = models.ForeignKey(Opsys, models.DO_NOTHING, null=True)
installer = models.ForeignKey(Installer, models.DO_NOTHING, null=True)
scenario = models.ForeignKey(Scenario, models.DO_NOTHING, null=True)
purpose = models.CharField(max_length=300, blank=False)
diff --git a/dashboard/src/booking/views.py b/dashboard/src/booking/views.py
index 6fdca0e..da2fe11 100644
--- a/dashboard/src/booking/views.py
+++ b/dashboard/src/booking/views.py
@@ -70,6 +70,7 @@ class BookingFormView(FormView):
booking = Booking(start=form.cleaned_data['start'],
end=form.cleaned_data['end'],
purpose=form.cleaned_data['purpose'],
+ opsys=form.cleaned_data['opsys'],
installer=form.cleaned_data['installer'],
scenario=form.cleaned_data['scenario'],
resource=self.resource, user=user)
@@ -117,6 +118,6 @@ class ResourceBookingsJSON(View):
def get(self, request, *args, **kwargs):
resource = get_object_or_404(Resource, id=self.kwargs['resource_id'])
bookings = resource.booking_set.get_queryset().values('id', 'start', 'end', 'purpose',
- 'jira_issue_status',
+ 'jira_issue_status', 'opsys__name',
'installer__name', 'scenario__name')
return JsonResponse({'bookings': list(bookings)})
diff --git a/dashboard/src/templates/booking/booking_calendar.html b/dashboard/src/templates/booking/booking_calendar.html
index 4644e85..16f0a4a 100644
--- a/dashboard/src/templates/booking/booking_calendar.html
+++ b/dashboard/src/templates/booking/booking_calendar.html
@@ -45,6 +45,7 @@
{% bootstrap_field form.end addon_after='' %}
+ {% bootstrap_field form.opsys %}
{% bootstrap_field form.purpose %}
{% bootstrap_field form.installer %}
{% bootstrap_field form.scenario %}
@@ -100,4 +101,4 @@
-{% endblock extrajs %}
\ No newline at end of file
+{% endblock extrajs %}
diff --git a/dashboard/src/templates/booking/booking_detail.html b/dashboard/src/templates/booking/booking_detail.html
index 4b016b2..cb937d3 100644
--- a/dashboard/src/templates/booking/booking_detail.html
+++ b/dashboard/src/templates/booking/booking_detail.html
@@ -18,9 +18,12 @@
Purpose: {{ booking.purpose }}
+
+ Operating System: {{ booking.opsys }}
+
Installer: {{ booking.installer }}
Scenario: {{ booking.scenario }}
-
\ No newline at end of file
+
diff --git a/dashboard/src/templates/booking/booking_table.html b/dashboard/src/templates/booking/booking_table.html
index 655b013..af2248c 100644
--- a/dashboard/src/templates/booking/booking_table.html
+++ b/dashboard/src/templates/booking/booking_table.html
@@ -7,6 +7,7 @@
Purpose |
Start |
End |
+ Operating System |
Installer |
Scenario |
@@ -26,6 +27,9 @@
{{ booking.end }}
|
+
+ {{ booking.opsys }}
+ |
{{ booking.installer }}
|
@@ -34,4 +38,4 @@
{% endfor %}
-
\ No newline at end of file
+
--
cgit 1.2.3-korg