Skip to content

Commit

Permalink
TaskDataSerializer is in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich committed Feb 4, 2019
1 parent 51eca12 commit 17ce661
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions cvat/apps/engine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:pk>/data', views.dummy_view,
name='task-data'),

path( # GET, DELETE, PATCH, PUT
REST_API_PREFIX + 'tasks/<int:pk>/annotations/',
Expand Down
10 changes: 9 additions & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 17ce661

Please sign in to comment.