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

fix: raise an exception if Radio Settings are not found

parent 3c3ad802
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ from typing import Literal, TypedDict
from dateutil.relativedelta import relativedelta
from dateutil.rrule import rrule
from rest_framework.exceptions import ValidationError
from rest_framework.exceptions import NotFound, ValidationError
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
......@@ -816,13 +816,16 @@ def make_timeslot_entry(*, timeslot: TimeSlot) -> TimeslotEntry:
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`."""
return {
"end": gap_end.strftime("%Y-%m-%dT%H:%M:%S %z"),
"is_virtual": True,
"show_id": RadioSettings.objects.first().fallback_show.id,
"show_name": RadioSettings.objects.first().fallback_default_pool,
"start": gap_start.strftime("%Y-%m-%dT%H:%M:%S %z"),
}
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"),
}
else:
raise NotFound("Radio settings with fallbacks not found.")
def get_timerange_timeslot_entries(
......
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