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

TMSS-207: added methods to get input- and output-dataproducts

parent bed5a64e
No related branches found
No related tags found
1 merge request!175Resolve TMSS-207
...@@ -204,6 +204,14 @@ class TMSSsession(object): ...@@ -204,6 +204,14 @@ class TMSSsession(object):
return None return None
return result return result
def get_subtask_output_dataproducts(self, subtask_id: int) -> []:
'''get the output dataproducts of the subtask with the given subtask_id'''
return self.get_path_as_json_object('subtask/%s/output_dataproducts' % subtask_id)
def get_subtask_input_dataproducts(self, subtask_id: int) -> []:
'''get the input dataproducts of the subtask with the given subtask_id'''
return self.get_path_as_json_object('subtask/%s/input_dataproducts' % subtask_id)
def specify_observation_task(self, task_id: int) -> requests.Response: def specify_observation_task(self, task_id: int) -> requests.Response:
"""specify observation for the given draft task by just doing a REST API call """ """specify observation for the given draft task by just doing a REST API call """
result = self.session.get(url='%s/api/task/%s/specify_observation' % (self.base_url, task_id)) result = self.session.get(url='%s/api/task/%s/specify_observation' % (self.base_url, task_id))
......
...@@ -224,6 +224,27 @@ class SubtaskViewSet(LOFARViewSet): ...@@ -224,6 +224,27 @@ class SubtaskViewSet(LOFARViewSet):
context={'request': request}) context={'request': request})
return RestResponse(serializer.data) return RestResponse(serializer.data)
@swagger_auto_schema(responses={200: 'The input dataproducts of this subtask.',
403: 'forbidden'},
operation_description="Get the input dataproducts of this subtask.")
@action(methods=['get'], detail=True, url_name='input_dataproducts')
def input_dataproducts(self, request, pk=None):
dataproducts = models.Dataproduct.objects.filter(subtaskinput__subtask_id=pk)
serializer = serializers.DataproductSerializer(dataproducts, many=True, context={'request': request})
return RestResponse(serializer.data)
@swagger_auto_schema(responses={200: 'The output dataproducts of this subtask.',
403: 'forbidden'},
operation_description="Get the output dataproducts of this subtask.")
@action(methods=['get'], detail=True, url_name='output_dataproducts')
def output_dataproducts(self, request, pk=None):
dataproducts = models.Dataproduct.objects.filter(producer__subtask_id=pk)
serializer = serializers.DataproductSerializer(dataproducts, many=True, context={'request': request})
return RestResponse(serializer.data)
class SubtaskNestedViewSet(LOFARNestedViewSet): class SubtaskNestedViewSet(LOFARNestedViewSet):
queryset = models.Subtask.objects.all() queryset = models.Subtask.objects.all()
serializer_class = serializers.SubtaskSerializer serializer_class = serializers.SubtaskSerializer
......
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