Browse Source

#27642 models and migrations

pull/1384/head
descansodj@hotmail.it 3 years ago
parent
commit
f3b60ae493
2 changed files with 53 additions and 0 deletions
  1. 34
      app/api/migrations/0009_annotations_relations_20210421_1445.py
  2. 19
      app/api/models.py

34
app/api/migrations/0009_annotations_relations_20210421_1445.py

@ -0,0 +1,34 @@
# Generated by Django 3.1.6 on 2021-03-02 10:13
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('api', '0008_auto_20210302_1013'),
]
operations = [
migrations.CreateModel( # id_autogen, annotation_id_1, annotation_id_2, type, author, timestamp
name='RelationTypes',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.TextField(max_length=50)),
('color', models.TextField(max_length=20)),
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relation_types', to='api.Project'))
],
),
migrations.CreateModel( # id_autogen, annotation_id_1, annotation_id_2, type, author, timestamp
name='AnnotationRelations',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('annotation_id_1', models.IntegerField()),
('annotation_id_2', models.IntegerField()),
('type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.RelationTypes')),
('timestamp', models.DateTimeField(auto_now_add=True))
],
)
]

19
app/api/models.py

@ -265,6 +265,25 @@ class SequenceAnnotation(Annotation):
unique_together = ('document', 'user', 'label', 'start_offset', 'end_offset')
class AnnotationRelations:
user = models.ForeignKey(User, on_delete=models.CASCADE)
timestamp = models.DateTimeField(auto_now_add=True)
annotation_id_1 = models.IntegerField()
annotation_id_2 = models.IntegerField()
type = models.CharField(max_length=50)
class Meta:
unique_together = ('timestamp', 'user', 'annotation_id_1', 'annotation_id_2', 'type')
class RelationTypes:
color = models.TextField()
name = models.TextField()
class Meta:
unique_together = ('color', 'name')
class Seq2seqAnnotation(Annotation):
# Override AnnotationManager for custom functionality
objects = Seq2seqAnnotationManager()

Loading…
Cancel
Save