diff --git a/program/services.py b/program/services.py index b5c504befc494e76419bd98cd9d43f19231255fb..1e2abd0bbfa411cdac05c699e499786ef282b619 100644 --- a/program/services.py +++ b/program/services.py @@ -782,13 +782,13 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: def make_schedule_entry(*, timeslot_entry: TimeslotEntry) -> ScheduleEntry: """returns a schedule entry for the given timeslot entry.""" - return { - "end": timeslot_entry["end"], - "show_id": timeslot_entry["show_id"], - "is_virtual": timeslot_entry["is_virtual"], - "start": timeslot_entry["start"], - "show_name": timeslot_entry["show_name"], - } + return ScheduleEntry( + end=timeslot_entry["end"], + show_id=timeslot_entry["show_id"], + is_virtual=timeslot_entry["is_virtual"], + start=timeslot_entry["start"], + show_name=timeslot_entry["show_name"], + ) def make_timeslot_entry(*, timeslot: TimeSlot) -> TimeslotEntry: @@ -797,33 +797,33 @@ def make_timeslot_entry(*, timeslot: TimeSlot) -> TimeslotEntry: schedule = timeslot.schedule show = timeslot.schedule.show - return { - "end": timeslot.end.strftime("%Y-%m-%dT%H:%M:%S%z"), - "is_virtual": False, - "playlist_id": timeslot.playlist_id, + return TimeslotEntry( + end=timeslot.end.strftime("%Y-%m-%dT%H:%M:%S%z"), + is_virtual=False, + playlist_id=timeslot.playlist_id, # 'timeslot.repetition_of` is a foreign key that can be null - "repetition_of_id": timeslot.repetition_of.id if timeslot.repetition_of else None, - "schedule_default_playlist_id": schedule.default_playlist_id, - "schedule_id": schedule.id, - "show_default_playlist_id": show.default_playlist_id, - "show_id": show.id, - "show_name": show.name, - "start": timeslot.start.strftime("%Y-%m-%dT%H:%M:%S%z"), - "timeslot_id": timeslot.id, - } + repetition_of_id=timeslot.repetition_of.id if timeslot.repetition_of else None, + schedule_default_playlist_id=schedule.default_playlist_id, + schedule_id=schedule.id, + show_default_playlist_id=show.default_playlist_id, + show_id=show.id, + show_name=show.name, + start=timeslot.start.strftime("%Y-%m-%dT%H:%M:%S%z"), + timeslot_id=timeslot.id, + ) def make_virtual_timeslot_entry(*, gap_start: datetime, gap_end: datetime) -> VirtualTimeslotEntry: """returns a virtual timeslot entry to fill the gap in between `gap_start` and `gap_end`.""" if radio_settings := RadioSettings.objects.first(): - return { - "end": gap_end.strftime("%Y-%m-%dT%H:%M:%S%z"), - "is_virtual": True, - "show_id": radio_settings.fallback_show.id, - "show_name": radio_settings.fallback_default_pool, - "start": gap_start.strftime("%Y-%m-%dT%H:%M:%S%z"), - } + return VirtualTimeslotEntry( + end=gap_end.strftime("%Y-%m-%dT%H:%M:%S%z"), + is_virtual=True, + show_id=radio_settings.fallback_show.id, + show_name=radio_settings.fallback_default_pool, + start=gap_start.strftime("%Y-%m-%dT%H:%M:%S%z"), + ) else: raise NotFound( detail=_("Radio settings with fallbacks not found."), code="radio_settings-not_found"