From 4587fed81b971842d05abfa4a2563f7eb5dfb2ce Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 25 Oct 2023 13:24:26 +0200 Subject: [PATCH] API: Allow to filter orders by customer --- doc/api/resources/orders.rst | 6 ++++++ src/pretix/api/views/order.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/api/resources/orders.rst b/doc/api/resources/orders.rst index 7c3420f38..a28fcb26a 100644 --- a/doc/api/resources/orders.rst +++ b/doc/api/resources/orders.rst @@ -135,6 +135,10 @@ last_modified datetime Last modificati The ``event`` attribute has been added. The organizer-level endpoint has been added. +.. versionchanged:: 2023.9 + + The ``customer`` query parameter has been added. + .. _order-position-resource: @@ -420,6 +424,7 @@ List of all orders :query string code: Only return orders that match the given order code :query string status: Only return orders in the given order status (see above) :query string search: Only return orders matching a given search query (matching for names, email addresses, and company names) + :query string customer: Only show orders linked to the given customer. :query integer item: Only return orders with a position that contains this item ID. *Warning:* Result will also include orders if they contain mixed items, and it will even return orders where the item is only contained in a canceled position. :query integer variation: Only return orders with a position that contains this variation ID. *Warning:* Result will also include orders if they contain mixed items and variations, and it will even return orders where the variation is only contained in a canceled position. :query boolean testmode: Only return orders with ``testmode`` set to ``true`` or ``false`` @@ -1566,6 +1571,7 @@ List of all order positions ``order__datetime,positionid`` :query string order: Only return positions of the order with the given order code :query string search: Fuzzy search matching the attendee name, order code, invoice address name as well as to the beginning of the secret. + :query string customer: Only show orders linked to the given customer. :query integer item: Only return positions with the purchased item matching the given ID. :query integer item__in: Only return positions with the purchased item matching one of the given comma-separated IDs. :query integer variation: Only return positions with the purchased item variation matching the given ID. diff --git a/src/pretix/api/views/order.py b/src/pretix/api/views/order.py index 992878193..aca2022f6 100644 --- a/src/pretix/api/views/order.py +++ b/src/pretix/api/views/order.py @@ -110,10 +110,11 @@ with scopes_disabled(): item = django_filters.CharFilter(field_name='all_positions', lookup_expr='item_id', distinct=True) variation = django_filters.CharFilter(field_name='all_positions', lookup_expr='variation_id', distinct=True) subevent = django_filters.CharFilter(field_name='all_positions', lookup_expr='subevent_id', distinct=True) + customer = django_filters.CharFilter(field_name='customer__identifier') class Meta: model = Order - fields = ['code', 'status', 'email', 'locale', 'testmode', 'require_approval'] + fields = ['code', 'status', 'email', 'locale', 'testmode', 'require_approval', 'customer'] @scopes_disabled() def subevent_after_qs(self, qs, name, value):