Add circles to competence api json
This commit is contained in:
parent
be68854545
commit
cf873e6f23
|
|
@ -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",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue