From 7c3d7e75f50c3e39eb1c752391c6336431543288 Mon Sep 17 00:00:00 2001 From: maxbr Date: Wed, 5 Oct 2016 14:10:56 +0200 Subject: Add Installer and Scenario fields to bookings JIRA: PHAROS-272 Change-Id: I28f44bfadb1dbe3cb0caca0a8038fba988cf26f9 Signed-off-by: maxbr --- tools/pharos-dashboard/src/booking/views.py | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'tools/pharos-dashboard/src/booking/views.py') diff --git a/tools/pharos-dashboard/src/booking/views.py b/tools/pharos-dashboard/src/booking/views.py index 2fe167af..413573da 100644 --- a/tools/pharos-dashboard/src/booking/views.py +++ b/tools/pharos-dashboard/src/booking/views.py @@ -15,7 +15,6 @@ from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.http import JsonResponse from django.shortcuts import get_object_or_404 -from django.shortcuts import redirect from django.urls import reverse from django.utils import timezone from django.views import View @@ -65,13 +64,12 @@ class BookingFormView(LoginRequiredMixin, FormView): def form_valid(self, form): user = self.request.user - if not user.userprofile.ssh_public_key or not user.userprofile.pgp_public_key: - messages.add_message(self.request, messages.INFO, - 'Please upload your private keys before booking') - return redirect('account:settings') - booking = Booking(start=form.cleaned_data['start'], end=form.cleaned_data['end'], - purpose=form.cleaned_data['purpose'], resource=self.resource, - user=user) + booking = Booking(start=form.cleaned_data['start'], + end=form.cleaned_data['end'], + purpose=form.cleaned_data['purpose'], + installer=form.cleaned_data['installer'], + scenario=form.cleaned_data['scenario'], + resource=self.resource, user=user) try: booking.save() except ValueError as err: @@ -98,10 +96,19 @@ class BookingView(TemplateView): def get_context_data(self, **kwargs): booking = get_object_or_404(Booking, id=self.kwargs['booking_id']) - jira_issue = booking.get_jira_issue() title = 'Booking Details' context = super(BookingView, self).get_context_data(**kwargs) - context.update({'title': title, 'booking': booking, 'jira_issue': jira_issue}) + context.update({'title': title, 'booking': booking}) + return context + +class BookingListView(TemplateView): + template_name = "booking/booking_list.html" + + def get_context_data(self, **kwargs): + bookings = Booking.objects.filter(end__gte=timezone.now()) + title = 'Search Booking' + context = super(BookingListView, self).get_context_data(**kwargs) + context.update({'title': title, 'bookings': bookings}) return context @@ -109,5 +116,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') - return JsonResponse({'bookings': list(bookings)}) \ No newline at end of file + 'jira_issue_status', + 'installer__name', 'scenario__name') + return JsonResponse({'bookings': list(bookings)}) -- cgit 1.2.3-korg