67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
# Generated by Django 3.2.20 on 2024-04-03 09:32
|
|
|
|
from django.db import migrations, models
|
|
|
|
TEST_COURSE_ID = -1
|
|
|
|
UK_COURSE_IDS = [
|
|
-3, # uk-de
|
|
-6, # uk-training-de
|
|
-5, # uk-fr
|
|
-7, # uk-training-fr
|
|
-8, # uk-it
|
|
-9, # uk-training-it
|
|
]
|
|
|
|
|
|
VV_COURSE_IDS = [
|
|
-4, # vv-de
|
|
-10, # vv-fr
|
|
-11, # vv-it
|
|
-12, # vv-prüfung
|
|
]
|
|
|
|
|
|
def forward_migration(apps, schema_editor):
|
|
Course = apps.get_model("course", "Course")
|
|
CourseConfiguration = apps.get_model("course", "CourseConfiguration")
|
|
|
|
for course in Course.objects.all():
|
|
config, created = CourseConfiguration.objects.get_or_create(
|
|
course=course,
|
|
)
|
|
|
|
# -> disable unnecessary features
|
|
if course.id in UK_COURSE_IDS:
|
|
config.is_uk = True
|
|
elif course.id in VV_COURSE_IDS:
|
|
config.is_vv = True
|
|
|
|
config.save()
|
|
|
|
|
|
def backward_migration(apps, schema_editor):
|
|
pass
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("course", "0007_auto_20240226_1553"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="courseconfiguration",
|
|
name="is_uk",
|
|
field=models.BooleanField(default=False, verbose_name="ÜK-Lehrgang"),
|
|
),
|
|
migrations.AddField(
|
|
model_name="courseconfiguration",
|
|
name="is_vv",
|
|
field=models.BooleanField(
|
|
default=False, verbose_name="Versicherungsvermittler-Lehrgang"
|
|
),
|
|
),
|
|
migrations.RunPython(forward_migration, backward_migration),
|
|
]
|