Update migration to assign circles to profiles
This commit is contained in:
parent
4d3ab9ce39
commit
1272037e73
|
|
@ -1,6 +1,10 @@
|
|||
import structlog
|
||||
|
||||
from vbv_lernwelt.course.consts import COURSE_VERSICHERUNGSVERMITTLERIN_ID
|
||||
from vbv_lernwelt.course.consts import (
|
||||
COURSE_VERSICHERUNGSVERMITTLERIN_FR_ID,
|
||||
COURSE_VERSICHERUNGSVERMITTLERIN_ID,
|
||||
COURSE_VERSICHERUNGSVERMITTLERIN_IT_ID,
|
||||
)
|
||||
from vbv_lernwelt.learnpath.consts import (
|
||||
COURSE_PROFILE_ALL_CODE,
|
||||
COURSE_PROFILE_ALL_ID,
|
||||
|
|
@ -35,18 +39,9 @@ def create_course_profiles():
|
|||
)
|
||||
|
||||
|
||||
def assign_circles_to_profiles():
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
def assign_circle_to_profile_curry(course_page):
|
||||
from vbv_lernwelt.learnpath.models import Circle, CourseProfile
|
||||
|
||||
try:
|
||||
course_page = CoursePage.objects.get(
|
||||
course_id=COURSE_VERSICHERUNGSVERMITTLERIN_ID
|
||||
)
|
||||
except CoursePage.DoesNotExist:
|
||||
logger.warning("Course does not exist yet")
|
||||
return
|
||||
|
||||
def assign_circle_to_profile(title, code):
|
||||
try:
|
||||
circle = Circle.objects.descendant_of(course_page).get(title=title)
|
||||
|
|
@ -56,6 +51,12 @@ def assign_circles_to_profiles():
|
|||
except Circle.DoesNotExist:
|
||||
logger.warning("assign_circle_to_profile: circle not found", title=title)
|
||||
|
||||
return assign_circle_to_profile
|
||||
|
||||
|
||||
def make_base_circle_curry(course_page):
|
||||
from vbv_lernwelt.learnpath.models import Circle
|
||||
|
||||
def make_base_circle(title):
|
||||
try:
|
||||
circle = Circle.objects.descendant_of(course_page).get(title=title)
|
||||
|
|
@ -64,6 +65,23 @@ def assign_circles_to_profiles():
|
|||
except Circle.DoesNotExist:
|
||||
logger.warning("assign_circle_to_profile: circle not found", title=title)
|
||||
|
||||
return make_base_circle
|
||||
|
||||
|
||||
def assign_de_circles_to_profiles():
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
|
||||
try:
|
||||
course_page = CoursePage.objects.get(
|
||||
course_id=COURSE_VERSICHERUNGSVERMITTLERIN_ID
|
||||
)
|
||||
except CoursePage.DoesNotExist:
|
||||
logger.warning("Course does not exist yet")
|
||||
return
|
||||
|
||||
assign_circle_to_profile = assign_circle_to_profile_curry(course_page)
|
||||
make_base_circle = make_base_circle_curry(course_page)
|
||||
|
||||
assign_circle_to_profile("Fahrzeug", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Haushalt", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Rechtsstreitigkeiten", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
|
|
@ -81,7 +99,90 @@ def assign_circles_to_profiles():
|
|||
|
||||
assign_circle_to_profile("Gesundheit", COURSE_PROFILE_KRANKENZUSATZ_CODE)
|
||||
|
||||
make_base_circle("Kickoff")
|
||||
make_base_circle("Basis")
|
||||
make_base_circle("Gewinnen")
|
||||
make_base_circle("Prüfungsvorbereitung")
|
||||
make_base_circle("Prüfung")
|
||||
|
||||
|
||||
def assign_fr_circles_to_profiles():
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
|
||||
try:
|
||||
course_page = CoursePage.objects.get(
|
||||
course_id=COURSE_VERSICHERUNGSVERMITTLERIN_FR_ID
|
||||
)
|
||||
except CoursePage.DoesNotExist:
|
||||
logger.warning("Course does not exist yet")
|
||||
return
|
||||
|
||||
assign_circle_to_profile = assign_circle_to_profile_curry(course_page)
|
||||
make_base_circle = make_base_circle_curry(course_page)
|
||||
|
||||
assign_circle_to_profile("Véhicule", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Ménage", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Litiges juridiques", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Voyages", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Propriété du logement", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Activité indépendante", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("PME", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
|
||||
assign_circle_to_profile("Garantie des revenus", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Retraite", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Hériter\xa0/\xa0léguer", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Épargne", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Activité indépendante", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("PME", COURSE_PROFILE_LEBEN_CODE)
|
||||
|
||||
assign_circle_to_profile("Santé", COURSE_PROFILE_KRANKENZUSATZ_CODE)
|
||||
|
||||
make_base_circle("Lancement")
|
||||
make_base_circle("Base")
|
||||
make_base_circle("Acquisition")
|
||||
make_base_circle("Préparation à l’examen")
|
||||
make_base_circle("L’examen")
|
||||
|
||||
|
||||
def assign_it_circles_to_profiles():
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
|
||||
try:
|
||||
course_page = CoursePage.objects.get(
|
||||
course_id=COURSE_VERSICHERUNGSVERMITTLERIN_IT_ID
|
||||
)
|
||||
except CoursePage.DoesNotExist:
|
||||
logger.warning("Course does not exist yet")
|
||||
return
|
||||
|
||||
assign_circle_to_profile = assign_circle_to_profile_curry(course_page)
|
||||
make_base_circle = make_base_circle_curry(course_page)
|
||||
|
||||
assign_circle_to_profile("Veicolo", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Economia domestica", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Controversie giuridiche", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Viaggi", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Casa di proprietà", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("Attività indipendente", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
assign_circle_to_profile("PMI", COURSE_PROFILE_NICHTLEBEN_CODE)
|
||||
|
||||
assign_circle_to_profile("Protezione del reddito", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Pensionamento", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Ereditare/lasciare in eredità", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Risparmio", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("Attività indipendente", COURSE_PROFILE_LEBEN_CODE)
|
||||
assign_circle_to_profile("PMI", COURSE_PROFILE_LEBEN_CODE)
|
||||
|
||||
assign_circle_to_profile("Salute", COURSE_PROFILE_KRANKENZUSATZ_CODE)
|
||||
|
||||
make_base_circle("Kickoff")
|
||||
make_base_circle("Base")
|
||||
make_base_circle("Acquisizione")
|
||||
make_base_circle("Preparazione all'esame")
|
||||
make_base_circle("Esame")
|
||||
|
||||
|
||||
def assign_circles_to_profiles():
|
||||
assign_de_circles_to_profiles()
|
||||
assign_fr_circles_to_profiles()
|
||||
assign_it_circles_to_profiles()
|
||||
|
|
|
|||
Loading…
Reference in New Issue