diff --git a/admin_panel/templates/admin_panel/_customer_phones.html b/admin_panel/templates/admin_panel/_customer_phones.html new file mode 100644 index 0000000..f941e88 --- /dev/null +++ b/admin_panel/templates/admin_panel/_customer_phones.html @@ -0,0 +1,37 @@ +{% load custom_tags %} +{# ستون «شماره‌های تماس» مشتری — تک‌منبع برای همهٔ صفحاتِ ستون اطلاعات مشتری. #} +{# شماره‌ها از خودِ شیء customer استخراج می‌شوند (نه context view) تا هیچ صفحه‌ای بدون داده نماند. #} +{# با phones_editable=1 (قالب‌هایی که اسکریپت افزودن/حذف شماره دارند) دکمه‌های ویرایش هم می‌آیند. #} +{% customer_phones customer as sms_phone_entries %} +
+ +
+ {% for entry in sms_phone_entries %} +
+
+ +
+
+ +
+ + {% if phones_editable and perms.admin_panel.ViewStore %} +
+ +
+ {% endif %} +
+ {% empty %} +

شماره‌ای برای این مشتری ثبت نشده است.

+ {% endfor %} +
+ {% if phones_editable and perms.admin_panel.ViewStore %} + + {% endif %} +
diff --git a/admin_panel/templates/admin_panel/customerBase.html b/admin_panel/templates/admin_panel/customerBase.html index 932dacd..0877996 100644 --- a/admin_panel/templates/admin_panel/customerBase.html +++ b/admin_panel/templates/admin_panel/customerBase.html @@ -27,26 +27,7 @@ -
- -
- {% if perms.admin_panel.ViewStore %} - - - - {% else %} -

- {{ customer.phone1 }} -

-

- {{ customer.phone2 }} -

-

- {{ customer.phone3 }} -

- {% endif %} -
-
+ {% include "./_customer_phones.html" %}
diff --git a/admin_panel/templates/admin_panel/customerBaseNew.html b/admin_panel/templates/admin_panel/customerBaseNew.html index 0170dc6..c01ceb4 100644 --- a/admin_panel/templates/admin_panel/customerBaseNew.html +++ b/admin_panel/templates/admin_panel/customerBaseNew.html @@ -42,39 +42,7 @@
-
- -
- {# همهٔ شماره‌ها از هر منبعی که ذخیره شده‌اند (جدول شماره‌ها + فیلدهای قدیمی)، بدون تکرار #} - {% for entry in sms_phone_entries %} -
-
- -
-
- -
- - {% if perms.admin_panel.ViewStore %} -
- -
- {% endif %} -
- {% empty %} -

شماره‌ای برای این مشتری ثبت نشده است.

- {% endfor %} -
- {% if perms.admin_panel.ViewStore %} - - {% endif %} -
+ {% include "./_customer_phones.html" with phones_editable=1 %}
diff --git a/admin_panel/templatetags/custom_tags.py b/admin_panel/templatetags/custom_tags.py index bc5d34b..a5b8c27 100644 --- a/admin_panel/templatetags/custom_tags.py +++ b/admin_panel/templatetags/custom_tags.py @@ -20,6 +20,19 @@ def toJalaliDT(value): def has_group(user, group_name): return user.groups.filter(name=group_name).exists() +@register.simple_tag +def customer_phones(customer): + """شماره‌های مشتری برای ستون اطلاعات مشتری. + + قبلاً این داده فقط از context view می‌آمد و صفحاتی که آن را پاس نمی‌دادند + «شماره‌ای ثبت نشده» نشان می‌دادند؛ حالا از خودِ شیء ``customer`` استخراج + می‌شود تا هر صفحه‌ای که این ستون را رندر می‌کند یکسان باشد. + """ + if not getattr(customer, 'pk', None): + return [] + from admin_panel.sms.phones import customer_phone_entries + return customer_phone_entries(customer) + register.filter('has_group', has_group) register.filter('toJalali', toJalali) register.filter('toJalaliDT', toJalaliDT) \ No newline at end of file