mirror of https://github.com/doccano/doccano.git
Hironsan
2 years ago
64 changed files with 806 additions and 371 deletions
Split View
Diff Options
-
23backend/api/admin.py
-
54backend/api/migrations/0036_auto_20220204_0201.py
-
81backend/api/migrations/0037_auto_20220204_0201.py
-
157backend/api/models.py
-
95backend/api/serializers.py
-
7backend/api/tests/api/utils.py
-
28backend/api/urls.py
-
2backend/app/urls.py
-
2backend/auto_labeling/migrations/0003_fill_task_type.py
-
26backend/auto_labeling/migrations/0004_alter_autolabelingconfig_project.py
-
2backend/auto_labeling/models.py
-
2backend/auto_labeling/pipeline/labels.py
-
2backend/auto_labeling/tests/test_views.py
-
2backend/auto_labeling/views.py
-
2backend/data_export/celery_tasks.py
-
5backend/data_export/pipeline/catalog.py
-
5backend/data_export/pipeline/factories.py
-
2backend/data_export/pipeline/repositories.py
-
2backend/data_export/tests/test_repositories.py
-
2backend/data_export/tests/test_views.py
-
2backend/data_export/views.py
-
2backend/data_import/celery_tasks.py
-
5backend/data_import/pipeline/catalog.py
-
2backend/data_import/pipeline/cleaners.py
-
2backend/data_import/pipeline/data.py
-
5backend/data_import/pipeline/factories.py
-
2backend/data_import/pipeline/labels.py
-
2backend/data_import/pipeline/writers.py
-
5backend/data_import/tests/test_tasks.py
-
2backend/data_import/tests/test_views.py
-
3backend/data_import/views.py
-
29backend/examples/migrations/0002_alter_example_project.py
-
2backend/examples/models.py
-
2backend/examples/tests/test_document.py
-
2backend/examples/tests/test_models.py
-
2backend/examples/views/example.py
-
2backend/examples/views/example_state.py
-
36backend/label_types/migrations/0003_auto_20220204_0201.py
-
2backend/label_types/models.py
-
2backend/label_types/tests/test_views.py
-
26backend/labels/migrations/0005_alter_relation_project.py
-
2backend/labels/models.py
-
2backend/labels/tests/test_category.py
-
2backend/labels/tests/test_span.py
-
2backend/labels/tests/test_text_label.py
-
2backend/labels/tests/test_views.py
-
2backend/labels/views.py
-
2backend/metrics/tests.py
-
18backend/projects/admin.py
-
2backend/projects/apps.py
-
2backend/projects/management/commands/create_member.py
-
155backend/projects/migrations/0002_auto_20220204_0201.py
-
49backend/projects/migrations/0003_auto_20220204_0551.py
-
157backend/projects/models.py
-
91backend/projects/serializers.py
-
2backend/projects/signals.py
-
0backend/projects/tests/__init__.py
-
0backend/projects/tests/test_member.py
-
2backend/projects/tests/test_project.py
-
2backend/projects/tests/test_tag.py
-
29backend/projects/urls.py
-
8backend/projects/views/member.py
-
4backend/projects/views/project.py
-
4backend/projects/views/tag.py
@ -1,23 +0,0 @@ |
|||
from django.contrib import admin |
|||
|
|||
from .models import (Project, Seq2seqProject, SequenceLabelingProject, Tag, |
|||
TextClassificationProject) |
|||
|
|||
|
|||
class ProjectAdmin(admin.ModelAdmin): |
|||
list_display = ('name', 'description', 'project_type', 'random_order', 'collaborative_annotation') |
|||
ordering = ('project_type',) |
|||
search_fields = ('name',) |
|||
|
|||
|
|||
class TagAdmin(admin.ModelAdmin): |
|||
list_display = ('project', 'text', ) |
|||
ordering = ('project', 'text', ) |
|||
search_fields = ('text',) |
|||
|
|||
|
|||
admin.site.register(Project, ProjectAdmin) |
|||
admin.site.register(TextClassificationProject, ProjectAdmin) |
|||
admin.site.register(SequenceLabelingProject, ProjectAdmin) |
|||
admin.site.register(Seq2seqProject, ProjectAdmin) |
|||
admin.site.register(Tag, TagAdmin) |
@ -0,0 +1,54 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0035_auto_20220128_0246'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.RemoveField( |
|||
model_name='imageclassificationproject', |
|||
name='project_ptr', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='intentdetectionandslotfillingproject', |
|||
name='project_ptr', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='project', |
|||
name='created_by', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='project', |
|||
name='polymorphic_ctype', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='seq2seqproject', |
|||
name='project_ptr', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='sequencelabelingproject', |
|||
name='project_ptr', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='speech2textproject', |
|||
name='project_ptr', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='tag', |
|||
name='project', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='textclassificationproject', |
|||
name='project_ptr', |
|||
), |
|||
], |
|||
database_operations=[] |
|||
) |
|||
] |
@ -0,0 +1,81 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('examples', '0002_alter_example_project'), |
|||
('labels', '0005_alter_relation_project'), |
|||
('projects', '0002_auto_20220204_0201'), |
|||
('auto_labeling', '0004_alter_autolabelingconfig_project'), |
|||
('api', '0036_auto_20220204_0201'), |
|||
('label_types', '0003_auto_20220204_0201'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.DeleteModel( |
|||
name='ImageClassificationProject', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='IntentDetectionAndSlotFillingProject', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='Project', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='Seq2seqProject', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='SequenceLabelingProject', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='Speech2textProject', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='Tag', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='TextClassificationProject', |
|||
), |
|||
], |
|||
database_operations=[ |
|||
migrations.AlterModelTable( |
|||
name='ImageClassificationProject', |
|||
table='projects_imageclassificationproject' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='IntentDetectionAndSlotFillingProject', |
|||
table='projects_intentdetectionandslotfillingproject' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='Project', |
|||
table='projects_project' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='Seq2seqProject', |
|||
table='projects_seq2seqproject' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='SequenceLabelingProject', |
|||
table='projects_sequencelabelingproject' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='Speech2textProject', |
|||
table='projects_speech2textproject' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='Tag', |
|||
table='projects_tag' |
|||
), |
|||
migrations.AlterModelTable( |
|||
name='TextClassificationProject', |
|||
table='projects_textclassificationproject' |
|||
), |
|||
] |
|||
) |
|||
|
|||
] |
@ -1,157 +0,0 @@ |
|||
import abc |
|||
|
|||
from django.contrib.auth.models import User |
|||
from django.db import models |
|||
from polymorphic.models import PolymorphicModel |
|||
|
|||
DOCUMENT_CLASSIFICATION = 'DocumentClassification' |
|||
SEQUENCE_LABELING = 'SequenceLabeling' |
|||
SEQ2SEQ = 'Seq2seq' |
|||
SPEECH2TEXT = 'Speech2text' |
|||
IMAGE_CLASSIFICATION = 'ImageClassification' |
|||
INTENT_DETECTION_AND_SLOT_FILLING = 'IntentDetectionAndSlotFilling' |
|||
PROJECT_CHOICES = ( |
|||
(DOCUMENT_CLASSIFICATION, 'document classification'), |
|||
(SEQUENCE_LABELING, 'sequence labeling'), |
|||
(SEQ2SEQ, 'sequence to sequence'), |
|||
(INTENT_DETECTION_AND_SLOT_FILLING, 'intent detection and slot filling'), |
|||
(SPEECH2TEXT, 'speech to text'), |
|||
(IMAGE_CLASSIFICATION, 'image classification') |
|||
) |
|||
|
|||
|
|||
class Project(PolymorphicModel): |
|||
name = models.CharField(max_length=100) |
|||
description = models.TextField(default='') |
|||
guideline = models.TextField(default='', blank=True) |
|||
created_at = models.DateTimeField(auto_now_add=True) |
|||
updated_at = models.DateTimeField(auto_now=True) |
|||
created_by = models.ForeignKey( |
|||
User, |
|||
on_delete=models.SET_NULL, |
|||
null=True, |
|||
) |
|||
project_type = models.CharField(max_length=30, choices=PROJECT_CHOICES) |
|||
random_order = models.BooleanField(default=False) |
|||
collaborative_annotation = models.BooleanField(default=False) |
|||
single_class_classification = models.BooleanField(default=False) |
|||
|
|||
@property |
|||
@abc.abstractmethod |
|||
def is_text_project(self) -> bool: |
|||
return False |
|||
|
|||
@property |
|||
def can_define_label(self) -> bool: |
|||
"""Whether or not the project can define label(ignoring the type of label)""" |
|||
return False |
|||
|
|||
@property |
|||
def can_define_relation(self) -> bool: |
|||
"""Whether or not the project can define relation.""" |
|||
return False |
|||
|
|||
@property |
|||
def can_define_category(self) -> bool: |
|||
"""Whether or not the project can define category.""" |
|||
return False |
|||
|
|||
@property |
|||
def can_define_span(self) -> bool: |
|||
"""Whether or not the project can define span.""" |
|||
return False |
|||
|
|||
def __str__(self): |
|||
return self.name |
|||
|
|||
|
|||
class TextClassificationProject(Project): |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_label(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_category(self) -> bool: |
|||
return True |
|||
|
|||
|
|||
class SequenceLabelingProject(Project): |
|||
allow_overlapping = models.BooleanField(default=False) |
|||
grapheme_mode = models.BooleanField(default=False) |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_label(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_span(self) -> bool: |
|||
return True |
|||
|
|||
|
|||
class Seq2seqProject(Project): |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return True |
|||
|
|||
|
|||
class IntentDetectionAndSlotFillingProject(Project): |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_label(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_category(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_span(self) -> bool: |
|||
return True |
|||
|
|||
|
|||
class Speech2textProject(Project): |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return False |
|||
|
|||
|
|||
class ImageClassificationProject(Project): |
|||
|
|||
@property |
|||
def is_text_project(self) -> bool: |
|||
return False |
|||
|
|||
@property |
|||
def can_define_label(self) -> bool: |
|||
return True |
|||
|
|||
@property |
|||
def can_define_category(self) -> bool: |
|||
return True |
|||
|
|||
|
|||
class Tag(models.Model): |
|||
text = models.TextField() |
|||
project = models.ForeignKey( |
|||
to=Project, |
|||
on_delete=models.CASCADE, |
|||
related_name='tags' |
|||
) |
|||
|
|||
def __str__(self): |
|||
return self.text |
@ -1,95 +0,0 @@ |
|||
from rest_framework import serializers |
|||
from rest_polymorphic.serializers import PolymorphicSerializer |
|||
|
|||
from .models import (ImageClassificationProject, |
|||
IntentDetectionAndSlotFillingProject, Project, |
|||
Seq2seqProject, SequenceLabelingProject, |
|||
Speech2textProject, Tag, TextClassificationProject) |
|||
|
|||
|
|||
class TagSerializer(serializers.ModelSerializer): |
|||
|
|||
class Meta: |
|||
model = Tag |
|||
fields = ('id', 'project', 'text', ) |
|||
read_only_fields = ('id', 'project') |
|||
|
|||
|
|||
class ProjectSerializer(serializers.ModelSerializer): |
|||
tags = TagSerializer(many=True, required=False) |
|||
|
|||
class Meta: |
|||
model = Project |
|||
fields = ( |
|||
'id', |
|||
'name', |
|||
'description', |
|||
'guideline', |
|||
'project_type', |
|||
'updated_at', |
|||
'random_order', |
|||
'created_by', |
|||
'collaborative_annotation', |
|||
'single_class_classification', |
|||
'is_text_project', |
|||
'can_define_label', |
|||
'can_define_relation', |
|||
'can_define_category', |
|||
'can_define_span', |
|||
'tags' |
|||
) |
|||
read_only_fields = ( |
|||
'updated_at', |
|||
'is_text_project', |
|||
'can_define_label', |
|||
'can_define_relation', |
|||
'can_define_category', |
|||
'can_define_span', |
|||
'tags' |
|||
) |
|||
|
|||
|
|||
class TextClassificationProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = TextClassificationProject |
|||
|
|||
|
|||
class SequenceLabelingProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = SequenceLabelingProject |
|||
fields = ProjectSerializer.Meta.fields + ('allow_overlapping', 'grapheme_mode') |
|||
|
|||
|
|||
class Seq2seqProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = Seq2seqProject |
|||
|
|||
|
|||
class IntentDetectionAndSlotFillingProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = IntentDetectionAndSlotFillingProject |
|||
|
|||
|
|||
class Speech2textProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = Speech2textProject |
|||
|
|||
|
|||
class ImageClassificationProjectSerializer(ProjectSerializer): |
|||
|
|||
class Meta(ProjectSerializer.Meta): |
|||
model = ImageClassificationProject |
|||
|
|||
|
|||
class ProjectPolymorphicSerializer(PolymorphicSerializer): |
|||
model_serializer_mapping = { |
|||
Project: ProjectSerializer, |
|||
**{ |
|||
cls.Meta.model: cls for cls in ProjectSerializer.__subclasses__() |
|||
} |
|||
} |
@ -1,35 +1,11 @@ |
|||
from django.urls import include, path |
|||
from django.urls import path |
|||
|
|||
from .views import project, tag, task |
|||
|
|||
urlpatterns_project = [ |
|||
path( |
|||
route='tags', |
|||
view=tag.TagList.as_view(), |
|||
name='tag_list' |
|||
), |
|||
path( |
|||
route='tags/<int:tag_id>', |
|||
view=tag.TagDetail.as_view(), |
|||
name='tag_detail' |
|||
), |
|||
] |
|||
from .views import task |
|||
|
|||
urlpatterns = [ |
|||
path( |
|||
route='projects', |
|||
view=project.ProjectList.as_view(), |
|||
name='project_list' |
|||
), |
|||
path( |
|||
route='tasks/status/<task_id>', |
|||
view=task.TaskStatus.as_view(), |
|||
name='task_status' |
|||
), |
|||
path( |
|||
route='projects/<int:project_id>', |
|||
view=project.ProjectDetail.as_view(), |
|||
name='project_detail' |
|||
), |
|||
path('projects/<int:project_id>/', include(urlpatterns_project)) |
|||
] |
@ -0,0 +1,26 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('projects', '0002_auto_20220204_0201'), |
|||
('auto_labeling', '0003_fill_task_type'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.AlterField( |
|||
model_name='autolabelingconfig', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, |
|||
related_name='auto_labeling_config', to='projects.project'), |
|||
), |
|||
], |
|||
database_operations=[] |
|||
) |
|||
] |
@ -0,0 +1,29 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('projects', '0002_auto_20220204_0201'), |
|||
('examples', '0001_initial'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.AlterField( |
|||
model_name='example', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='examples', |
|||
to='projects.project'), |
|||
), |
|||
], |
|||
database_operations=[ |
|||
|
|||
] |
|||
) |
|||
|
|||
] |
@ -0,0 +1,36 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('projects', '0002_auto_20220204_0201'), |
|||
('label_types', '0002_rename_relationtypes_relationtype'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.AlterField( |
|||
model_name='categorytype', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.project'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='relationtype', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relation_types', |
|||
to='projects.project'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='spantype', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.project'), |
|||
), |
|||
], |
|||
database_operations=[] |
|||
) |
|||
] |
@ -0,0 +1,26 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('projects', '0002_auto_20220204_0201'), |
|||
('labels', '0004_auto_20220128_0246'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.AlterField( |
|||
model_name='relation', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, |
|||
related_name='annotation_relations', to='projects.project'), |
|||
), |
|||
], |
|||
database_operations=[] |
|||
) |
|||
] |
@ -0,0 +1,155 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 02:01 |
|||
|
|||
from django.conf import settings |
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
|||
('contenttypes', '0002_remove_content_type_name'), |
|||
('projects', '0001_initial'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
state_operations=[ |
|||
migrations.CreateModel( |
|||
name='Project', |
|||
fields=[ |
|||
('id', |
|||
models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('name', models.CharField(max_length=100)), |
|||
('description', models.TextField(default='')), |
|||
('guideline', models.TextField(blank=True, default='')), |
|||
('created_at', models.DateTimeField(auto_now_add=True)), |
|||
('updated_at', models.DateTimeField(auto_now=True)), |
|||
('project_type', models.CharField( |
|||
choices=[('DocumentClassification', 'document classification'), |
|||
('SequenceLabeling', 'sequence labeling'), ('Seq2seq', 'sequence to sequence'), |
|||
('IntentDetectionAndSlotFilling', 'intent detection and slot filling'), |
|||
('Speech2text', 'speech to text'), |
|||
('ImageClassification', 'image classification')], max_length=30)), |
|||
('random_order', models.BooleanField(default=False)), |
|||
('collaborative_annotation', models.BooleanField(default=False)), |
|||
('single_class_classification', models.BooleanField(default=False)), |
|||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, |
|||
to=settings.AUTH_USER_MODEL)), |
|||
('polymorphic_ctype', |
|||
models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, |
|||
related_name='polymorphic_projects.project_set+', |
|||
to='contenttypes.contenttype')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
), |
|||
migrations.CreateModel( |
|||
name='ImageClassificationProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='IntentDetectionAndSlotFillingProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='Seq2seqProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='SequenceLabelingProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
('allow_overlapping', models.BooleanField(default=False)), |
|||
('grapheme_mode', models.BooleanField(default=False)), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='Speech2textProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='TextClassificationProject', |
|||
fields=[ |
|||
('project_ptr', |
|||
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, |
|||
parent_link=True, primary_key=True, serialize=False, |
|||
to='projects.project')), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
'base_manager_name': 'objects', |
|||
}, |
|||
bases=('projects.project',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='Tag', |
|||
fields=[ |
|||
('id', |
|||
models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('text', models.TextField()), |
|||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tags', |
|||
to='projects.project')), |
|||
], |
|||
), |
|||
migrations.AlterField( |
|||
model_name='member', |
|||
name='project', |
|||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='role_mappings', |
|||
to='projects.project'), |
|||
), |
|||
], |
|||
database_operations=[] |
|||
) |
|||
] |
@ -0,0 +1,49 @@ |
|||
# Generated by Django 3.2.11 on 2022-02-04 05:51 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('projects', '0002_auto_20220204_0201'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunSQL( |
|||
sql=""" |
|||
UPDATE |
|||
projects_project |
|||
SET |
|||
polymorphic_ctype_id = ( |
|||
SELECT |
|||
t2.id |
|||
from |
|||
django_content_type t1 |
|||
INNER JOIN django_content_type t2 ON t1.model = t2.model |
|||
WHERE |
|||
t1.app_label = 'api' |
|||
AND t2.app_label = 'projects' |
|||
AND t1.model LIKE '%project' |
|||
AND t1.id = projects_project.polymorphic_ctype_id |
|||
); |
|||
""", |
|||
reverse_sql=""" |
|||
UPDATE |
|||
projects_project |
|||
SET |
|||
polymorphic_ctype_id = ( |
|||
SELECT |
|||
t1.id |
|||
from |
|||
django_content_type t1 |
|||
INNER JOIN django_content_type t2 ON t1.model = t2.model |
|||
WHERE |
|||
t1.app_label = 'api' |
|||
AND t2.app_label = 'projects' |
|||
AND t1.model LIKE '%project' |
|||
AND t2.id = projects_project.polymorphic_ctype_id |
|||
); |
|||
""" |
|||
) |
|||
] |
@ -1,7 +1,7 @@ |
|||
from rest_framework import status |
|||
from rest_framework.reverse import reverse |
|||
|
|||
from .utils import CRUDMixin, create_default_roles, make_user, prepare_project |
|||
from api.tests.api.utils import CRUDMixin, create_default_roles, make_user, prepare_project |
|||
|
|||
|
|||
class TestProjectList(CRUDMixin): |
@ -1,7 +1,7 @@ |
|||
from rest_framework import status |
|||
from rest_framework.reverse import reverse |
|||
|
|||
from .utils import CRUDMixin, make_tag, make_user, prepare_project |
|||
from api.tests.api.utils import CRUDMixin, make_tag, make_user, prepare_project |
|||
|
|||
|
|||
class TestTagList(CRUDMixin): |
@ -1,15 +1,38 @@ |
|||
from django.urls import path |
|||
|
|||
from .views import MemberList, MemberDetail |
|||
from .views.member import MemberList, MemberDetail |
|||
from .views.tag import TagList, TagDetail |
|||
from .views.project import ProjectList, ProjectDetail |
|||
|
|||
|
|||
urlpatterns = [ |
|||
path( |
|||
route='members', |
|||
route='projects', |
|||
view=ProjectList.as_view(), |
|||
name='project_list' |
|||
), |
|||
path( |
|||
route='projects/<int:project_id>', |
|||
view=ProjectDetail.as_view(), |
|||
name='project_detail' |
|||
), |
|||
path( |
|||
route='projects/<int:project_id>/tags', |
|||
view=TagList.as_view(), |
|||
name='tag_list' |
|||
), |
|||
path( |
|||
route='projects/<int:project_id>/tags/<int:tag_id>', |
|||
view=TagDetail.as_view(), |
|||
name='tag_detail' |
|||
), |
|||
path( |
|||
route='projects/<int:project_id>/members', |
|||
view=MemberList.as_view(), |
|||
name='member_list' |
|||
), |
|||
path( |
|||
route='members/<int:member_id>', |
|||
route='projects/<int:project_id>/members/<int:member_id>', |
|||
view=MemberDetail.as_view(), |
|||
name='member_detail' |
|||
) |
|||
|
Write
Preview
Loading…
Cancel
Save