Skip to content
Snippets Groups Projects
Commit 5725a345 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: move logic for finding the fallback show

parent 63107926
No related branches found
No related tags found
1 merge request!57Incorporate feedback for virtual timeslots
...@@ -700,6 +700,17 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -700,6 +700,17 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
return conflicts return conflicts
def get_fallback_show(raise_exceptions: bool = False):
radio_settings: RadioSettings | None = RadioSettings.objects.first()
fallback_show = radio_settings.fallback_show if radio_settings is not None else None
if raise_exceptions and fallback_show is None:
raise ConfigurationError(
"Radio settings must define a fallback show if include_virtual is True.",
code="no-fallback-show-defined",
)
return fallback_show
def generate_program_entries( def generate_program_entries(
queryset: QuerySet[TimeSlot], queryset: QuerySet[TimeSlot],
*, *,
...@@ -743,13 +754,9 @@ def generate_program_entries( ...@@ -743,13 +754,9 @@ def generate_program_entries(
yield from (create_timeslot_entry(timeslot) for timeslot in queryset) yield from (create_timeslot_entry(timeslot) for timeslot in queryset)
return return
radio_settings: RadioSettings | None = RadioSettings.objects.first() # Program entries that are not based on scheduled timeslots are generated using the fallback
fallback_show = radio_settings.fallback_show if radio_settings is not None else None # show. We can only create these program entries if a fallback show has been specified.
if fallback_show is None: fallback_show = get_fallback_show(raise_exceptions=True)
raise ConfigurationError(
"Radio settings must define a fallback show if include_virtual is True.",
code="no-fallback-show-defined",
)
entry_start = start entry_start = start
timeslot: TimeSlot timeslot: TimeSlot
......
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