bugfix
This commit is contained in:
parent
6570be7b20
commit
2a428fbb5d
1 changed files with 10 additions and 15 deletions
|
|
@ -206,23 +206,19 @@ class Recipient(BaseModel):
|
||||||
def promote(self, plan=None, event=None):
|
def promote(self, plan=None, event=None):
|
||||||
recipient = self.get_recipient_uuid(plan, event)
|
recipient = self.get_recipient_uuid(plan, event)
|
||||||
promotion_amount = self.get_promotion_amount(plan=plan, event=event)
|
promotion_amount = self.get_promotion_amount(plan=plan, event=event)
|
||||||
if recipient and promotion_amount:
|
promotion, created = Promotion.objects.get_or_create(
|
||||||
|
promotion_amount=promotion_amount,
|
||||||
|
user_uuid=self.get_recipient_uuid(plan, event),
|
||||||
|
event=event,
|
||||||
|
plan=plan,
|
||||||
|
recipient=self,
|
||||||
|
base_amount=promotion_amount,
|
||||||
|
)
|
||||||
|
if recipient and promotion_amount and created:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
promotion_amount = self.get_promotion_amount(plan=plan, event=event)
|
|
||||||
reserved = self.plan.reserve_promotion_amount(promotion_amount)
|
reserved = self.plan.reserve_promotion_amount(promotion_amount)
|
||||||
if reserved:
|
if reserved:
|
||||||
promotion, created = Promotion.objects.get_or_create(
|
promotion.promote()
|
||||||
promotion_amount=promotion_amount,
|
|
||||||
user_uuid=self.get_recipient_uuid(plan, event),
|
|
||||||
event=event,
|
|
||||||
plan=plan,
|
|
||||||
recipient=self,
|
|
||||||
base_amount=promotion_amount,
|
|
||||||
)
|
|
||||||
if created:
|
|
||||||
promotion.promote()
|
|
||||||
else:
|
|
||||||
raise Exception('promotion object not created')
|
|
||||||
else:
|
else:
|
||||||
raise Exception('promotion reward not reserved')
|
raise Exception('promotion reward not reserved')
|
||||||
|
|
||||||
|
|
@ -246,7 +242,6 @@ class PromotionQuerySet(models.QuerySet):
|
||||||
|
|
||||||
|
|
||||||
class Promotion(BaseModel):
|
class Promotion(BaseModel):
|
||||||
|
|
||||||
user_uuid = models.UUIDField() # user_uuid
|
user_uuid = models.UUIDField() # user_uuid
|
||||||
application = models.ForeignKey(oauth2_settings.APPLICATION_MODEL, on_delete=models.PROTECT,
|
application = models.ForeignKey(oauth2_settings.APPLICATION_MODEL, on_delete=models.PROTECT,
|
||||||
related_name='+', null=True, blank=True)
|
related_name='+', null=True, blank=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue