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

feat: allow the exclusion of inactive schedules in the REST API

This filter is currently applied programmatically in the dashboard. It
makes much more sense to do this on a database level.

refs dashboard#246
parent 2bf226d5
No related branches found
No related tags found
No related merge requests found
Pipeline #7224 passed
......@@ -170,6 +170,19 @@ class ScheduleFilterSet(filters.FilterSet):
field_name="show",
help_text="Return only schedules that belong to the specified show(s).",
)
exclude_inactive = filters.BooleanFilter(
method="filter_exclude_inactive",
help_text="Excludes all schedules that don’t have timeslots in the future.",
)
def filter_exclude_inactive(self, queryset: QuerySet, name: str, value: bool):
if not value:
return queryset
return queryset.filter(
Exists(
models.TimeSlot.objects.filter(schedule=OuterRef("pk"), end__gte=timezone.now())
)
)
class TimeSlotFilterSet(filters.FilterSet):
......
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