diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index eecd804df94c..022d4ed61090 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -97,8 +97,13 @@ class Meta: model = Task fields = ('client_files', 'server_files', 'remote_files') - def create(self, validated_data): - pass + def update(self, instance, validated_data): + client_files = validated_data.pop('client_files') + server_files = validated_data.pop('server_files') + remote_files = validated_data.pop('remote_files') + + return instance + class TaskSerializer(serializers.ModelSerializer): labels = LabelSerializer(many=True, source='label_set', partial=True) diff --git a/cvat/apps/engine/urls.py b/cvat/apps/engine/urls.py index ace7e560e55f..cedc722b7cd5 100644 --- a/cvat/apps/engine/urls.py +++ b/cvat/apps/engine/urls.py @@ -21,9 +21,6 @@ path('api/docs/', include_docs_urls(title='CVAT REST API')), # entry point for API path(REST_API_PREFIX, include(router.urls)), - path( # PUT - REST_API_PREFIX + 'tasks//data', views.dummy_view, - name='task-data'), path( # GET, DELETE, PATCH, PUT REST_API_PREFIX + 'tasks//annotations/', diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 917e37153354..e237070b41cd 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -35,7 +35,7 @@ from cvat.apps.engine.models import StatusChoice, Task, Job from cvat.apps.engine.serializers import (TaskSerializer, UserSerializer, ExceptionSerializer, AboutSerializer, JobSerializer, ImageMetaSerializer, - RqStatusSerializer) + RqStatusSerializer, TaskDataSerializer) from django.contrib.auth.models import User # Server REST API @@ -95,6 +95,14 @@ def jobs(self, request, pk, version): return Response(serializer.data) + @action(detail=True, methods=['PUT'], serializer_class=TaskDataSerializer) + def data(self, request, pk, version): + db_task = self.get_object() + serializer = TaskDataSerializer(db_task, data=request.data) + if serializer.is_valid(raise_exception=True): + serializer.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + @action(detail=True, methods=['GET'], serializer_class=RqStatusSerializer) def status(self, request, pk, version): response = self._get_rq_response(queue="default",