Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add summary message to filterset records found
Anna Siwik1834030729e2
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex f24627a644..1a36a1417d 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -6,7 +6,7 @@ from django.http import HttpResponsefrom django.shortcuts import get_object_or_404, redirectfrom django.template.context_processors import csrffrom django.template.response import TemplateResponse-from django.utils.translation import pgettext_lazy+from django.utils.translation import npgettext_lazy, pgettext_lazyfrom django_prices.templatetags.prices_i18n import grossfrom payments import PaymentStatusfrom prices import Price@@ -34,12 +34,18 @@ def order_list(request):orders = (Order.objects.prefetch_related('payments', 'groups__lines', 'user').order_by('-pk'))order_filter = OrderFilter(request.GET, queryset=orders)+ summary_msg = npgettext_lazy(+ 'Filter set results summary',+ 'Found %(counter)d matching product',+ 'Found %(counter)d matching products',+ 'counter') % {'counter': order_filter.qs.count() }orders = get_paginator_items(order_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))ctx = {'orders': orders, 'filter': order_filter,- 'is_empty': not order_filter.queryset.exists()}+ 'is_empty': not order_filter.queryset.exists(),+ 'summary_msg': summary_msg}return TemplateResponse(request, 'dashboard/order/list.html', ctx)diff --git a/saleor/dashboard/templatetags/utils.py b/saleor/dashboard/templatetags/utils.pyindex d717d0b3b1..94f5e83dfa 100644--- a/saleor/dashboard/templatetags/utils.py+++ b/saleor/dashboard/templatetags/utils.py@@ -76,7 +76,9 @@ def margins_for_variant(variant):@register.inclusion_tag('dashboard/includes/_filters.html', takes_context=True)-def add_filters(context, filter_set, sort_by_filter_name='sort_by'):+def add_filters(+ context, filter_set, summary_msg, sort_by_filter_name='sort_by'):+ """Rendering filters template based on FilterSet."""chips = []request_get = context['request'].GET.copy()for filter_name in filter_set.form.cleaned_data.keys():@@ -102,7 +104,7 @@ def add_filters(context, filter_set, sort_by_filter_name='sort_by'):items = handle_default(field, request_get)chips.extend(items)return {- 'chips': chips, 'filter': filter_set, 'count': filter_set.qs.count(),+ 'chips': chips, 'filter': filter_set, 'summary_msg': summary_msg,'sort_by': request_get.get(sort_by_filter_name, None)}diff --git a/templates/dashboard/includes/_filters.html b/templates/dashboard/includes/_filters.htmlindex ac71c3be79..b0479d963c 100644--- a/templates/dashboard/includes/_filters.html+++ b/templates/dashboard/includes/_filters.html@@ -8,7 +8,7 @@<div class="card-content"><div class="col s12"><span class="card-title">{% trans 'Filters' context 'Dashboard card title' %}</span>- <span>{% trans 'Total records found' context 'Dashboard filter' %}: {{ count }}</span>+ {{ summary_msg }}<span class="collapse-activate hide-on-large-only"><svg data-src="{% static '/images/filter_icon.svg' %}" /></span></div><div class="col s12 hide-on-large-only chips-container">diff --git a/templates/dashboard/order/list.html b/templates/dashboard/order/list.htmlindex 40cbef0f1a..71f052a7a7 100644--- a/templates/dashboard/order/list.html+++ b/templates/dashboard/order/list.html@@ -41,7 +41,7 @@{% endif %}</div><div class="col s12 l3" id="filters">- {% if not is_empty %}{% add_filters filter %}{% endif %}+ {% if not is_empty %}{% add_filters filter summary_msg %}{% endif %}</div></div>{% endblock %}