diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2018-02-19 21:17:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-02-19 21:17:12 +0000 |
commit | 55a03a85263a9c4033bdb228418f689d78e38860 (patch) | |
tree | bd3fc8dce2c59e0c5f1bccdeb06d7775a16baa37 /dashboard/src/booking/views.py | |
parent | 3b22628fe24ca3b9b9659462af6abaf8fd6601f8 (diff) | |
parent | 936a1a26401dc39e12209d9ff94404351a646d17 (diff) |
Merge "Provide Interface for Booking Deletion"
Diffstat (limited to 'dashboard/src/booking/views.py')
-rw-r--r-- | dashboard/src/booking/views.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/dashboard/src/booking/views.py b/dashboard/src/booking/views.py index ab3a04e..7e35af2 100644 --- a/dashboard/src/booking/views.py +++ b/dashboard/src/booking/views.py @@ -18,6 +18,7 @@ from django.views import View from django.views.generic import FormView from django.views.generic import TemplateView from jira import JIRAError +from django.shortcuts import redirect from account.jira_util import get_jira from booking.forms import BookingForm, BookingEditForm @@ -163,6 +164,7 @@ class BookingEditFormView(FormView): class BookingView(TemplateView): template_name = "booking/booking_detail.html" + def get_context_data(self, **kwargs): booking = get_object_or_404(Booking, id=self.kwargs['booking_id']) title = 'Booking Details' @@ -170,6 +172,21 @@ class BookingView(TemplateView): context.update({'title': title, 'booking': booking}) return context +class BookingDeleteView(TemplateView): + template_name = "booking/booking_delete.html" + + def get_context_data(self, **kwargs): + booking = get_object_or_404(Booking, id=self.kwargs['booking_id']) + title = 'Delete Booking' + context = super(BookingDeleteView, self).get_context_data(**kwargs) + context.update({'title': title, 'booking': booking}) + return context + +def bookingDelete(request, booking_id): + booking = get_object_or_404(Booking, id=booking_id) + booking.delete() + messages.add_message(request, messages.SUCCESS, 'Booking deleted') + return redirect('../../../../') class BookingListView(TemplateView): template_name = "booking/booking_list.html" @@ -188,4 +205,4 @@ class ResourceBookingsJSON(View): bookings = resource.booking_set.get_queryset().values('id', 'start', 'end', 'purpose', 'jira_issue_status', 'opsys__name', 'installer__name', 'scenario__name') - return JsonResponse({'bookings': list(bookings)}) + return JsonResponse({'bookings': list(bookings)})
\ No newline at end of file |