fix(promotion): fix promotion not valid condition
fix promotion not valid condition
This commit is contained in:
parent
50e69d985c
commit
8300f09003
2 changed files with 10 additions and 3 deletions
|
|
@ -502,7 +502,7 @@ class Promotion(BaseModel):
|
||||||
if self.state not in [PaymentStateChoices.CREATED]:
|
if self.state not in [PaymentStateChoices.CREATED]:
|
||||||
raise Exception(_('Cannot promote. not in correct state'))
|
raise Exception(_('Cannot promote. not in correct state'))
|
||||||
|
|
||||||
if not self.promotion_amount or self.plan.balance_holder:
|
if not self.promotion_amount:
|
||||||
to_not_payed = self.change_state(
|
to_not_payed = self.change_state(
|
||||||
from_states=[PaymentStateChoices.CREATED],
|
from_states=[PaymentStateChoices.CREATED],
|
||||||
to_state=PaymentStateChoices.SUCCESS,
|
to_state=PaymentStateChoices.SUCCESS,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
from apps.promotions.models import Event
|
from apps.promotions.models import Event
|
||||||
from main import celery_app
|
from main import celery_app
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@celery_app.task
|
@celery_app.task
|
||||||
def analyze_event_task(event_uuid):
|
def analyze_event_task(event_uuid):
|
||||||
event = Event.objects.get(uuid=event_uuid)
|
event = Event.objects.get(uuid=event_uuid)
|
||||||
for plan_analyze_result in event.analyze():
|
for plan_analyze_result in event.analyze():
|
||||||
|
try:
|
||||||
for promotion in plan_analyze_result:
|
for promotion in plan_analyze_result:
|
||||||
print(promotion)
|
print(promotion)
|
||||||
|
except Exception:
|
||||||
|
logger.exception('Failed to process plan for event %s', event_uuid)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue