aboutsummaryrefslogtreecommitdiffstats
path: root/src/booking
diff options
context:
space:
mode:
Diffstat (limited to 'src/booking')
-rw-r--r--src/booking/forms.py4
-rw-r--r--src/booking/quick_deployer.py8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/booking/forms.py b/src/booking/forms.py
index 9349ac1..de427ab 100644
--- a/src/booking/forms.py
+++ b/src/booking/forms.py
@@ -41,9 +41,7 @@ class QuickBookingForm(forms.Form):
super(QuickBookingForm, self).__init__(data=data, **kwargs)
self.fields["image"] = forms.ModelChoiceField(
- queryset=Image.objects.difference(
- Image.objects.filter(public=False).difference(Image.objects.filter(owner=user))
- )
+ Image.objects.filter(public=True) | Image.objects.filter(owner=user)
)
self.fields['users'] = forms.CharField(
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index cc593fa..640ded9 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -92,6 +92,10 @@ class NoRemainingPublicNetwork(Exception):
pass
+class BookingPermissionException(Exception):
+ pass
+
+
def parse_host_field(host_field_contents):
host_json = json.loads(host_field_contents)
lab_dict = host_json['labs'][0]
@@ -262,6 +266,10 @@ def create_from_form(form, request):
data['host_profile'] = host_profile
check_invariants(request, **data)
+ # check booking privileges
+ if Booking.objects.filter(owner=request.user, end__gt=timezone.now()).count() >= 3 and not request.user.userprofile.booking_privledge:
+ raise BookingPermissionException("You do not have permission to have more than 3 bookings at a time.")
+
check_available_matching_host(lab, host_profile) # requires cleanup if failure after this point
grbundle = generate_grb(request.user, lab, quick_booking_id)