Skip to content

Commit

Permalink
Implementation of create/task is in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich committed Jan 30, 2019
1 parent 0169ac3 commit 20bad7a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
30 changes: 30 additions & 0 deletions cvat/apps/engine/migrations/0016_auto_20190130_1838.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 2.1.5 on 2019-01-30 15:38

import cvat.apps.engine.models
import django.core.files.storage
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('engine', '0015_task_segment_size'),
]

operations = [
migrations.AddField(
model_name='task',
name='client_files',
field=models.FileField(blank=True, storage=django.core.files.storage.FileSystemStorage(), upload_to=cvat.apps.engine.models.upload_path_handler),
),
migrations.AddField(
model_name='task',
name='remote_files',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='task',
name='server_files',
field=models.TextField(blank=True),
),
]
12 changes: 12 additions & 0 deletions cvat/apps/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.conf import settings

from django.contrib.auth.models import User
from django.core.files.storage import FileSystemStorage

from io import StringIO
from enum import Enum
Expand All @@ -15,6 +16,11 @@
import re
import os

fs = FileSystemStorage()

def upload_path_handler(instance, filename):
return os.path.join(instance.get_upload_dirname(), filename)

class StatusChoice(Enum):
ANNOTATION = 'annotation'
VALIDATION = 'validation'
Expand Down Expand Up @@ -50,8 +56,14 @@ class Task(models.Model):
segment_size = models.PositiveIntegerField()
z_order = models.BooleanField(default=False)
flipped = models.BooleanField(default=False)
# FIXME: remote source field
source = SafeCharField(max_length=256, default="unknown")
status = models.CharField(max_length=32, default=StatusChoice.ANNOTATION)
# FIXME: multiple files upload doesn't work
client_files = models.FileField(upload_to=upload_path_handler, storage=fs,
blank=True)
server_files = models.TextField(blank=True)
remote_files = models.TextField(blank=True)

# Extend default permission model
class Meta:
Expand Down
11 changes: 10 additions & 1 deletion cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,23 @@ class Meta:
class TaskSerializer(serializers.ModelSerializer):
labels = LabelSerializer(many=True, source='label_set')
segments = SegmentSerializer(many=True, source='segment_set', read_only=True)
server_files = serializers.ListField(
child=serializers.CharField(max_length=1024, trim_whitespace=True)
)
remote_files = serializers.ListField(
child=serializers.CharField(max_length=1024)
)


class Meta:
model = Task
fields = ('url', 'id', 'name', 'size', 'mode', 'owner', 'assignee',
'bug_tracker', 'created_date', 'updated_date', 'overlap',
'segment_size', 'z_order', 'flipped', 'status', 'labels', 'segments')
'segment_size', 'z_order', 'flipped', 'status', 'labels', 'segments',
'server_files', 'client_files', 'remote_files')
read_only_fields = ('size', 'mode', 'created_date', 'updated_date',
'overlap', 'status', 'segment_size')
write_only_fields = ('server_files', 'client_files', 'remote_files')

def create(self, validated_data):
labels = validated_data.pop('labels')
Expand Down

0 comments on commit 20bad7a

Please sign in to comment.