create promotion outside of atomic
This commit is contained in:
parent
2a428fbb5d
commit
faab09595c
1 changed files with 10 additions and 6 deletions
|
|
@ -215,12 +215,16 @@ class Recipient(BaseModel):
|
||||||
base_amount=promotion_amount,
|
base_amount=promotion_amount,
|
||||||
)
|
)
|
||||||
if recipient and promotion_amount and created:
|
if recipient and promotion_amount and created:
|
||||||
with transaction.atomic():
|
try:
|
||||||
reserved = self.plan.reserve_promotion_amount(promotion_amount)
|
with transaction.atomic():
|
||||||
if reserved:
|
reserved = self.plan.reserve_promotion_amount(promotion_amount)
|
||||||
promotion.promote()
|
if reserved:
|
||||||
else:
|
promotion.promote()
|
||||||
raise Exception('promotion reward not reserved')
|
else:
|
||||||
|
raise Exception('promotion reward not reserved')
|
||||||
|
except Exception as e:
|
||||||
|
promotion.change_state(from_states=[promotion.state], to_state=PaymentStateChoices.EXPECTED_FAILURE, same_ok=True)
|
||||||
|
promotion.refresh_from_db()
|
||||||
|
|
||||||
return promotion
|
return promotion
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue