sms
This commit is contained in:
1 parent
250cdbab7f
commit
5c6069c3ef
87 files changed
+29209
-3697
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""قواعد فعال/غیرفعال بودن پیامک برای مشتری (مدل opt-out)."""
|
||||
from ..models import CustomerSMSSetting, SMSType
|
||||
|
||||
|
||||
def is_sms_enabled(customer, sms_type):
|
||||
"""اگر رکوردی با is_enabled=False وجود داشته باشد غیرفعال است؛ در غیر اینصورت فعال."""
|
||||
if customer is None or sms_type == SMSType.CUSTOM:
|
||||
return True
|
||||
setting = CustomerSMSSetting.objects.filter(customer=customer, sms_type=sms_type).first()
|
||||
if setting is None:
|
||||
return True
|
||||
return setting.is_enabled
|
||||
|
||||
|
||||
def customer_toggle_map(customer):
|
||||
"""فهرست نوعهای پیامک با وضعیت مؤثر (برای نمایش در پنل مشتری)."""
|
||||
overrides = {
|
||||
s.sms_type: s.is_enabled
|
||||
for s in CustomerSMSSetting.objects.filter(customer=customer)
|
||||
}
|
||||
return [
|
||||
{"code": code, "label": label, "enabled": overrides.get(code, True)}
|
||||
for code, label in SMSType.choices
|
||||
if code != SMSType.CUSTOM
|
||||
]
|
||||
Reference in new issue
Block a user