diff --git a/doc/api/resources/subevents.rst b/doc/api/resources/subevents.rst index 466c70868..b71b238da 100644 --- a/doc/api/resources/subevents.rst +++ b/doc/api/resources/subevents.rst @@ -474,6 +474,7 @@ Endpoints :query is_future: If set to ``true`` (``false``), only events that happen currently or in the future are (not) returned. :query is_past: If set to ``true`` (``false``), only events that are over are (not) returned. :query ends_after: If set to a date and time, only events that happen during of after the given time are returned. + :query sales_channel: If set to a sales channel identifier, the response will only contain subevents from events available on this sales channel. :param organizer: The ``slug`` field of a valid organizer :param event: The ``slug`` field of the event to fetch :statuscode 200: no error diff --git a/src/pretix/api/views/event.py b/src/pretix/api/views/event.py index 51d802983..98963f329 100644 --- a/src/pretix/api/views/event.py +++ b/src/pretix/api/views/event.py @@ -321,6 +321,7 @@ with scopes_disabled(): is_future = django_filters.rest_framework.BooleanFilter(method='is_future_qs') ends_after = django_filters.rest_framework.IsoDateTimeFilter(method='ends_after_qs') modified_since = django_filters.IsoDateTimeFilter(field_name='last_modified', lookup_expr='gte') + sales_channel = django_filters.rest_framework.CharFilter(method='sales_channel_qs') class Meta: model = SubEvent @@ -353,6 +354,9 @@ with scopes_disabled(): else: return queryset.exclude(expr) + def sales_channel_qs(self, queryset, name, value): + return queryset.filter(event__sales_channels__contains=value) + class SubEventViewSet(ConditionalListView, viewsets.ModelViewSet): serializer_class = SubEventSerializer