Source code for intranet.apps.schedule.serializers
import logging
from rest_framework import serializers
from .models import Block, Day, DayType, Time
logger = logging.getLogger(__name__)
[docs]class TimeSerializer(serializers.ModelSerializer):
[docs]class BlockSerializer(serializers.ModelSerializer):
start = serializers.StringRelatedField()
end = serializers.StringRelatedField()
[docs]class DayTypeSerializer(serializers.ModelSerializer):
# url = serializers.HyperlinkedIdentityField(view_name="api_eighth_activity_detail")
blocks = BlockSerializer(many=True, read_only=True)
[docs]class DaySerializer(serializers.HyperlinkedModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name="api_schedule_day_detail", lookup_field="date")
day_type = DayTypeSerializer(read_only=True)