aboutsummaryrefslogtreecommitdiffstats
path: root/src/booking/quick_deployer.py
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2019-04-08 13:17:45 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2019-04-16 12:51:41 -0400
commitb3a44b5d833b0d02735bc2c42d5981c0368da7a6 (patch)
tree21cbc69f5fdbefb9960f89e1100572d8da2e9c71 /src/booking/quick_deployer.py
parent4391d9794ba82e609acc7fff43b8ae449fcb87c7 (diff)
Limit total number of active bookings per user
Change-Id: I4f79e3225f423274de3d2da912a080521447b185 Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src/booking/quick_deployer.py')
-rw-r--r--src/booking/quick_deployer.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index f076a2e..7059313 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -90,6 +90,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]
@@ -246,6 +250,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)