diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py index 6b5c19e704e5ccdf501820caf3deb1db9addceb3..19e5818a63460c6f05f29ba917903ece3b5589af 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py @@ -810,6 +810,19 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): status=status.HTTP_200_OK) + @swagger_auto_schema(responses={201: "This SchedulingUnitBlueprint, with references to the created Cleanup TaskBlueprints.", + 403: 'forbidden'}, + operation_description="Create a cleanup task for this scheduling unit.") + @action(methods=['get'], detail=True, url_name="create_cleanuptask", name="Create a cleanup task for this scheduling unit") + def create_cleanuptask_for_scheduling_unit_blueprint(self, request, pk=None): + scheduling_unit_blueprint = get_object_or_404(models.SchedulingUnitBlueprint, pk=pk) + scheduling_unit_blueprint = create_cleanuptask_for_scheduling_unit_blueprint(scheduling_unit_blueprint) + + # return a response with the new serialized scheduling_unit_blueprint (with references to the created task_blueprint and subtask) + return Response(serializers.SchedulingUnitBlueprintSerializer(scheduling_unit_blueprint, context={'request':request}).data, + status=status.HTTP_201_CREATED) + + class SchedulingUnitBlueprintExtendedViewSet(SchedulingUnitBlueprintViewSet): serializer_class = serializers.SchedulingUnitBlueprintExtendedSerializer