Browse Source

Add task_type field to AutoLabelingConfig

pull/1650/head
Hironsan 2 years ago
parent
commit
ee3e38e9cb
3 changed files with 42 additions and 0 deletions
  1. 18
      backend/auto_labeling/migrations/0002_autolabelingconfig_task_type.py
  2. 23
      backend/auto_labeling/migrations/0003_fill_task_type.py
  3. 1
      backend/auto_labeling/models.py

18
backend/auto_labeling/migrations/0002_autolabelingconfig_task_type.py

@ -0,0 +1,18 @@
# Generated by Django 3.2.11 on 2022-01-24 07:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('auto_labeling', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='autolabelingconfig',
name='task_type',
field=models.CharField(default='', max_length=100),
),
]

23
backend/auto_labeling/migrations/0003_fill_task_type.py

@ -0,0 +1,23 @@
from django.db import migrations
def fill_task_type(apps, schema_editor):
AutoLabelingConfig = apps.get_model('auto_labeling', 'AutoLabelingConfig')
for config in AutoLabelingConfig.objects.all():
project = config.project
config.task_type = project.project_type
config.save()
class Migration(migrations.Migration):
dependencies = [
('auto_labeling', '0002_autolabelingconfig_task_type'),
]
operations = [
migrations.RunPython(
code=fill_task_type,
reverse_code=migrations.RunPython.noop
)
]

1
backend/auto_labeling/models.py

@ -15,6 +15,7 @@ class AutoLabelingConfig(models.Model):
on_delete=models.CASCADE,
related_name='auto_labeling_config'
)
task_type = models.CharField(max_length=100, default='')
default = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Loading…
Cancel
Save