You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
662 B
27 lines
662 B
from rest_framework import serializers
|
|
|
|
from maps.models import CourseRoute, CourseMap
|
|
|
|
|
|
class CourseRouteSerializer(serializers.ModelSerializer):
|
|
maps = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = CourseRoute
|
|
fields = '__all__'
|
|
|
|
@staticmethod
|
|
def get_maps(self):
|
|
return [CourseMapSerializer(i).data for i in self.get_maps()]
|
|
|
|
|
|
class CourseMapSerializer(serializers.ModelSerializer):
|
|
vertexes = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = CourseMap
|
|
fields = '__all__'
|
|
|
|
@staticmethod
|
|
def get_vertexes(self):
|
|
return [i.id for i in self.pivotvertex_set.all()] |