Skip to content
Snippets Groups Projects
Commit b245dfe4 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-605: filter for overlap of reservation and SUB times

parent 0d297556
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!624TMSS-605: Add check for stations in use when saving reservation, and fix...
......@@ -1435,10 +1435,16 @@ class Reservation(NamedCommon, TemplateSchemaMixin):
return None
def _prevent_reserving_stations_that_are_used_in_active_units(self):
# todo: we cannot filter for status in SQL because is a property, find a way to reduce the queryset reasonably
# todo: filter for the time range of the reservation?
# Determine active scheduling units that overlap in time with the reservation
# Note: we cannot filter for status and on sky times in SQL because these are properties
# todo: find a way to reduce the initial queryset reasonably
subs = SchedulingUnitBlueprint.objects.all()
active_subs = [x for x in subs if x.status in [SchedulingUnitBlueprint.Status.OBSERVING.value, SchedulingUnitBlueprint.Status.SCHEDULED.value]]
active_subs = [x for x in subs if (x.status in [SchedulingUnitBlueprint.Status.OBSERVING.value, SchedulingUnitBlueprint.Status.SCHEDULED.value]
and x.scheduled_on_sky_stop_time >= self.start_time)]
if self.stop_time:
active_subs = [x for x in active_subs if self.scheduled_on_sky_start_time <= self.stop_time]
# Raise an exception if any of these scheduling units uses a station that shall be reserved
if "resources" in self.specifications_doc and "stations" in self.specifications_doc["resources"]:
stations_to_reserve = self.specifications_doc['resources']['stations']
for sub in active_subs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment