aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-10-15 14:03:26 -0400
committerParker Berberian <pberberian@iol.unh.edu>2018-10-15 14:05:00 -0400
commitbbff86219d2580d8b654ac6ec86d65ef23ad94ed (patch)
treef63102eeb28664ebc41db233ade84ce83ddce388
parent1f3a770d2547848590f39e9d9b9bdffeb94eec14 (diff)
Removed references to old code
With the LaaS 2.0 rewrite, there was still some old/dead/broken code being referenced. This patch fixes that. Change-Id: I25803652bc59bba1e416e526d205742c52f14a65 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
-rw-r--r--src/booking/views.py127
-rw-r--r--src/resource_inventory/admin.py2
2 files changed, 1 insertions, 128 deletions
diff --git a/src/booking/views.py b/src/booking/views.py
index c139b4c..9b9860f 100644
--- a/src/booking/views.py
+++ b/src/booking/views.py
@@ -19,7 +19,6 @@ from django.views.generic import TemplateView
from django.shortcuts import redirect, render
import json
-from booking.forms import BookingForm, BookingEditForm
from resource_inventory.models import ResourceBundle
from resource_inventory.resource_manager import ResourceManager
from booking.models import Booking, Installer, Opsys
@@ -42,132 +41,6 @@ def drop_filter(context):
context.update({'installer_filter': json.dumps(installer_filter), 'scenario_filter': json.dumps(scenario_filter)})
-class BookingFormView(FormView):
- template_name = "booking/booking_calendar.html"
- form_class = BookingForm
-
- def dispatch(self, request, *args, **kwargs):
- self.resource = get_object_or_404(ResourceBundle, id=self.kwargs['resource_id'])
- return super(BookingFormView, self).dispatch(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- title = 'Booking: ' + str(self.resource.id)
- context = super(BookingFormView, self).get_context_data(**kwargs)
- context.update({'title': title, 'resource': self.resource})
-
- drop_filter(context)
-
- return context
-
- def get_success_url(self):
- return reverse('booking:create', kwargs=self.kwargs)
-
- def form_valid(self, form):
- if not self.request.user.is_authenticated:
- messages.add_message(self.request, messages.ERROR,
- 'You need to be logged in to book a Pod.')
- return super(BookingFormView, self).form_invalid(form)
-
- if form.cleaned_data['end'] - form.cleaned_data['start'] > timezone.timedelta(days=21):
- messages.add_message(self.request, messages.ERROR,
- 'Bookings can be no more than 3 weeks long.')
- return super(BookingFormView, self).form_invalid(form)
-
- user = self.request.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,
- owner=user
- )
- try:
- booking.save()
- except ValueError as err:
- messages.add_message(self.request, messages.ERROR, err)
- return super(BookingFormView, self).form_invalid(form)
- messages.add_message(self.request, messages.SUCCESS, 'Booking saved')
- return super(BookingFormView, self).form_valid(form)
-
-
-class BookingEditFormView(FormView):
- template_name = "booking/booking_calendar.html"
- form_class = BookingEditForm
-
- def is_valid(self):
- return True
-
- def dispatch(self, request, *args, **kwargs):
- self.resource = get_object_or_404(ResourceBundle, id=self.kwargs['resource_id'])
- self.original_booking = get_object_or_404(Booking, id=self.kwargs['booking_id'])
- return super(BookingEditFormView, self).dispatch(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- title = 'Editing Booking on: ' + self.resource.name
- context = super(BookingEditFormView, self).get_context_data(**kwargs)
- context.update({'title': title, 'resource': self.resource, 'booking': self.original_booking})
-
- drop_filter(context)
-
- return context
-
- def get_form_kwargs(self):
- kwargs = super(BookingEditFormView, self).get_form_kwargs()
- kwargs['purpose'] = self.original_booking.purpose
- kwargs['start'] = self.original_booking.start
- kwargs['end'] = self.original_booking.end
- return kwargs
-
- def get_success_url(self):
- return reverse('booking:create', args=(self.resource.id,))
-
- def form_valid(self, form):
-
- if not self.request.user.is_authenticated:
- messages.add_message(self.request, messages.ERROR,
- 'You need to be logged in to book a Pod.')
- return super(BookingEditFormView, self).form_invalid(form)
-
- if not self.request.user == self.original_booking.user:
- messages.add_message(self.request, messages.ERROR,
- 'You are not the owner of this booking.')
- return super(BookingEditFormView, self).form_invalid(form)
-
- # Do Conflict Checks
- if self.original_booking.end != form.cleaned_data['end']:
- if form.cleaned_data['end'] - self.original_booking.end > timezone.timedelta(days=7):
- messages.add_message(self.request, messages.ERROR,
- 'Extensions can not be longer than one week.')
- return super(BookingEditFormView, self).form_invalid(form)
- elif self.original_booking.ext_count <= 0:
- messages.add_message(self.request, messages.ERROR,
- 'Cannot change end date after maximum number of extensions reached.')
- return super(BookingEditFormView, self).form_invalid(form)
-
- else:
- self.original_booking.ext_count -= 1
-
- if self.original_booking.start != form.cleaned_data['start']:
- if timezone.now() > form.cleaned_data['start']:
- messages.add_message(self.request, messages.ERROR,
- 'Cannot change start date after it has occurred.')
- return super(BookingEditFormView, self).form_invalid(form)
- self.original_booking.start = form.cleaned_data['start']
- self.original_booking.end = form.cleaned_data['end']
- self.original_booking.purpose = form.cleaned_data['purpose']
- self.original_booking.installer = form.cleaned_data['installer']
- self.original_booking.scenario = form.cleaned_data['scenario']
- self.original_booking.reset = form.cleaned_data['reset']
- try:
- self.original_booking.save()
- except ValueError as err:
- messages.add_message(self.request, messages.ERROR, err)
- return super(BookingEditFormView, self).form_invalid(form)
-
- return super(BookingEditFormView, self).form_valid(form)
-
-
class BookingView(TemplateView):
template_name = "booking/booking_detail.html"
diff --git a/src/resource_inventory/admin.py b/src/resource_inventory/admin.py
index 222877a..37b0c45 100644
--- a/src/resource_inventory/admin.py
+++ b/src/resource_inventory/admin.py
@@ -16,7 +16,7 @@ profiles = [HostProfile, InterfaceProfile, DiskProfile, CpuProfile, RamProfile]
admin.site.register(profiles)
-generics = [GenericResourceBundle, GenericResource, GenericHost, GenericPod, GenericInterface]
+generics = [GenericResourceBundle, GenericResource, GenericHost, GenericInterface]
admin.site.register(generics)