mirror of
https://github.com/pretix/pretix.git
synced 2026-05-20 17:44:02 +00:00
fix combined valid and product check
This commit is contained in:
@@ -665,20 +665,15 @@ def _redeem_process(*, checkinlists, raw_barcode, answers_data, datetime, force,
|
|||||||
|
|
||||||
# 3. Handle the "multiple options found" case: Except for the unlikely case of a secret being also a valid primary
|
# 3. Handle the "multiple options found" case: Except for the unlikely case of a secret being also a valid primary
|
||||||
# key on the same list, we're probably dealing with multiple linked_orderpositions or the ``addon_match`` case
|
# key on the same list, we're probably dealing with multiple linked_orderpositions or the ``addon_match`` case
|
||||||
# here and in the latter case need to figure out which add-on has the right product.
|
# here and need to figure out which op has the right product. This basically is a valid-for-checkin-test on every op.
|
||||||
if len(op_candidates) > 1:
|
if len(op_candidates) > 1:
|
||||||
today = now()
|
today = now()
|
||||||
# when we have addons and non-addons, we need to match the product as well
|
|
||||||
match_product = any([op.addon_to for op in op_candidates]) and any([not op.addon_to for op in op_candidates])
|
|
||||||
op_candidates_matching_product = [
|
op_candidates_matching_product = [
|
||||||
op for op in op_candidates
|
op for op in op_candidates
|
||||||
if (
|
if (
|
||||||
(not op.valid_from or op.valid_from < today) and
|
(not op.valid_from or op.valid_from < today) and
|
||||||
(not op.valid_until or op.valid_until > today) and
|
(not op.valid_until or op.valid_until > today) and
|
||||||
(not match_product or (
|
|
||||||
(list_by_event[op.order.event_id].addon_match or op.secret == raw_barcode or legacy_url_support) and
|
|
||||||
(list_by_event[op.order.event_id].all_products or op.item_id in {i.pk for i in list_by_event[op.order.event_id].limit_products.all()})
|
(list_by_event[op.order.event_id].all_products or op.item_id in {i.pk for i in list_by_event[op.order.event_id].limit_products.all()})
|
||||||
))
|
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ def test_by_medium(token_client, organizer, clist, event, order):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_by_medium_multiple_orderpositions(token_client, organizer, clist, event, order):
|
def test_by_medium_multiple_orderpositions(token_client, organizer, clist_all, event, order):
|
||||||
with scopes_disabled():
|
with scopes_disabled():
|
||||||
rm = ReusableMedium.objects.create(
|
rm = ReusableMedium.objects.create(
|
||||||
type="barcode",
|
type="barcode",
|
||||||
@@ -315,7 +315,7 @@ def test_by_medium_multiple_orderpositions(token_client, organizer, clist, event
|
|||||||
rm.linked_orderpositions.add(op_item_other)
|
rm.linked_orderpositions.add(op_item_other)
|
||||||
|
|
||||||
# multiple tickets are valid => no check-in
|
# multiple tickets are valid => no check-in
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert resp.data['status'] == 'error'
|
assert resp.data['status'] == 'error'
|
||||||
assert resp.data['reason'] == 'ambiguous'
|
assert resp.data['reason'] == 'ambiguous'
|
||||||
@@ -327,18 +327,18 @@ def test_by_medium_multiple_orderpositions(token_client, organizer, clist, event
|
|||||||
|
|
||||||
with freeze_time("2020-01-01 13:45:00"):
|
with freeze_time("2020-01-01 13:45:00"):
|
||||||
# multiple tickets are valid => no check-in
|
# multiple tickets are valid => no check-in
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert resp.data['status'] == 'error'
|
assert resp.data['status'] == 'error'
|
||||||
assert resp.data['reason'] == 'ambiguous'
|
assert resp.data['reason'] == 'ambiguous'
|
||||||
|
|
||||||
with freeze_time("2020-01-01 10:45:00"):
|
with freeze_time("2020-01-01 10:45:00"):
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 201
|
assert resp.status_code == 201
|
||||||
assert resp.data['status'] == 'ok'
|
assert resp.data['status'] == 'ok'
|
||||||
|
|
||||||
with freeze_time("2020-01-01 15:45:00"):
|
with freeze_time("2020-01-01 15:45:00"):
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert resp.data['status'] == 'error'
|
assert resp.data['status'] == 'error'
|
||||||
assert resp.data['reason'] == 'already_redeemed'
|
assert resp.data['reason'] == 'already_redeemed'
|
||||||
@@ -349,7 +349,7 @@ def test_by_medium_multiple_orderpositions(token_client, organizer, clist, event
|
|||||||
op_item_first.save()
|
op_item_first.save()
|
||||||
|
|
||||||
with freeze_time("2020-01-01 15:45:00"):
|
with freeze_time("2020-01-01 15:45:00"):
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert resp.data['status'] == 'error'
|
assert resp.data['status'] == 'error'
|
||||||
assert resp.data['reason'] == 'invalid_time'
|
assert resp.data['reason'] == 'invalid_time'
|
||||||
@@ -360,7 +360,7 @@ def test_by_medium_multiple_orderpositions(token_client, organizer, clist, event
|
|||||||
op_item_other.canceled = True
|
op_item_other.canceled = True
|
||||||
op_item_other.save()
|
op_item_other.save()
|
||||||
|
|
||||||
resp = _redeem(token_client, organizer, clist, "abcdef", {"source_type": "barcode"})
|
resp = _redeem(token_client, organizer, clist_all, "abcdef", {"source_type": "barcode"})
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert resp.data['status'] == 'error'
|
assert resp.data['status'] == 'error'
|
||||||
assert resp.data['reason'] == 'canceled'
|
assert resp.data['reason'] == 'canceled'
|
||||||
|
|||||||
Reference in New Issue
Block a user