mirror of https://github.com/doccano/doccano.git
Hironsan
2 years ago
11 changed files with 59 additions and 112 deletions
Split View
Diff Options
-
36backend/api/migrations/0020_auto_20211220_2327.py
-
18backend/api/migrations/0020_label_task_type.py
-
36backend/api/migrations/0021_auto_20211209_0644.py
-
21backend/api/migrations/0022_auto_20211210_0052.py
-
19backend/api/models.py
-
1backend/api/serializers.py
-
9backend/api/tests/api/test_label.py
-
10backend/api/tests/test_models.py
-
1backend/api/views/label.py
-
18backend/api/views/upload/label.py
-
2backend/api/views/upload/writers.py
@ -0,0 +1,36 @@ |
|||
# Generated by Django 3.2.8 on 2021-12-20 23:27 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0019_auto_20211124_0506'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='DocType', |
|||
fields=[ |
|||
('label_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.label')), |
|||
], |
|||
bases=('api.label',), |
|||
), |
|||
migrations.CreateModel( |
|||
name='SpanType', |
|||
fields=[ |
|||
('label_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.label')), |
|||
], |
|||
bases=('api.label',), |
|||
), |
|||
migrations.AlterUniqueTogether( |
|||
name='label', |
|||
unique_together=set(), |
|||
), |
|||
migrations.AddConstraint( |
|||
model_name='label', |
|||
constraint=models.UniqueConstraint(fields=('project', 'text'), name='unique_label'), |
|||
), |
|||
] |
@ -1,18 +0,0 @@ |
|||
# Generated by Django 3.2.8 on 2021-12-09 06:38 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0019_auto_20211124_0506'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='label', |
|||
name='task_type', |
|||
field=models.CharField(choices=[('Category', 'Category'), ('Span', 'Span'), ('Relation', 'Relation')], default='Category', max_length=30), |
|||
), |
|||
] |
@ -1,36 +0,0 @@ |
|||
from django.db import migrations |
|||
|
|||
|
|||
def update_label_type(apps, schema_editor): |
|||
Label = apps.get_model('api', 'Label') |
|||
for label in Label.objects.all(): |
|||
project_type = label.project.project_type |
|||
if project_type.endswith('Classification'): |
|||
label.task_type = 'Category' |
|||
else: |
|||
label.task_type = 'Span' |
|||
label.save() |
|||
|
|||
|
|||
# def move_relation_type_to_label(apps, schema_editor): |
|||
# Label = apps.get_model('api', 'Label') |
|||
# RelationTypes = apps.get_model('api', 'RelationTypes') |
|||
# for relation_type in RelationTypes.objects.all(): |
|||
# Label.objects.create( |
|||
# text=relation_type.name, |
|||
# project=relation_type.project, |
|||
# background_color=relation_type.color, |
|||
# task_type='Relation' |
|||
# ) |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0020_label_task_type'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(update_label_type), |
|||
# migrations.RunPython(move_relation_type_to_label), |
|||
] |
@ -1,21 +0,0 @@ |
|||
# Generated by Django 3.2.8 on 2021-12-10 00:52 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0021_auto_20211209_0644'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterUniqueTogether( |
|||
name='label', |
|||
unique_together=set(), |
|||
), |
|||
migrations.AddConstraint( |
|||
model_name='label', |
|||
constraint=models.UniqueConstraint(fields=('project', 'text', 'task_type'), name='unique_label'), |
|||
), |
|||
] |
Write
Preview
Loading…
Cancel
Save