Add "bulk" argument to order_placed signal (#5505)

* datasync: add immediate parameter to enqueue_order

* interactive argument for order_placed signal

The ``interactive`` argument specifies whether the order was
placed interactively, by a customer (as opposed to via a bulk
import or the REST API).

* use bulk=True instead of interactive=False to mark bulk imports
This commit is contained in:
luelista
2025-10-02 09:36:02 +02:00
committed by GitHub
parent 425f4da1f1
commit 9d5563018e
5 changed files with 20 additions and 19 deletions

View File

@@ -743,7 +743,7 @@ class EventOrderViewSet(OrderViewSetMixin, viewsets.ModelViewSet):
user=request.user if request.user.is_authenticated else None,
auth=request.auth,
)
order_placed.send(self.request.event, order=order)
order_placed.send(self.request.event, order=order, bulk=False)
if order.status == Order.STATUS_PAID:
order_paid.send(self.request.event, order=order)
order.log_action(

View File

@@ -221,7 +221,7 @@ def import_orders(event: Event, fileid: str, settings: dict, locale: str, user,
for o in orders:
with language(o.locale, event.settings.region):
order_placed.send(event, order=o)
order_placed.send(event, order=o, bulk=True)
if o.status == Order.STATUS_PAID:
order_paid.send(event, order=o)

View File

@@ -1091,7 +1091,7 @@ def _create_order(event: Event, *, email: str, positions: List[CartPosition], no
for msg in meta_info.get('confirm_messages', []):
order.log_action('pretix.event.order.consent', data={'msg': msg})
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
return order, payments

View File

@@ -665,12 +665,13 @@ As with all event-plugin signals, the ``sender`` keyword argument will contain t
order_placed = EventPluginSignal()
"""
Arguments: ``order``
Arguments: ``order``, ``bulk``
This signal is sent out every time an order is placed. The order object is given
as the first argument. This signal is *not* sent out if an order is created through
splitting an existing order, so you can not expect to see all orders by listening
to this signal.
as the first argument. The ``bulk`` argument specifies whether the order was placed
as part of a bulk action, e.g. an import from a file.
This signal is *not* sent out if an order is created through splitting an existing order,
so you can not expect to see all orders by listening to this signal.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
"""

View File

@@ -54,7 +54,7 @@ def test_sales_channel_all(event, item, order, checkin_list):
mode=AutoCheckinRule.MODE_PLACED,
all_sales_channels=True,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -67,12 +67,12 @@ def test_sales_channel_limit(event, item, order, checkin_list):
all_sales_channels=False,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert not order.positions.first().checkins.exists()
acr.limit_sales_channels.add(order.sales_channel)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -84,7 +84,7 @@ def test_items_all(event, item, order, checkin_list):
mode=AutoCheckinRule.MODE_PLACED,
all_products=True,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -97,12 +97,12 @@ def test_items_limit(event, item, order, checkin_list):
all_products=False,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert not order.positions.first().checkins.exists()
acr.limit_products.add(item)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -124,7 +124,7 @@ def test_variations_limit_mixed_order(event, item, order, checkin_list):
)
acr.limit_variations.add(var)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
assert not order.positions.last().checkins.exists()
@@ -143,19 +143,19 @@ def test_variations_limit(event, item, order, checkin_list):
all_products=False,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert not order.positions.first().checkins.exists()
acr.limit_variations.add(var)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
order.positions.first().checkins.all().delete()
acr.limit_products.add(item)
acr.limit_variations.clear()
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -170,7 +170,7 @@ def test_mode_placed(event, item, order, checkin_list):
order_paid.send(event, order=order)
assert not order.positions.first().checkins.exists()
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert order.positions.first().checkins.exists()
@@ -182,7 +182,7 @@ def test_mode_paid(event, item, order, checkin_list):
mode=AutoCheckinRule.MODE_PAID,
)
order_placed.send(event, order=order)
order_placed.send(event, order=order, bulk=False)
assert not order.positions.first().checkins.exists()
order_paid.send(event, order=order)