diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py index f03c7b03a4e3e083d4fc4f9187acf40e4a223287..c66c17b2461f1f96fea446744f51e3de7a41d8a2 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py @@ -1201,7 +1201,8 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): scheduling_unit_blueprint = get_object_or_404(models.SchedulingUnitBlueprint, pk=pk) # update the task graph via the draft with copies of the failed tasks - update_task_graph_from_specifications_doc(scheduling_unit_blueprint.draft, scheduling_unit_blueprint.specifications_doc_including_copies_for_failed_tasks) + scheduling_unit_draft = scheduling_unit_blueprint.draft + update_task_graph_from_specifications_doc(scheduling_unit_draft, scheduling_unit_blueprint.specifications_doc_including_copies_for_failed_tasks) # and then reflect the new draft graph in this blueprint scheduling_unit_blueprint = update_task_blueprints_and_subtasks_graph_from_draft(scheduling_unit_blueprint) @@ -1210,6 +1211,22 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): return RestResponse(serializer.data) + @swagger_auto_schema(responses={201: "This blueprint's SchedulingUnitDraft including new editable TaskDrafts copies for the failed TaskBlueprints", + 403: 'forbidden'}, + operation_description="Create editable TaskDraft copies of failed tasks in the original SchedulingUnitDraft.") + @action(methods=['post'], detail=True, url_name="create_copies_of_failed_tasks_in_draft", name="Create editable TaskDraft copies of failed tasks in the original SchedulingUnitDraft") + def create_copies_of_failed_tasks_in_draft(self, request, pk=None): + scheduling_unit_blueprint = get_object_or_404(models.SchedulingUnitBlueprint, pk=pk) + + # update the task graph in the draft with copies of the failed tasks + scheduling_unit_draft = scheduling_unit_blueprint.draft + scheduling_unit_draft = update_task_graph_from_specifications_doc(scheduling_unit_draft, scheduling_unit_blueprint.specifications_doc_including_copies_for_failed_tasks) + + # return the updated draft + return Response(serializers.SchedulingUnitDraftSerializer(scheduling_unit_draft, context={'request':request}).data, + status=status.HTTP_200_OK) + + @swagger_auto_schema(responses={201: 'The newly copied SchedulingUnitDraft', 403: 'forbidden'}, operation_description="Copy this blueprint into a new SchedulingUnitDraft instance") diff --git a/SAS/TMSS/client/lib/tmss_http_rest_client.py b/SAS/TMSS/client/lib/tmss_http_rest_client.py index 6e2a05343d1b69f6ae0b81b95e5c19ff65a5da8e..968fc748865d969647efdf483d66bd9c2991ee7e 100644 --- a/SAS/TMSS/client/lib/tmss_http_rest_client.py +++ b/SAS/TMSS/client/lib/tmss_http_rest_client.py @@ -653,6 +653,12 @@ class TMSSsession(object): return self.post_to_path_and_get_result_as_json_object('scheduling_unit_blueprint/%s/create_copies_of_failed_tasks_via_draft' % (scheduling_unit_blueprint_id, ), retry_count=retry_count) + def create_copies_of_failed_tasks_in_draft(self, scheduling_unit_blueprint_id: int, retry_count: int=0) -> {}: + """Create editable TaskDraft copies of failed tasks in the original SchedulingUnitDraft. + returns the scheduling_unit_draft (which contains link(s) to new task_draft copies, or raises.""" + return self.post_to_path_and_get_result_as_json_object('scheduling_unit_blueprint/%s/create_copies_of_failed_tasks_in_draft' % (scheduling_unit_blueprint_id, ), retry_count=retry_count) + + def copy_scheduling_unit_draft(self, scheduling_unit_draft_id: int, retry_count: int=0) -> {}: """Create a copy of the given scheduling_unit_draft including copies of all its task_drafts and relations. returns the copied scheduling_unit_draft, or raises."""