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,
|
||||
)
|
||||
if recipient and promotion_amount and created:
|
||||
try:
|
||||
with transaction.atomic():
|
||||
reserved = self.plan.reserve_promotion_amount(promotion_amount)
|
||||
if reserved:
|
||||
promotion.promote()
|
||||
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 None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue