Add 'all' CourseProfile to database

This commit is contained in:
Ramon Wenger 2024-07-18 15:39:06 +02:00 committed by Christian Cueni
parent 6ea37447f4
commit 0bcafab8a8
3 changed files with 9 additions and 1 deletions

View File

@ -30,6 +30,7 @@ from vbv_lernwelt.course_session.models import (
) )
from vbv_lernwelt.course_session_group.models import CourseSessionGroup from vbv_lernwelt.course_session_group.models import CourseSessionGroup
from vbv_lernwelt.iam.permissions import has_course_access 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.graphql.types import LearningPathObjectType
from vbv_lernwelt.learnpath.models import Circle, CourseProfile from vbv_lernwelt.learnpath.models import Circle, CourseProfile
@ -135,7 +136,9 @@ class CourseObjectType(DjangoObjectType):
@staticmethod @staticmethod
def resolve_profiles(root: Course, info, **kwargs): def resolve_profiles(root: Course, info, **kwargs):
if root.configuration.is_vv: 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 [] return []
@staticmethod @staticmethod

View File

@ -1,7 +1,9 @@
COURSE_PROFILE_LEBEN_ID = -1 COURSE_PROFILE_LEBEN_ID = -1
COURSE_PROFILE_NICHTLEBEN_ID = -2 COURSE_PROFILE_NICHTLEBEN_ID = -2
COURSE_PROFILE_KRANKENZUSATZ_ID = -3 COURSE_PROFILE_KRANKENZUSATZ_ID = -3
COURSE_PROFILE_ALL_ID = -99
COURSE_PROFILE_LEBEN_CODE = "leben" COURSE_PROFILE_LEBEN_CODE = "leben"
COURSE_PROFILE_NICHTLEBEN_CODE = "nichtleben" COURSE_PROFILE_NICHTLEBEN_CODE = "nichtleben"
COURSE_PROFILE_KRANKENZUSATZ_CODE = "krankenzusatzversicherung" COURSE_PROFILE_KRANKENZUSATZ_CODE = "krankenzusatzversicherung"
COURSE_PROFILE_ALL_CODE = "all"

View File

@ -2,6 +2,8 @@ import structlog
from vbv_lernwelt.course.consts import COURSE_VERSICHERUNGSVERMITTLERIN_ID from vbv_lernwelt.course.consts import COURSE_VERSICHERUNGSVERMITTLERIN_ID
from vbv_lernwelt.learnpath.consts import ( from vbv_lernwelt.learnpath.consts import (
COURSE_PROFILE_ALL_CODE,
COURSE_PROFILE_ALL_ID,
COURSE_PROFILE_KRANKENZUSATZ_CODE, COURSE_PROFILE_KRANKENZUSATZ_CODE,
COURSE_PROFILE_KRANKENZUSATZ_ID, COURSE_PROFILE_KRANKENZUSATZ_ID,
COURSE_PROFILE_LEBEN_CODE, COURSE_PROFILE_LEBEN_CODE,
@ -25,6 +27,7 @@ def create_course_profiles():
CourseProfile.objects.create( CourseProfile.objects.create(
id=COURSE_PROFILE_KRANKENZUSATZ_ID, code=COURSE_PROFILE_KRANKENZUSATZ_CODE 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(): def assign_circles_to_profiles():