Fix is_reservation_allowed when restriction last indefinitely
@@ -55,7 +55,6 @@ class ReservationVerifier:
start_date = reservation.starts_at
end_date = reservation.ends_at
- reservation_allowed = False
while True:
start_date_changed = False
for restriction in restrictions:
@@ -63,6 +62,10 @@ class ReservationVerifier:
(restriction.ends_at is None or start_date < restriction.ends_at):
schedules = restriction.schedules
if not schedules:
+ if restriction.ends_at is None:
+ # If restriction lasts indefinitely, reservation is allowed
+ return True
+ else:
start_date = restriction.ends_at
start_date_changed = True
else:
@@ -71,11 +74,10 @@ class ReservationVerifier:
start_date_changed = True
start_date = date
if start_date >= end_date:
- reservation_allowed = True
+ return True
+ if not start_date_changed:
break
- if reservation_allowed or not start_date_changed:
- break
- return reservation_allowed
+ return False
@classmethod
def update_user_reservations_statuses(cls, user, have_users_permissions_increased):
