from rest_framework import serializers from vbv_lernwelt.competence.models import PerformanceCriteria from vbv_lernwelt.learnpath.models import LearningUnit from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class class PerformanceCriteriaSerializer(get_it_serializer_class(PerformanceCriteria, [ 'id', 'title', 'slug', 'type', 'translation_key', 'pc_id', 'learning_unit', 'circle', ])): learning_unit = serializers.SerializerMethodField() circle = serializers.SerializerMethodField() def get_learning_unit(self, obj): learning_unit_serializer = get_it_serializer_class(LearningUnit, [ 'id', 'title', 'slug', 'type', 'translation_key', ]) return learning_unit_serializer(obj.learning_unit).data def get_circle(self, obj): return obj.learning_unit.get_parent().specific.title class PerformanceCriteriaLearningPathSerializer(get_it_serializer_class(PerformanceCriteria, [ 'id', 'title', 'slug', 'type', 'translation_key', 'pc_id', ])): pass