40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from rest_framework import serializers
|
|
|
|
from vbv_lernwelt.learnpath.models import Circle, LearningPath
|
|
from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class
|
|
|
|
|
|
class CircleSerializer(get_it_serializer_class(Circle, [])):
|
|
children = serializers.SerializerMethodField()
|
|
|
|
meta_fields = []
|
|
|
|
def get_children(self, obj):
|
|
return [c.specific.get_serializer_class()(c.specific).data for c in obj.get_children()]
|
|
|
|
def get_meta_label(self, obj):
|
|
return obj._meta.label
|
|
|
|
class Meta:
|
|
model = Circle
|
|
fields = [
|
|
'id', 'title', 'slug', 'type', 'translation_key',
|
|
'children', 'description', 'job_situations', 'goals', 'experts',
|
|
]
|
|
|
|
|
|
class LearningPathSerializer(get_it_serializer_class(LearningPath, [])):
|
|
children = serializers.SerializerMethodField()
|
|
|
|
meta_fields = []
|
|
|
|
def get_children(self, obj):
|
|
return [c.specific.get_serializer_class()(c.specific).data for c in obj.get_children()]
|
|
|
|
def get_meta_label(self, obj):
|
|
return obj._meta.label
|
|
|
|
class Meta:
|
|
model = Circle
|
|
fields = ['id', 'title', 'slug', 'children', 'type']
|