import structlog from vbv_lernwelt.course.consts import COURSE_VERSICHERUNGSVERMITTLERIN_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 CourseProfile.objects.get_or_create( id=COURSE_PROFILE_LEBEN_ID, code=COURSE_PROFILE_LEBEN_CODE ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_NICHTLEBEN_ID, code=COURSE_PROFILE_NICHTLEBEN_CODE ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_KRANKENZUSATZ_ID, code=COURSE_PROFILE_KRANKENZUSATZ_CODE ) CourseProfile.objects.get_or_create( id=COURSE_PROFILE_ALL_ID, code=COURSE_PROFILE_ALL_CODE ) def assign_circles_to_profiles(): from vbv_lernwelt.course.models import CoursePage 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) 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) 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) 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("Selbständigkeit", COURSE_PROFILE_NICHTLEBEN_CODE) 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("Selbständigkeit", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile("KMU", COURSE_PROFILE_LEBEN_CODE) assign_circle_to_profile("Gesundheit", COURSE_PROFILE_KRANKENZUSATZ_CODE) make_base_circle("Basis") make_base_circle("Gewinnen") make_base_circle("Prüfungsvorbereitung") make_base_circle("Prüfung")