Skip to content

Commit

Permalink
Fix data action for TaskViewSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanovic committed Feb 4, 2019
1 parent 17ce661 commit 828989b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,16 @@ class Meta:
model = ClientFile
fields = ('file', )

def to_internal_value(self, data):
return { 'file': data }


class ServerFileSerializer(serializers.ModelSerializer):
class Meta:
model = ServerFile
fields = ('file', )

def to_internal_value(self, data):
return { 'file': data }


class RemoteFileSerializer(serializers.ModelSerializer):
class Meta:
model = RemoteFile
fields = ('file', )

def to_internal_value(self, data):
return { 'file' : data }

class RqStatusSerializer(serializers.Serializer):
state = serializers.ChoiceField(choices=[
"Queued", "Started", "Finished", "Failed"])
Expand All @@ -98,9 +87,21 @@ class Meta:
fields = ('client_files', 'server_files', 'remote_files')

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')
client_files = validated_data.pop('clientfile_set')
server_files = validated_data.pop('serverfile_set')
remote_files = validated_data.pop('remotefile_set')

for file in client_files:
client_file = ClientFile(task=instance, **file)
client_file.save()

for file in server_files:
server_file = ServerFile(task=instance, **file)
server_file.save()

for file in remote_files:
remote_file = RemoteFile(task=instance, **file)
remote_file.save()

return instance

Expand Down

0 comments on commit 828989b

Please sign in to comment.