Return CourseProfiles depending on the course configuration
This commit is contained in:
parent
fc27d000ab
commit
6da8907816
|
|
@ -134,7 +134,9 @@ class CourseObjectType(DjangoObjectType):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_profiles(root: Course, info, **kwargs):
|
def resolve_profiles(root: Course, info, **kwargs):
|
||||||
return CourseProfile.objects.all().values_list("code", flat=True)
|
if root.configuration.is_vv:
|
||||||
|
return CourseProfile.objects.all().values_list("code", flat=True)
|
||||||
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_course_session_users(root: Course, info, id=None, **kwargs):
|
def resolve_course_session_users(root: Course, info, id=None, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from vbv_lernwelt.course.models import (
|
||||||
CourseSession,
|
CourseSession,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.iam.permissions import course_session_permissions
|
from vbv_lernwelt.iam.permissions import course_session_permissions
|
||||||
|
from vbv_lernwelt.learnpath.models import CourseProfile
|
||||||
|
|
||||||
|
|
||||||
class CourseConfigurationSerializer(serializers.ModelSerializer):
|
class CourseConfigurationSerializer(serializers.ModelSerializer):
|
||||||
|
|
@ -31,10 +32,23 @@ class CourseSerializer(serializers.ModelSerializer):
|
||||||
configuration = CourseConfigurationSerializer(
|
configuration = CourseConfigurationSerializer(
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
course_profiles = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_course_profiles(self, obj):
|
||||||
|
if obj.configuration.is_vv:
|
||||||
|
return CourseProfile.objects.all().values_list("code", flat=True)
|
||||||
|
return []
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Course
|
model = Course
|
||||||
fields = ["id", "title", "category_name", "slug", "configuration"]
|
fields = [
|
||||||
|
"id",
|
||||||
|
"title",
|
||||||
|
"category_name",
|
||||||
|
"slug",
|
||||||
|
"configuration",
|
||||||
|
"course_profiles",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class CourseCategorySerializer(serializers.ModelSerializer):
|
class CourseCategorySerializer(serializers.ModelSerializer):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue