Skip to content
Snippets Groups Projects
Commit e3189ae9 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-261: action/url to retreive all subtasks for a scheduling unit

parent a885c014
No related branches found
No related tags found
1 merge request!409Resolve TMSS-261
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment