diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py index 4aab0b865a25b65e95051e876c79b3a3ce308536..f3f230b3e966e0aee34a383529bf17b93db377e4 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py @@ -95,9 +95,10 @@ def create_scheduling_unit_draft_from_observing_strategy_template(strategy_templ # use the latest scheduling_constraints_template (can be None, which is acceptable) scheduling_constraints_template = models.SchedulingConstraintsTemplate.objects.all().order_by('created_at').last() - # extract the scheduling_constraints_doc from the template_doc, - # so we can feed in seperately into the SchedulingUnitDraft. - scheduling_constraints_doc = specifications_doc.pop('scheduling_constraints_doc', {}) + # extract the scheduling_constraints_doc from the specifications_doc_overrides, or else from the generated and defaults-including-specifications_doc, + # so we can feed in separately into the SchedulingUnitDraft. + scheduling_constraints_doc = specifications_doc_overrides.get('scheduling_constraints_doc', specifications_doc.get('scheduling_constraints_doc',{})) + specifications_doc.pop('scheduling_constraints_doc', {}) # make sure it's popped/removed from the specifications_doc with transaction.atomic(): scheduling_unit_draft = models.SchedulingUnitDraft.objects.create(name=name or strategy_template.name,