From 8c63659050cd5bd415204c96d2e876a947d1773e Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 13 Jul 2022 16:29:30 +0200 Subject: [PATCH] API: Allow to filter quota list for multiple subevents --- doc/api/resources/quotas.rst | 3 ++- src/pretix/api/views/item.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/resources/quotas.rst b/doc/api/resources/quotas.rst index 35057645d..a03a9af88 100644 --- a/doc/api/resources/quotas.rst +++ b/doc/api/resources/quotas.rst @@ -89,7 +89,8 @@ Endpoints :query integer page: The page number in case of a multi-page result set, default is 1 :query string ordering: Manually set the ordering of results. Valid fields to be used are ``id`` and ``position``. Default: ``position`` - :query integer subevent: Only return quotas of the sub-event with the given ID + :query integer subevent: Only return quotas of the sub-event with the given ID. Can be passed multiple times to filter + for multiple sub-events. :query string with_availability: Set to ``true`` to get availability information. Can lead to increased answer times. :param organizer: The ``slug`` field of the organizer to fetch :param event: The ``slug`` field of the event to fetch diff --git a/src/pretix/api/views/item.py b/src/pretix/api/views/item.py index e21c8a2e2..bf49f0dd3 100644 --- a/src/pretix/api/views/item.py +++ b/src/pretix/api/views/item.py @@ -52,7 +52,7 @@ from pretix.api.serializers.item import ( from pretix.api.views import ConditionalListView from pretix.base.models import ( CartPosition, Item, ItemAddOn, ItemBundle, ItemCategory, ItemVariation, - Question, QuestionOption, Quota, + Question, QuestionOption, Quota, SubEvent, ) from pretix.base.services.quotas import QuotaAvailability from pretix.helpers.dicts import merge_dicts @@ -459,6 +459,8 @@ class QuestionOptionViewSet(viewsets.ModelViewSet): with scopes_disabled(): class QuotaFilter(FilterSet): + subevent = django_filters.ModelMultipleChoiceFilter(queryset=SubEvent.objects.all()) + class Meta: model = Quota fields = ['subevent']