mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Autocheckin: Fix handling of mixed orders
This commit is contained in:
@@ -137,6 +137,7 @@ def perform_auto_checkin(sender, order, mode, payment_methods):
|
||||
)
|
||||
.distinct()
|
||||
.select_related("list")
|
||||
.prefetch_related("limit_products", "limit_variations")
|
||||
)
|
||||
|
||||
if any(r.list is None for r in rules):
|
||||
@@ -148,6 +149,8 @@ def perform_auto_checkin(sender, order, mode, payment_methods):
|
||||
all_lists = []
|
||||
|
||||
for r in rules:
|
||||
r_item_ids = {i.pk for i in r.limit_products.all()}
|
||||
r_variation_ids = {v.pk for v in r.limit_variations.all()}
|
||||
if r.list is not None:
|
||||
lists = [r.list]
|
||||
else:
|
||||
@@ -159,6 +162,10 @@ def perform_auto_checkin(sender, order, mode, payment_methods):
|
||||
i.pk for i in cl.limit_products.all()
|
||||
}:
|
||||
continue
|
||||
|
||||
if not (r.all_products or op.item_id in r_item_ids or op.variation_id in r_variation_ids):
|
||||
continue
|
||||
|
||||
if cl.subevent_id and cl.subevent_id != op.subevent_id:
|
||||
continue
|
||||
|
||||
|
||||
@@ -106,6 +106,29 @@ def test_items_limit(event, item, order, checkin_list):
|
||||
assert order.positions.first().checkins.exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@scopes_disabled()
|
||||
def test_variations_limit_mixed_order(event, item, order, checkin_list):
|
||||
var = item.variations.create(value="V1")
|
||||
op = order.positions.first()
|
||||
op.variation = var
|
||||
op.save()
|
||||
|
||||
var2 = item.variations.create(value="V2")
|
||||
order.positions.create(order=order, item=item, price=2, variation=var2)
|
||||
|
||||
acr = event.autocheckinrule_set.create(
|
||||
list=checkin_list,
|
||||
mode=AutoCheckinRule.MODE_PLACED,
|
||||
all_products=False,
|
||||
)
|
||||
acr.limit_variations.add(var)
|
||||
|
||||
order_placed.send(event, order=order)
|
||||
assert order.positions.first().checkins.exists()
|
||||
assert not order.positions.last().checkins.exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@scopes_disabled()
|
||||
def test_variations_limit(event, item, order, checkin_list):
|
||||
|
||||
Reference in New Issue
Block a user