From e6fd44ef6b44bf35afd0415d6e9ef27d00b7b692 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Sat, 3 Jan 2026 15:38:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20'=D0=95=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BA=D0=B0=D0=BD=D0=B0=D0=BB=20=D1=81=D0=B2?= =?UTF-8?q?=D1=8F=D0=B7=D0=B8'=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Новый фильтр has_contact_channel показывает клиентов с записями в ContactChannel - Проверяет наличие альтернативных контактов (Instagram, Telegram и т.д.) - Добавлен чекбокс в форму фильтров с flex-wrap для переноса - Обновлено условие показа кнопки Очистить - Фильтр автоматически сохраняется в пагинации через url_replace --- myproject/customers/filters.py | 18 +++++++++++++++++- .../templates/customers/customer_list.html | 10 ++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/myproject/customers/filters.py b/myproject/customers/filters.py index c7becba..49028b4 100644 --- a/myproject/customers/filters.py +++ b/myproject/customers/filters.py @@ -38,9 +38,16 @@ class CustomerFilter(django_filters.FilterSet): widget=forms.CheckboxInput(attrs={'class': 'form-check-input'}) ) + # Фильтр: есть канал связи + has_contact_channel = django_filters.BooleanFilter( + method='filter_has_contact_channel', + label='Есть канал связи', + widget=forms.CheckboxInput(attrs={'class': 'form-check-input'}) + ) + class Meta: model = Customer - fields = ['has_notes', 'no_phone', 'no_email'] + fields = ['has_notes', 'no_phone', 'no_email', 'has_contact_channel'] def filter_has_notes(self, queryset, name, value): """Фильтр клиентов с заметками""" @@ -59,3 +66,12 @@ class CustomerFilter(django_filters.FilterSet): if value: return queryset.filter(email__isnull=True) | queryset.filter(email='') return queryset + + def filter_has_contact_channel(self, queryset, name, value): + """Фильтр клиентов с каналами связи (Instagram, Telegram и т.д.)""" + if value: + from .models import ContactChannel + # Возвращаем только клиентов у которых есть хотя бы один канал связи + customer_ids = ContactChannel.objects.values_list('customer_id', flat=True).distinct() + return queryset.filter(id__in=customer_ids) + return queryset diff --git a/myproject/customers/templates/customers/customer_list.html b/myproject/customers/templates/customers/customer_list.html index eeff6f4..b670e4a 100644 --- a/myproject/customers/templates/customers/customer_list.html +++ b/myproject/customers/templates/customers/customer_list.html @@ -41,7 +41,7 @@
-
+
{{ filter.form.has_notes }}
+
+ {{ filter.form.has_contact_channel }} + +
@@ -69,7 +75,7 @@ - {% if query or filter.form.has_notes.value or filter.form.no_phone.value or filter.form.no_email.value %} + {% if query or filter.form.has_notes.value or filter.form.no_phone.value or filter.form.no_email.value or filter.form.has_contact_channel.value %} Очистить