Skip to content
Snippets Groups Projects
Verified Commit ed684a83 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

refactor: reuse the existing Timesolt serializer, exclude the memo field

parent 5b236257
No related branches found
No related tags found
1 merge request!52new program endpoint
Pipeline #8327 passed
......@@ -1389,32 +1389,9 @@ class CalendarSchemaSerializer(serializers.Serializer):
def link_types(self):
return LinkType.objects.all()
class CalendarTimeslotSerializer(serializers.ModelSerializer):
note_id = serializers.SerializerMethodField()
show_id = serializers.SerializerMethodField()
schedule_id = serializers.PrimaryKeyRelatedField(
queryset=Schedule.objects.all(),
required=False,
source="schedule",
)
repetition_of_id = serializers.PrimaryKeyRelatedField(
allow_null=True,
queryset=TimeSlot.objects.all(),
required=False,
source="repetition_of",
)
class Meta:
exclude = ("memo", "schedule", "repetition_of")
model = TimeSlot
@staticmethod
def get_show_id(obj) -> int:
return obj.schedule.show.id
@staticmethod
def get_note_id(obj) -> int:
return obj.note.id
class CalendarTimeslotSerializer(TimeSlotSerializer):
class Meta(TimeSlotSerializer.Meta):
fields = [f for f in TimeSlotSerializer.Meta.fields if f != "memo"]
shows = ShowSerializer(many=True)
timeslots = CalendarTimeslotSerializer(many=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment