Commit 7fc41630 authored by Jorrit Schaap's avatar Jorrit Schaap

TMSS-153: added REST url to get the parset for a subtask instance

parent 77206e56
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404
from lofar.sas.tmss.tmss.tmssapp.models.scheduling import SubtaskTemplate
from lofar.sas.tmss.tmss.tmssapp.models.scheduling import SubtaskTemplate, Subtask
from lofar.common.json_utils import get_default_json_object_for_schema
from lofar.sas.tmss.tmss.tmssapp.adapters.parset import convert_to_parset
def subtask_template_default_specification(request, subtask_template_pk:int):
subtask_template = get_object_or_404(SubtaskTemplate, pk=subtask_template_pk)
spec = get_default_json_object_for_schema(subtask_template.schema)
return JsonResponse(spec)
def subtask_parset(request, subtask_pk:int):
subtask = get_object_or_404(Subtask, pk=subtask_pk)
parset = convert_to_parset(subtask)
return HttpResponse(str(parset), content_type='text/plain')
......@@ -121,7 +121,9 @@ router.register(r'default_subtask_template', viewsets.DefaultSubtaskTemplateView
router.register(r'default_dataproduct_specifications_template', viewsets.DefaultDataproductSpecificationsTemplateViewSet)
router.register(r'subtask_input_selection_template', viewsets.SubtaskInputSelectionTemplateViewSet)
router.register(r'dataproduct_feedback_template', viewsets.DataproductFeedbackTemplateViewSet)
urlpatterns.append(re_path(r'subtask_template/(?P<subtask_template_pk>\d+)/default_specification', views.subtask_template_default_specification))
urlpatterns.append(re_path(r'subtask/(?P<subtask_pk>\d+)/parset', views.subtask_parset))
# instances
#router.register(r'subtask', viewsets.SubtaskViewSet) # todo: default view, re-activate or remove the JSON editor one in bottom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment