Skip to content

Commit

Permalink
API: Allow to filter orders by customer
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Oct 25, 2023
1 parent 0642dcb commit 4587fed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/api/resources/orders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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``
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/pretix/api/views/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ class OrderFilter(FilterSet):
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):
Expand Down

0 comments on commit 4587fed

Please sign in to comment.