mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Check-in: Save answers independent of result
This commit is contained in:
@@ -143,7 +143,6 @@ def _save_answers(op, answers, given_answers):
|
|||||||
op.answers.create(question=q, answer=str(a))
|
op.answers.create(question=q, answer=str(a))
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic
|
|
||||||
def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict, force=False,
|
def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict, force=False,
|
||||||
ignore_unpaid=False, nonce=None, datetime=None, questions_supported=True,
|
ignore_unpaid=False, nonce=None, datetime=None, questions_supported=True,
|
||||||
user=None, auth=None, canceled_supported=False, type=Checkin.TYPE_ENTRY):
|
user=None, auth=None, canceled_supported=False, type=Checkin.TYPE_ENTRY):
|
||||||
@@ -163,18 +162,16 @@ def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict,
|
|||||||
"""
|
"""
|
||||||
dt = datetime or now()
|
dt = datetime or now()
|
||||||
|
|
||||||
# Lock order positions
|
|
||||||
op = OrderPosition.all.select_for_update().get(pk=op.pk)
|
|
||||||
checkin_questions = list(
|
|
||||||
clist.event.questions.filter(ask_during_checkin=True, items__in=[op.item_id])
|
|
||||||
)
|
|
||||||
|
|
||||||
if op.canceled or op.order.status not in (Order.STATUS_PAID, Order.STATUS_PENDING):
|
if op.canceled or op.order.status not in (Order.STATUS_PAID, Order.STATUS_PENDING):
|
||||||
raise CheckInError(
|
raise CheckInError(
|
||||||
_('This order position has been canceled.'),
|
_('This order position has been canceled.'),
|
||||||
'canceled' if canceled_supported else 'unpaid'
|
'canceled' if canceled_supported else 'unpaid'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Do this outside of transaction so it is saved even if the checkin fails for some other reason
|
||||||
|
checkin_questions = list(
|
||||||
|
clist.event.questions.filter(ask_during_checkin=True, items__in=[op.item_id])
|
||||||
|
)
|
||||||
require_answers = []
|
require_answers = []
|
||||||
if checkin_questions:
|
if checkin_questions:
|
||||||
answers = {a.question: a for a in op.answers.all()}
|
answers = {a.question: a for a in op.answers.all()}
|
||||||
@@ -184,6 +181,10 @@ def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict,
|
|||||||
|
|
||||||
_save_answers(op, answers, given_answers)
|
_save_answers(op, answers, given_answers)
|
||||||
|
|
||||||
|
with transaction.atomic():
|
||||||
|
# Lock order positions
|
||||||
|
op = OrderPosition.all.select_for_update().get(pk=op.pk)
|
||||||
|
|
||||||
if not clist.all_products and op.item_id not in [i.pk for i in clist.limit_products.all()]:
|
if not clist.all_products and op.item_id not in [i.pk for i in clist.limit_products.all()]:
|
||||||
raise CheckInError(
|
raise CheckInError(
|
||||||
_('This order position has an invalid product for this check-in list.'),
|
_('This order position has an invalid product for this check-in list.'),
|
||||||
|
|||||||
Reference in New Issue
Block a user