From e3189ae9ba22ebc21bbabefe555a8b030ccca6a2 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 4 Mar 2021 18:27:48 +0100 Subject: [PATCH] TMSS-261: action/url to retreive all subtasks for a scheduling unit --- .../src/tmss/tmssapp/viewsets/specification.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py index 12fa2504a11..6d2c71da1cf 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py @@ -730,6 +730,18 @@ class SchedulingUnitBlueprintViewSet(LOFARViewSet): # result is list of dict so thats why return JsonResponse(result, safe=False) + @swagger_auto_schema(responses={200: "All Subtasks in this SchedulingUnitBlueprint", + 403: 'forbidden'}, + operation_description="Get all subtasks for this scheduling_unit") + @action(methods=['get'], detail=True, url_name="subtasks", name="all subtasks in this scheduling_unit") + def subtasks(self, request, pk=None): + subtasks = models.Subtask.objects.all().filter(task_blueprint__scheduling_unit_blueprint_id=pk). \ + select_related('state', 'specifications_template', 'specifications_template__type', 'cluster', 'created_or_updated_by_user').all() + + # return a response with the new serialized scheduling_unit_blueprint (with references to the created task_blueprint(s) and (scheduled) subtasks) + return Response(serializers.SubtaskSerializer(subtasks, many=True, context={'request':request}).data, + status=status.HTTP_200_OK) + class SchedulingUnitBlueprintExtendedViewSet(SchedulingUnitBlueprintViewSet): serializer_class = serializers.SchedulingUnitBlueprintExtendedSerializer -- GitLab