mirror of
https://github.com/lemeow125/InfoTech-Backend.git
synced 2024-11-17 06:29:26 +08:00
20 lines
677 B
Python
20 lines
677 B
Python
from rest_framework import serializers
|
|
from django.contrib.auth.models import User
|
|
from .models import TimeSlot, TimeSchedule
|
|
|
|
|
|
class TimeSlotSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = TimeSlot
|
|
fields = ('id', 'name', 'time_start', 'time_end')
|
|
read_only_fields = ['id', 'name']
|
|
|
|
|
|
class TimeScheduleSerializer(serializers.HyperlinkedModelSerializer):
|
|
time_window = serializers.SlugRelatedField(
|
|
queryset=TimeSlot.objects.all(), slug_field='name')
|
|
|
|
class Meta:
|
|
model = TimeSchedule
|
|
fields = ('id', 'name', 'day', 'time_window')
|
|
read_only_fields = ['id', 'name']
|