Browse Source

Add updated_at and created_at fields to models

For managing data life cycle
pull/110/head
Hironsan 5 years ago
parent
commit
6b8f2a7627
2 changed files with 156 additions and 0 deletions
  1. 150
      app/server/migrations/0004_created_at.py
  2. 6
      app/server/models.py

150
app/server/migrations/0004_created_at.py

@ -0,0 +1,150 @@
# Generated by Django 2.1.5 on 2019-02-25 01:38
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('server', '0003_shortcut'),
]
operations = [
migrations.CreateModel(
name='Seq2seqDocument',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.document',),
),
migrations.CreateModel(
name='Seq2seqProject',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.project',),
),
migrations.CreateModel(
name='SequenceLabelingDocument',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.document',),
),
migrations.CreateModel(
name='SequenceLabelingProject',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.project',),
),
migrations.CreateModel(
name='TextClassificationDocument',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.document',),
),
migrations.CreateModel(
name='TextClassificationProject',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('server.project',),
),
migrations.AddField(
model_name='document',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='document',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='documentannotation',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='documentannotation',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='label',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='label',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='seq2seqannotation',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='seq2seqannotation',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='sequenceannotation',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='sequenceannotation',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='documentannotation',
name='document',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='doc_annotations', to='server.TextClassificationDocument'),
),
migrations.AlterField(
model_name='project',
name='description',
field=models.TextField(),
),
migrations.AlterField(
model_name='seq2seqannotation',
name='document',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seq2seq_annotations', to='server.Seq2seqDocument'),
),
migrations.AlterField(
model_name='sequenceannotation',
name='document',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seq_annotations', to='server.SequenceLabelingDocument'),
),
]

6
app/server/models.py

@ -117,6 +117,8 @@ class Label(models.Model):
project = models.ForeignKey(Project, related_name='labels', on_delete=models.CASCADE)
background_color = models.CharField(max_length=7, default='#209cee')
text_color = models.CharField(max_length=7, default='#ffffff')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.text
@ -132,6 +134,8 @@ class Document(models.Model):
text = models.TextField()
project = models.ForeignKey(Project, related_name='documents', on_delete=models.CASCADE)
metadata = models.TextField(default='{}')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.text[:50]
@ -168,6 +172,8 @@ class Annotation(models.Model):
prob = models.FloatField(default=0.0)
manual = models.BooleanField(default=False)
user = models.ForeignKey(User, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
abstract = True

Loading…
Cancel
Save