mirror of
https://github.com/pretix/pretix.git
synced 2026-05-19 17:34:03 +00:00
combine addon match and time-based validity match
This commit is contained in:
@@ -664,30 +664,26 @@ def _redeem_process(*, checkinlists, raw_barcode, answers_data, datetime, force,
|
|||||||
op_candidates += list(op.addons.all())
|
op_candidates += list(op.addons.all())
|
||||||
|
|
||||||
# 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 the ``addon_match`` case here and need to figure out
|
# key on the same list, we're probably dealing with multiple linked_orderpositions or the ``addon_match`` case
|
||||||
# which add-on has the right product.
|
# here and in the latter case need to figure out which add-on has the right product.
|
||||||
if len(op_candidates) > 1:
|
if len(op_candidates) > 1:
|
||||||
# only check addons if at most one non-addon-op is in op_candidates
|
today = now()
|
||||||
# otherwise it is likely a medium linked to multiple orderpositions, which we need to filter based on validity
|
# when we have addons and non-addons, we need to match the product as well
|
||||||
if len([op for op in op_candidates if not op.addon_to]) <= 1:
|
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_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].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()})
|
||||||
)
|
))
|
||||||
]
|
)
|
||||||
else:
|
]
|
||||||
op_candidates_matching_product = [
|
|
||||||
op for op in op_candidates
|
|
||||||
if (
|
|
||||||
(not op.valid_from or op.valid_from < now()) and
|
|
||||||
(not op.valid_until or op.valid_until > now())
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
if len(op_candidates_matching_product) == 0:
|
if len(op_candidates_matching_product) == 0:
|
||||||
# None of the found add-ons has the correct product, too bad! We could just error out here, but
|
# None of the ops is valid today or has the correct product, too bad! We could just error out here, but
|
||||||
# instead we just continue with *any* product and have it rejected by the check in perform_checkin.
|
# instead we just continue with *any* product and have it rejected by the check in perform_checkin.
|
||||||
# This has the advantage of a better error message.
|
# This has the advantage of a better error message.
|
||||||
op_candidates = [op_candidates[0]]
|
op_candidates = [op_candidates[0]]
|
||||||
|
|||||||
Reference in New Issue
Block a user