vbv/server/vbv_lernwelt/learnpath/serializers.py

15 lines
573 B
Python

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
class LearningUnitSerializer(get_it_serializer_class(LearningUnit, [
'id', 'title', 'slug', 'type', 'translation_key',
'course_category', 'children',
])):
def get_children(self, obj):
return [
PerformanceCriteriaLearningPathSerializer(child).data
for child in obj.performancecriteria_set.all()
]