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

Document new filters for Show viewset

parent 7e34a4c2
No related branches found
No related tags found
No related merge requests found
Pipeline #2509 passed
......@@ -55,6 +55,9 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
field_name="music_focus",
help_text="Return only shows with given music focus(es).",
)
music_focus__slug = filters.CharFilter(
field_name="music_focus", help_text="Return only shows with the give music focus slug."
)
owner = IntegerInFilter(
field_name="owners",
help_text="Return only shows that belong to the given owner(s).",
......@@ -62,15 +65,24 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
category = IntegerInFilter(
help_text="Return only shows of the given category or categories.",
)
category__slug = filters.CharFilter(
field_name="category", help_text="Return only shows of the given category slug."
)
language = IntegerInFilter(
help_text="Return only shows of the given language(s).",
)
topic = IntegerInFilter(
help_text="Return only shows of the given topic(s).",
)
topic__slug = filters.CharFilter(
field_name="topic", help_text="Return only shows of the given topic slug."
)
type = IntegerInFilter(
help_text="Return only shows of a given type.",
)
type__slug = filters.CharFilter(
field_name="type", help_text="Return only shows of the given type slug."
)
public = filters.BooleanFilter(
field_name="is_public",
help_text="Return only shows that are public/non-public.",
......@@ -154,9 +166,7 @@ class TimeSlotFilterSet(filters.FilterSet):
),
)
def filter_surrounding(
self, queryset: QuerySet, name: str, value: datetime.datetime
):
def filter_surrounding(self, queryset: QuerySet, name: str, value: datetime.datetime):
nearest_timeslots_in_future = (
models.TimeSlot.objects.filter(start__gte=value)
.order_by("start")
......@@ -167,9 +177,7 @@ class TimeSlotFilterSet(filters.FilterSet):
.order_by("-start")
.values_list("id", flat=True)[:5]
)
relevant_timeslot_ids = list(nearest_timeslots_in_future) + list(
nearest_timeslots_in_past
)
relevant_timeslot_ids = list(nearest_timeslots_in_future) + list(nearest_timeslots_in_past)
return queryset.filter(id__in=relevant_timeslot_ids)
def filter_start(self, queryset: QuerySet, name: str, value: datetime.date):
......
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