Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add is_empty flag to list views
Anna Siwik963bcf3ad96c
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.pyindex a38191cc08..b9c1403d90 100644--- a/saleor/dashboard/category/views.py+++ b/saleor/dashboard/category/views.py@@ -22,7 +22,9 @@ def category_list(request):categories = get_paginator_items(category_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'categories': categories, 'filter': category_filter}+ ctx = {+ 'categories': categories, 'filter': category_filter,+ 'is_empty': not category_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/category/list.html', ctx)@@ -88,7 +90,8 @@ def category_detail(request, pk):category_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))ctx = {'categories': categories, 'path': path, 'root': root,- 'filter': category_filter}+ 'filter': category_filter,+ 'is_empty': not category_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/category/detail.html', ctx)diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.pyindex 8e68210028..233c9748ff 100644--- a/saleor/dashboard/customer/views.py+++ b/saleor/dashboard/customer/views.py@@ -24,7 +24,9 @@ def customer_list(request):customers = get_paginator_items(customer_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'customers': customers, 'filter': customer_filter}+ ctx = {+ 'customers': customers, 'filter': customer_filter,+ 'is_empty': not customer_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/customer/list.html', ctx)diff --git a/saleor/dashboard/discount/views.py b/saleor/dashboard/discount/views.pyindex b921eb0153..22a9cacc07 100644--- a/saleor/dashboard/discount/views.py+++ b/saleor/dashboard/discount/views.py@@ -20,7 +20,9 @@ def sale_list(request):sales = get_paginator_items(sale_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'sales': sales, 'filter': sale_filter}+ ctx = {+ 'sales': sales, 'filter': sale_filter,+ 'is_empty': not sale_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/discount/sale/list.html', ctx)@@ -64,7 +66,9 @@ def voucher_list(request):vouchers = get_paginator_items(voucher_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'vouchers': vouchers, 'filter': voucher_filter}+ ctx = {+ 'vouchers': vouchers, 'filter': voucher_filter,+ 'is_empty': not voucher_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/discount/voucher/list.html', ctx)diff --git a/saleor/dashboard/group/views.py b/saleor/dashboard/group/views.pyindex 52048fc659..4a629ddbb5 100644--- a/saleor/dashboard/group/views.py+++ b/saleor/dashboard/group/views.py@@ -22,7 +22,9 @@ def group_list(request):for group in group_filter.qs]groups = get_paginator_items(groups, settings.DASHBOARD_PAGINATE_BY, request.GET.get('page'))- ctx = {'groups': groups, 'filter': group_filter}+ ctx = {+ 'groups': groups, 'filter': group_filter,+ 'is_empty': not group_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/group/list.html', ctx)diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex ac7fa8dbbb..016b5e8d89 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -37,7 +37,9 @@ def order_list(request):orders = get_paginator_items(order_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'orders': orders, 'filter': order_filter}+ ctx = {+ 'orders': orders, 'filter': order_filter,+ 'is_empty': not order_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/order/list.html', ctx)diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 6b312b0520..70aa11affe 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -38,7 +38,9 @@ def product_class_list(request):(pc.pk, pc.name, pc.has_variants, pc.product_attributes.all(),pc.variant_attributes.all())for pc in classes.object_list]- ctx = {'form': form, 'product_classes': classes, 'filter': class_filter}+ ctx = {+ 'form': form, 'product_classes': classes, 'filter': class_filter,+ 'is_empty': not class_filter.queryset.exists()}return TemplateResponse(request,'dashboard/product/product_class/list.html',@@ -119,6 +121,7 @@ def product_list(request):'bulk_action_form': forms.ProductBulkUpdate(),'products': products, 'product_classes': product_classes,'filter': product_filter,+ 'is_empty': not product_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/product/list.html', ctx)@@ -203,7 +206,8 @@ def product_detail(request, pk):'gross_price_range': gross_price_range, 'images': images,'no_variants': no_variants, 'only_variant': only_variant,'stock': stock, 'purchase_cost': purchase_cost,- 'gross_margin': gross_margin}+ 'gross_margin': gross_margin,+ 'is_empty': not variants.exists()}return TemplateResponse(request, 'dashboard/product/detail.html', ctx)@@ -330,10 +334,10 @@ def product_images(request, product_pk):product = get_object_or_404(Product.objects.prefetch_related('images'), pk=product_pk)images = product.images.all()+ ctx = {+ 'product': product, 'images': images, 'is_empty': not images.exists()}return TemplateResponse(- request,- 'dashboard/product/product_image/list.html',- {'product': product, 'images': images})+ request, 'dashboard/product/product_image/list.html', ctx)@staff_member_required@@ -433,7 +437,8 @@ def variant_details(request, product_pk, variant_pk):costs_data = get_variant_costs_data(variant)ctx = {'images': images, 'product': product, 'stock': stock,'variant': variant, 'costs': costs_data['costs'],- 'margins': costs_data['margins']}+ 'margins': costs_data['margins'],+ 'is_empty': not stock.exists()}return TemplateResponse(request,'dashboard/product/product_variant/detail.html',@@ -492,7 +497,9 @@ def attribute_list(request):for attribute in attribute_filter.qs]attributes = get_paginator_items(attributes, settings.DASHBOARD_PAGINATE_BY, request.GET.get('page'))- ctx = {'attributes': attributes, 'filter': attribute_filter}+ ctx = {+ 'attributes': attributes, 'filter': attribute_filter,+ 'is_empty': not attribute_filter.queryset.exists()}return TemplateResponse(request,'dashboard/product/product_attribute/list.html',@@ -504,10 +511,11 @@ def attribute_list(request):def attribute_detail(request, pk):attributes = ProductAttribute.objects.prefetch_related('values').all()attribute = get_object_or_404(attributes, pk=pk)+ ctx = {+ 'attribute': attribute,+ 'is_empty': not attributes.exists()}return TemplateResponse(- request,- 'dashboard/product/product_attribute/detail.html',- {'attribute': attribute})+ request, 'dashboard/product/product_attribute/detail.html', ctx)@staff_member_required@@ -603,7 +611,9 @@ def stock_location_list(request):stock_locations = get_paginator_items(stock_location_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'locations': stock_locations, 'filter': stock_location_filter}+ ctx = {+ 'locations': stock_locations, 'filter': stock_location_filter,+ 'is_empty': not stock_location_filter.queryset.exists()}return TemplateResponse(request,'dashboard/product/stock_location/list.html',diff --git a/saleor/dashboard/shipping/views.py b/saleor/dashboard/shipping/views.pyindex 059cba44b6..a8b006629a 100644--- a/saleor/dashboard/shipping/views.py+++ b/saleor/dashboard/shipping/views.py@@ -22,7 +22,9 @@ def shipping_method_list(request):methods = get_paginator_items(shipping_method_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'shipping_methods': methods, 'filter': shipping_method_filter}+ ctx = {+ 'shipping_methods': methods, 'filter': shipping_method_filter,+ 'is_empty': not shipping_method_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/shipping/list.html', ctx)diff --git a/saleor/dashboard/sites/views.py b/saleor/dashboard/sites/views.pyindex 57d8166803..dae1233454 100644--- a/saleor/dashboard/sites/views.py+++ b/saleor/dashboard/sites/views.py@@ -46,7 +46,9 @@ def site_settings_detail(request, pk):site_settings = get_object_or_404(SiteSettings, pk=pk)authorization_keys = AuthorizationKey.objects.filter(site_settings=site_settings)- ctx = {'site': site_settings, 'authorization_keys': authorization_keys}+ ctx = {+ 'site': site_settings, 'authorization_keys': authorization_keys,+ 'is_empty': not authorization_keys.exists()}return TemplateResponse(request, 'dashboard/sites/detail.html', ctx)diff --git a/saleor/dashboard/staff/views.py b/saleor/dashboard/staff/views.pyindex 1badb2ae63..f04720b5f4 100644--- a/saleor/dashboard/staff/views.py+++ b/saleor/dashboard/staff/views.py@@ -23,7 +23,9 @@ def staff_list(request):staff_members = get_paginator_items(staff_filter.qs, settings.DASHBOARD_PAGINATE_BY,request.GET.get('page'))- ctx = {'staff': staff_members, 'filter': staff_filter}+ ctx = {+ 'staff': staff_members, 'filter': staff_filter,+ 'is_empty': not staff_filter.queryset.exists()}return TemplateResponse(request, 'dashboard/staff/list.html', ctx)diff --git a/templates/dashboard/shipping/list.html b/templates/dashboard/shipping/list.htmlindex a5ae2f8194..930fb3e4a8 100644--- a/templates/dashboard/shipping/list.html+++ b/templates/dashboard/shipping/list.html@@ -93,8 +93,8 @@{% endif %}</div><div class="col s12 l3" id="filters">- {% add_filters filter %}- </div>+ {% add_filters filter %}+ </div></div>{% paginate shipping_methods %}{% endblock %}diff --git a/templates/dashboard/sites/detail.html b/templates/dashboard/sites/detail.htmlindex f230437b3c..84c7f8de89 100644--- a/templates/dashboard/sites/detail.html+++ b/templates/dashboard/sites/detail.html@@ -74,7 +74,7 @@<div class="card"><div class="card-content"><span class="card-title">- {% trans "Authorization keys" context "Title of the authorization keys list" %}+ {% trans "Authorization keys" context "Title of the authorization keys list" %}</span></div><div class="data-table-header-action">