Move atomic transaction block

This commit is contained in:
Raphael Michel
2017-02-03 13:11:24 +01:00
parent 5495cd749a
commit 7146d984d0

View File

@@ -288,7 +288,6 @@ def _check_positions(event: Event, now_dt: datetime, positions: List[CartPositio
raise OrderError(err) raise OrderError(err)
@transaction.atomic
def _create_order(event: Event, email: str, positions: List[CartPosition], now_dt: datetime, def _create_order(event: Event, email: str, positions: List[CartPosition], now_dt: datetime,
payment_provider: BasePaymentProvider, locale: str=None, address: int=None, payment_provider: BasePaymentProvider, locale: str=None, address: int=None,
meta_info: dict=None): meta_info: dict=None):
@@ -317,6 +316,7 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d
if last_date < expires: if last_date < expires:
expires = last_date expires = last_date
with transaction.atomic():
order = Order.objects.create( order = Order.objects.create(
status=Order.STATUS_PENDING, status=Order.STATUS_PENDING,
event=event, event=event,
@@ -344,6 +344,7 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d
pass pass
order.log_action('pretix.event.order.placed') order.log_action('pretix.event.order.placed')
order_placed.send(event, order=order) order_placed.send(event, order=order)
return order return order