diff --git a/server/vbv_lernwelt/competence/models.py b/server/vbv_lernwelt/competence/models.py index ce1b4162..f9779974 100644 --- a/server/vbv_lernwelt/competence/models.py +++ b/server/vbv_lernwelt/competence/models.py @@ -6,7 +6,7 @@ from wagtail.fields import StreamField from wagtail.models import Page from vbv_lernwelt.core.model_utils import find_available_slug -from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class +from vbv_lernwelt.core.serializer_helpers import get_it_serializer_class class CompetenceProfilePage(Page): @@ -32,6 +32,7 @@ class CompetenceProfilePage(Page): cls, [ "course", + "circles", "children", ], ) diff --git a/server/vbv_lernwelt/competence/serializers.py b/server/vbv_lernwelt/competence/serializers.py index 3b4d96ef..062009bf 100644 --- a/server/vbv_lernwelt/competence/serializers.py +++ b/server/vbv_lernwelt/competence/serializers.py @@ -1,8 +1,8 @@ from rest_framework import serializers from vbv_lernwelt.competence.models import PerformanceCriteria +from vbv_lernwelt.core.serializer_helpers import get_it_serializer_class from vbv_lernwelt.course.serializers import CourseCategorySerializer -from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class class PerformanceCriteriaSerializer( @@ -33,7 +33,8 @@ class PerformanceCriteriaSerializer( return LearningUnitPerformanceCriteriaSerializer(obj.learning_unit).data def get_circle(self, obj): - return obj.learning_unit.get_parent().specific.title + c = obj.learning_unit.get_parent() + return {"id": c.id, "title": c.title, "translation_key": c.translation_key} def get_course_category(self, obj): if obj.learning_unit: diff --git a/server/vbv_lernwelt/learnpath/serializer_helpers.py b/server/vbv_lernwelt/core/serializer_helpers.py similarity index 77% rename from server/vbv_lernwelt/learnpath/serializer_helpers.py rename to server/vbv_lernwelt/core/serializer_helpers.py index 57c385f8..72b5f031 100644 --- a/server/vbv_lernwelt/learnpath/serializer_helpers.py +++ b/server/vbv_lernwelt/core/serializer_helpers.py @@ -35,6 +35,7 @@ class ItBaseSerializer(wagtail_serializers.BaseSerializer): course = SerializerMethodField() course_category = CourseCategorySerializer(read_only=True) frontend_url = SerializerMethodField() + circles = SerializerMethodField() meta_fields = [] @@ -62,6 +63,28 @@ class ItBaseSerializer(wagtail_serializers.BaseSerializer): return CourseSerializer(course_parent_page.specific.course).data return "" + def get_circles(self, obj): + course_parent_page = obj.get_ancestors().exact_type(CoursePage).last() + + if course_parent_page: + from vbv_lernwelt.learnpath.models import Circle + from vbv_lernwelt.learnpath.models import LearningPath + + circles = ( + course_parent_page.get_children() + .exact_type(LearningPath) + .first() + .get_children() + .exact_type(Circle) + ) + + return [ + {"id": c.id, "title": c.title, "translation_key": c.translation_key} + for c in circles + ] + + return [] + def get_frontend_url(self, obj): if hasattr(obj, "get_frontend_url"): return obj.get_frontend_url() diff --git a/server/vbv_lernwelt/learnpath/create_default_learning_path.py b/server/vbv_lernwelt/learnpath/create_default_learning_path.py index 21bcc00e..33b2dbaa 100644 --- a/server/vbv_lernwelt/learnpath/create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/create_default_learning_path.py @@ -564,7 +564,7 @@ def create_circle_abschluss(lp): def create_circle_betreuen(lp): circle = CircleFactory( - title="Abschluss", + title="Betreuen", parent=lp, ) LearningSequenceFactory(title="Starten", parent=circle, icon="it-icon-ls-start") diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index 4564451b..3844c901 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -8,6 +8,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.models import Page from vbv_lernwelt.core.model_utils import find_available_slug +from vbv_lernwelt.core.serializer_helpers import get_it_serializer_class from vbv_lernwelt.course.models import CoursePage from vbv_lernwelt.learnpath.models_learning_unit_content import ( AssignmentBlock, @@ -21,7 +22,6 @@ from vbv_lernwelt.learnpath.models_learning_unit_content import ( TestBlock, VideoBlock, ) -from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class class LearningPath(Page): diff --git a/server/vbv_lernwelt/learnpath/serializers.py b/server/vbv_lernwelt/learnpath/serializers.py index 8884663e..8843f161 100644 --- a/server/vbv_lernwelt/learnpath/serializers.py +++ b/server/vbv_lernwelt/learnpath/serializers.py @@ -4,7 +4,7 @@ from vbv_lernwelt.competence.serializers import ( PerformanceCriteriaLearningPathSerializer, ) from vbv_lernwelt.learnpath.models import LearningUnit -from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class +from vbv_lernwelt.core.serializer_helpers import get_it_serializer_class class LearningUnitSerializer( diff --git a/server/vbv_lernwelt/media_library/models.py b/server/vbv_lernwelt/media_library/models.py index 0a0a5f9c..642f08f4 100644 --- a/server/vbv_lernwelt/media_library/models.py +++ b/server/vbv_lernwelt/media_library/models.py @@ -7,7 +7,7 @@ from wagtail.fields import StreamField from wagtail.models import Page from vbv_lernwelt.core.model_utils import find_available_slug -from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class +from vbv_lernwelt.core.serializer_helpers import get_it_serializer_class from vbv_lernwelt.media_library.content_blocks import MediaContentCollection