import structlog 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, COURSE_PROFILE_KRANKENZUSATZ_CODE, COURSE_PROFILE_KRANKENZUSATZ_ID, COURSE_PROFILE_LEBEN_CODE, COURSE_PROFILE_LEBEN_ID, COURSE_PROFILE_NICHTLEBEN_CODE, COURSE_PROFILE_NICHTLEBEN_ID, ) logger = structlog.get_logger(__name__) def create_course_profiles(): from vbv_lernwelt.learnpath.models import CourseProfile # Allbranche, Krankenzusatzversicherung, nicht Leben, Leben CourseProfile.objects.get_or_create( id=COURSE_PROFILE_ALL_ID, code=COURSE_PROFILE_ALL_CODE, order=1 ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_KRANKENZUSATZ_ID, code=COURSE_PROFILE_KRANKENZUSATZ_CODE, order=2, ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_NICHTLEBEN_ID, code=COURSE_PROFILE_NICHTLEBEN_CODE, order=3 ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_LEBEN_ID, code=COURSE_PROFILE_LEBEN_CODE, order=4 ) def assign_circle_to_profile_curry(course_page): from vbv_lernwelt.learnpath.models import Circle, CourseProfile def assign_circle_to_profile(title, code): try: circle = Circle.objects.descendant_of(course_page).get(title=title) course_profile = CourseProfile.objects.get(code=code) circle.profiles.add(course_profile) circle.save() 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) circle.is_base_circle = True circle.save() 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) assign_circle_to_profile("Reisen", COURSE_PROFILE_NICHTLEBEN_CODE) assign_circle_to_profile("Wohneigentum", COURSE_PROFILE_NICHTLEBEN_CODE) assign_circle_to_profile( "Selbstständigkeit", COURSE_PROFILE_NICHTLEBEN_CODE ) # typo, but that's how it is in prod data assign_circle_to_profile("KMU", COURSE_PROFILE_NICHTLEBEN_CODE) assign_circle_to_profile("Einkommenssicherung", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile("Pensionierung", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile("Erben/Vererben", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile("Sparen", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile( "Selbstständigkeit", COURSE_PROFILE_LEBEN_CODE ) # typo, but that's how it is in prod data assign_circle_to_profile("KMU", COURSE_PROFILE_LEBEN_CODE) 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()