From 0bcafab8a8c36fd2b8b1fd0f4e759dd75548d871 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Thu, 18 Jul 2024 15:39:06 +0200 Subject: [PATCH] Add 'all' CourseProfile to database --- server/vbv_lernwelt/course/graphql/types.py | 5 ++++- server/vbv_lernwelt/learnpath/consts.py | 2 ++ server/vbv_lernwelt/learnpath/creators.py | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/vbv_lernwelt/course/graphql/types.py b/server/vbv_lernwelt/course/graphql/types.py index 260796a0..cbec6854 100644 --- a/server/vbv_lernwelt/course/graphql/types.py +++ b/server/vbv_lernwelt/course/graphql/types.py @@ -30,6 +30,7 @@ from vbv_lernwelt.course_session.models import ( ) from vbv_lernwelt.course_session_group.models import CourseSessionGroup from vbv_lernwelt.iam.permissions import has_course_access +from vbv_lernwelt.learnpath.consts import COURSE_PROFILE_ALL_ID from vbv_lernwelt.learnpath.graphql.types import LearningPathObjectType from vbv_lernwelt.learnpath.models import Circle, CourseProfile @@ -135,7 +136,9 @@ class CourseObjectType(DjangoObjectType): @staticmethod def resolve_profiles(root: Course, info, **kwargs): if root.configuration.is_vv: - return CourseProfile.objects.all().values_list("code", flat=True) + return CourseProfile.objects.exclude(id=COURSE_PROFILE_ALL_ID).values_list( + "code", flat=True + ) return [] @staticmethod diff --git a/server/vbv_lernwelt/learnpath/consts.py b/server/vbv_lernwelt/learnpath/consts.py index 55b22d70..f9c71875 100644 --- a/server/vbv_lernwelt/learnpath/consts.py +++ b/server/vbv_lernwelt/learnpath/consts.py @@ -1,7 +1,9 @@ COURSE_PROFILE_LEBEN_ID = -1 COURSE_PROFILE_NICHTLEBEN_ID = -2 COURSE_PROFILE_KRANKENZUSATZ_ID = -3 +COURSE_PROFILE_ALL_ID = -99 COURSE_PROFILE_LEBEN_CODE = "leben" COURSE_PROFILE_NICHTLEBEN_CODE = "nichtleben" COURSE_PROFILE_KRANKENZUSATZ_CODE = "krankenzusatzversicherung" +COURSE_PROFILE_ALL_CODE = "all" diff --git a/server/vbv_lernwelt/learnpath/creators.py b/server/vbv_lernwelt/learnpath/creators.py index 202a2a46..b32c4dbe 100644 --- a/server/vbv_lernwelt/learnpath/creators.py +++ b/server/vbv_lernwelt/learnpath/creators.py @@ -2,6 +2,8 @@ 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, @@ -25,6 +27,7 @@ def create_course_profiles(): CourseProfile.objects.create( id=COURSE_PROFILE_KRANKENZUSATZ_ID, code=COURSE_PROFILE_KRANKENZUSATZ_CODE ) + CourseProfile.objects.create(id=COURSE_PROFILE_ALL_ID, code=COURSE_PROFILE_ALL_CODE) def assign_circles_to_profiles():