From 1f18fde0f259abb2a9994e584eabcbe575a1f863 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Tue, 9 Jul 2024 10:14:19 +0200 Subject: [PATCH] TMSS-3021: allow scheduled units to be adapted as well --- SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py | 1 + SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index fe7a87aebd4..f442f947609 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -204,6 +204,7 @@ class SchedulingUnitStatus(AbstractChoice): # some common combinations of statuses PRE_ACTIVE_STATUS_VALUES = (Choices.DEFINED.value, Choices.SCHEDULABLE.value, Choices.UNSCHEDULABLE.value) + PRE_OBSERVING_STATUS_VALUES = PRE_ACTIVE_STATUS_VALUES + (Choices.SCHEDULED.value,) ACTIVE_STATUS_VALUES = (Choices.SCHEDULED.value, Choices.OBSERVING.value, Choices.OBSERVED.value, Choices.PROCESSING.value, Choices.PROCESSED.value, Choices.INGESTING.value, Choices.INGESTED.value) SCHEDULABLE_OR_ACTIVE_STATUS_VALUES = (Choices.SCHEDULABLE.value,) + ACTIVE_STATUS_VALUES ACTIVE_OR_FINISHED_STATUS_VALUES = (Choices.FINISHED.value,) + ACTIVE_STATUS_VALUES diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py index 4bc1ed194be..6105317ffc7 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py @@ -1639,7 +1639,7 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): scheduling_unit_blueprint = get_object_or_404(models.SchedulingUnitBlueprint, pk=pk) - if scheduling_unit_blueprint.status.value not in models.SchedulingUnitStatus.PRE_ACTIVE_STATUS_VALUES: + if scheduling_unit_blueprint.status.value not in models.SchedulingUnitStatus.PRE_OBSERVING_STATUS_VALUES: return Response(f'Error: scheduling unit blueprint is already in status={scheduling_unit_blueprint.status.value}', status=400) with transaction.atomic(): @@ -1675,6 +1675,10 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): # create a fresh blueprint from the updated draft with correct duration. new_blueprint = create_scheduling_unit_blueprint_and_tasks_and_subtasks_from_scheduling_unit_draft(new_draft) + # unschedule the old blueprint if needed + if scheduling_unit_blueprint.status.value == SchedulingUnitStatus.Choices.SCHEDULED.value: + scheduling_unit_blueprint = unschedule_subtasks_in_scheduling_unit_blueprint(scheduling_unit_blueprint) + # mark the old blueprint obsolete mark_scheduling_unit_blueprint_as_obsolete(scheduling_unit_blueprint) -- GitLab