diff --git a/cvat/apps/engine/migrations/0016_auto_20190130_1838.py b/cvat/apps/engine/migrations/0016_auto_20190130_1838.py new file mode 100644 index 000000000000..b448348f9d8b --- /dev/null +++ b/cvat/apps/engine/migrations/0016_auto_20190130_1838.py @@ -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), + ), + ] diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index 566ffa27259e..f8324b18fbdf 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -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 @@ -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' @@ -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: diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index d553f64c7c2a..899cab63b7e5 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -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')