Initial commit - clean project structure

This commit is contained in:
2026-08-18 16:48:15 +03:30
commit 331148037e
147 changed files with 5543 additions and 0 deletions

20
discount/receivers.py Normal file
View 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')