From 9713850afa491051df5fc1d89a882dc0d88a0a83 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Thu, 11 Jul 2024 15:30:07 +0200 Subject: [PATCH] Add data migration for course profiles --- server/vbv_lernwelt/learnpath/consts.py | 7 ++++++ server/vbv_lernwelt/learnpath/creators.py | 22 +++++++++++++++++++ .../migrations/0018_auto_20240711_1527.py | 17 ++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 server/vbv_lernwelt/learnpath/consts.py create mode 100644 server/vbv_lernwelt/learnpath/creators.py create mode 100644 server/vbv_lernwelt/learnpath/migrations/0018_auto_20240711_1527.py diff --git a/server/vbv_lernwelt/learnpath/consts.py b/server/vbv_lernwelt/learnpath/consts.py new file mode 100644 index 00000000..55b22d70 --- /dev/null +++ b/server/vbv_lernwelt/learnpath/consts.py @@ -0,0 +1,7 @@ +COURSE_PROFILE_LEBEN_ID = -1 +COURSE_PROFILE_NICHTLEBEN_ID = -2 +COURSE_PROFILE_KRANKENZUSATZ_ID = -3 + +COURSE_PROFILE_LEBEN_CODE = "leben" +COURSE_PROFILE_NICHTLEBEN_CODE = "nichtleben" +COURSE_PROFILE_KRANKENZUSATZ_CODE = "krankenzusatzversicherung" diff --git a/server/vbv_lernwelt/learnpath/creators.py b/server/vbv_lernwelt/learnpath/creators.py new file mode 100644 index 00000000..14dca7c3 --- /dev/null +++ b/server/vbv_lernwelt/learnpath/creators.py @@ -0,0 +1,22 @@ +from vbv_lernwelt.learnpath.consts import ( + COURSE_PROFILE_KRANKENZUSATZ_CODE, + COURSE_PROFILE_KRANKENZUSATZ_ID, + COURSE_PROFILE_LEBEN_CODE, + COURSE_PROFILE_LEBEN_ID, + COURSE_PROFILE_NICHTLEBEN_CODE, + COURSE_PROFILE_NICHTLEBEN_ID, +) + + +def create_course_profiles(): + from vbv_lernwelt.learnpath.models import CourseProfile + + CourseProfile.objects.create( + id=COURSE_PROFILE_LEBEN_ID, code=COURSE_PROFILE_LEBEN_CODE + ) + CourseProfile.objects.create( + id=COURSE_PROFILE_NICHTLEBEN_ID, code=COURSE_PROFILE_NICHTLEBEN_CODE + ) + CourseProfile.objects.create( + id=COURSE_PROFILE_KRANKENZUSATZ_ID, code=COURSE_PROFILE_KRANKENZUSATZ_CODE + ) diff --git a/server/vbv_lernwelt/learnpath/migrations/0018_auto_20240711_1527.py b/server/vbv_lernwelt/learnpath/migrations/0018_auto_20240711_1527.py new file mode 100644 index 00000000..d4cb42a1 --- /dev/null +++ b/server/vbv_lernwelt/learnpath/migrations/0018_auto_20240711_1527.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.20 on 2024-07-11 13:27 + +from django.db import migrations + +from vbv_lernwelt.learnpath.creators import create_course_profiles + + +def migrate(apps, schema_editor): + create_course_profiles() + + +class Migration(migrations.Migration): + dependencies = [ + ("learnpath", "0017_auto_20240711_1100"), + ] + + operations = [migrations.RunPython(migrate)]