Web M&M
https://mam.matfyz.cz
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.
89 lines
2.2 KiB
89 lines
2.2 KiB
from rest_framework import serializers
|
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
|
|
|
import seminar.models as m
|
|
|
|
DEFAULT_NODE_DEPTH = 2
|
|
|
|
class UlohaVzorakNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.UlohaVzorakNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class UlohaZadaniNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.UlohaZadaniNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class RocnikNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.RocnikNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class CisloNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.CisloNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class MezicisloNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.MezicisloNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class TemaVCisleNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.TemaVCisleNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class OrgTextNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.OrgTextNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class PohadkaNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.PohadkaNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class TextNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.TextNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class CastNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.CastNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
class ReseniNodeSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = m.ReseniNode
|
|
fields = '__all__'
|
|
depth = DEFAULT_NODE_DEPTH
|
|
|
|
|
|
class TreeNodeSerializer(PolymorphicSerializer):
|
|
model_serializer_mapping = {
|
|
m.RocnikNode: RocnikNodeSerializer,
|
|
m.CisloNode: CisloNodeSerializer,
|
|
m.MezicisloNode: MezicisloNodeSerializer,
|
|
m.TemaVCisleNode: TemaVCisleNodeSerializer,
|
|
m.OrgTextNode: OrgTextNodeSerializer,
|
|
m.UlohaZadaniNode: UlohaZadaniNodeSerializer,
|
|
m.UlohaVzorakNode: UlohaVzorakNodeSerializer,
|
|
m.PohadkaNode: PohadkaNodeSerializer,
|
|
m.TextNode: TextNodeSerializer,
|
|
m.CastNode: CastNodeSerializer,
|
|
m.ReseniNode: ReseniNodeSerializer,
|
|
|
|
}
|
|
|