Initial commit - clean project structure
This commit is contained in:
20
discount/receivers.py
Normal file
20
discount/receivers.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
گیرندهی سیگنال ثبتنام (accounts.signals.user_registered). accounts هیچوقت
|
||||
از وجود discount/Offer خبر نداره؛ این فایل فقط توی apps.py همین اپ (discount)
|
||||
connect میشه. برای تغییر منطق «کدوم آفر به کی تعلق بگیره»، فقط همینجا و
|
||||
discount/services.py رو لمس کنید — دقیقاً همون چیزی که سینیور خواسته بود.
|
||||
"""
|
||||
from accounts.signals import user_registered
|
||||
|
||||
from .models import Offer
|
||||
from .services import apply_offer
|
||||
|
||||
|
||||
def _assign_signup_offers(sender, **kwargs):
|
||||
user_id = kwargs['user_id']
|
||||
offers = Offer.objects.filter(auto_assign_on_signup=True, is_active=True)
|
||||
for offer in offers:
|
||||
apply_offer(user_id=user_id, offer=offer, source='signup_auto')
|
||||
|
||||
|
||||
user_registered.connect(_assign_signup_offers, dispatch_uid='discount_assign_signup_offers')
|
||||
Reference in New Issue
Block a user