Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use render_sorting_header template tag
Anna Siwik6e58f7a0463e
diff --git a/saleor/core/templatetags/shop.py b/saleor/core/templatetags/shop.pyindex 56fe2c3883..6d4e857902 100644--- a/saleor/core/templatetags/shop.py+++ b/saleor/core/templatetags/shop.py@@ -18,7 +18,7 @@ def get_sort_by_url(context, field, descending=False):@register.inclusion_tag('dashboard/includes/_sorting_header.html', takes_context=True)-def render_sorting_header(context, field, label):+def render_sorting_header(context, field, label, is_wide=False):"""This template tag renders table sorting header."""request = context['request']request_get = request.GET.copy()@@ -50,4 +50,5 @@ def render_sorting_header(context, field, label):request_get['sort_by'] = new_sort_byreturn {'url': '%s?%s' % (request.path, request_get.urlencode()),- 'is_active': is_active, 'sorting_icon': sorting_icon, 'label': label}+ 'is_active': is_active, 'sorting_icon': sorting_icon, 'label': label,+ 'is_wide': is_wide}diff --git a/templates/dashboard/category/detail.html b/templates/dashboard/category/detail.htmlindex 347ffb4576..471d194c04 100644--- a/templates/dashboard/category/detail.html+++ b/templates/dashboard/category/detail.html@@ -2,7 +2,7 @@{% load i18n %}{% load mptt_tags %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -133,21 +133,15 @@<table class="bordered highlight responsive data-table data-table-description"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Category list table header name" %}- </a>- </th>- {% get_sort_by_toggle 'description' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Description" context "Category list table header description" %}- </a>- </th>- <th></th>+ {% trans "Name" context "Category list table header name" as label %}+ {% render_sorting_header 'name' label %}++ {% trans "Description" context "Category list table header description" as label %}+ {% render_sorting_header 'description' label is_wide=True %}++ {% if perms.product.edit_category %}+ <th></th>+ {% endif %}</tr></thead><tbody>diff --git a/templates/dashboard/category/list.html b/templates/dashboard/category/list.htmlindex 9ca87fe27e..f7067c029c 100644--- a/templates/dashboard/category/list.html+++ b/templates/dashboard/category/list.html@@ -2,7 +2,7 @@{% load i18n %}{% load mptt_tags %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -51,20 +51,11 @@<table class="bordered highlight responsive data-table data-table-description"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Category list table header name" %}- </a>- </th>- {% get_sort_by_toggle 'description' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Description" context "Category list table header description" %}- </a>- </th>+ {% trans "Name" context "Category list table header name" as label %}+ {% render_sorting_header 'name' label %}++ {% trans "Description" context "Category list table header description" as label %}+ {% render_sorting_header 'description' label is_wide=True %}</tr></thead><tbody>diff --git a/templates/dashboard/customer/list.html b/templates/dashboard/customer/list.htmlindex 816e288647..08deb29590 100644--- a/templates/dashboard/customer/list.html+++ b/templates/dashboard/customer/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load prices_i18n %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load materializecss %}{% load utils %}@@ -30,27 +30,14 @@<table class="bordered highlight responsive data-table"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Customers table header" %}- </a>- </th>- {% get_sort_by_toggle 'email' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Email" context "Customers table header" %}- </a>- </th>- {% get_sort_by_toggle 'location' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Location" context "Customers table header" %}- </a>- </th>+ {% trans "Name" context "Customers table header" as label %}+ {% render_sorting_header 'name' label %}++ {% trans "Email" context "Customers table header" as label %}+ {% render_sorting_header 'email' label %}++ {% trans "Location" context "Customers table header" as label %}+ {% render_sorting_header 'location' label %}</tr></thead><tbody>diff --git a/templates/dashboard/discount/sale/list.html b/templates/dashboard/discount/sale/list.htmlindex be964cec82..ef75d73afe 100644--- a/templates/dashboard/discount/sale/list.html+++ b/templates/dashboard/discount/sale/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load prices_i18n %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load materializecss %}{% load utils %}@@ -43,20 +43,11 @@<table class="bordered highlight responsive data-table last-right-align"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Sale (discount) table header" %}- </a>- </th>- {% get_sort_by_toggle 'value' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Discount" context "Sale (discount) table header" %}- </a>- </th>+ {% trans "Name" context "Sale (discount) table header" as label %}+ {% render_sorting_header 'name' label is_wide=True %}++ {% trans "Discount" context "Sale (discount) table header" as label %}+ {% render_sorting_header 'value' label is_wide=True %}</tr></thead><tbody>diff --git a/templates/dashboard/discount/voucher/list.html b/templates/dashboard/discount/voucher/list.htmlindex 20bb8b5e8e..28221e37a5 100644--- a/templates/dashboard/discount/voucher/list.html+++ b/templates/dashboard/discount/voucher/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load prices_i18n %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load materializecss %}{% load utils %}{% load static %}@@ -44,51 +44,27 @@<table class="bordered highlight responsive data-table last-right-align"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Voucher table header" %}- </a>- </th>- {% get_sort_by_toggle 'discount_value' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Discount" context "Voucher table header" %}- </a>- </th>+ {% trans "Name" context "Voucher table header" as label %}+ {% render_sorting_header 'name' label is_wide=True %}++ {% trans "Discount" context "Voucher table header" as label %}+ {% render_sorting_header 'discount_value' label is_wide=True %}+<th>{% trans "Apply to" context "Voucher table header" %}</th>- {% get_sort_by_toggle 'start_date' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Start date" context "Voucher table header" %}- </a>- </th>- {% get_sort_by_toggle 'end_date' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "End date" context "Voucher table header" %}- </a>- </th>- {% get_sort_by_toggle 'used' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Used" context "Voucher table header" %}- </a>- </th>- {% get_sort_by_toggle 'limit' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Limit" context "Voucher table header" %}- </a>- </th>++ {% trans "Start date" context "Voucher table header" as label %}+ {% render_sorting_header 'start_date' label is_wide=True %}++ {% trans "End date" context "Voucher table header" as label %}+ {% render_sorting_header 'end_date' label is_wide=True %}++ {% trans "Used" context "Voucher table header" as label %}+ {% render_sorting_header 'used' label is_wide=True %}++ {% trans "Limit" context "Voucher table header" as label %}+ {% render_sorting_header 'limit' label is_wide=True %}</tr></thead>{% for voucher in vouchers %}diff --git a/templates/dashboard/includes/_orders_table.html b/templates/dashboard/includes/_orders_table.htmlindex be125e5a03..d35b150fec 100644--- a/templates/dashboard/includes/_orders_table.html+++ b/templates/dashboard/includes/_orders_table.html@@ -1,49 +1,27 @@{% load i18n %}{% load prices_i18n %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load status %}<div class="data-table-container"><table class="bordered highlight responsive data-table last-right-align"><thead><tr>- {% get_sort_by_toggle 'pk' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- #- </a>- </th>+ {% render_sorting_header 'pk' '#' %}+<th></th>- {% get_sort_by_toggle 'email' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Customer" context "Orders table header" %}- </a>- </th>- {% get_sort_by_toggle 'created' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Placed on" context "Orders table header" %}- </a>- </th>- {% get_sort_by_toggle 'status' as toggle %}- {% get_sort_by_toggle 'payment_status' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Payment status" context "Orders table header" %}- </a>- </th>- {% get_sort_by_toggle 'total' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Total" context "Orders table header" %}- </a>- </th>++ {% trans "Customer" context "Orders table header" as label %}+ {% render_sorting_header 'email' label %}++ {% trans "Placed on" context "Orders table header" as label %}+ {% render_sorting_header 'created' label %}++ {% trans "Payment status" context "Orders table header" as label %}+ {% render_sorting_header 'payment_status' label %}++ {% trans "Total" context "Orders table header" as label %}+ {% render_sorting_header 'total' label %}</tr></thead><tbody>diff --git a/templates/dashboard/includes/_sorting_header.html b/templates/dashboard/includes/_sorting_header.htmlindex 0787ac57f2..38931f3380 100644--- a/templates/dashboard/includes/_sorting_header.html+++ b/templates/dashboard/includes/_sorting_header.html@@ -1,4 +1,4 @@-<th class="{% if is_active %}active{% endif %}">+<th class="{% if is_wide %}wide{% endif %} {% if is_active %}active{% endif %}"><a href="{{ url }}"><svg data-src="{{ sorting_icon }}" />{{ label }}diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.htmlindex fb9ad5903f..3a74184ea7 100644--- a/templates/dashboard/product/list.html+++ b/templates/dashboard/product/list.html@@ -2,7 +2,7 @@{% load i18n %}{% load prices_i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load product_first_image from product_images %}{% load utils %}@@ -74,20 +74,11 @@<label for="select-all-products"></label></th><th></th>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Products list table header" %}- </a>- </th>- {% get_sort_by_toggle 'price' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Price" context "Products list table header" %}- </a>- </th>+ {% trans "Name" context "Products list table header" as label %}+ {% render_sorting_header 'name' label is_wide=True %}++ {% trans "Price" context "Products list table header" as label %}+ {% render_sorting_header 'price' label is_wide=True %}</tr></thead><tbody>diff --git a/templates/dashboard/product/product_attribute/list.html b/templates/dashboard/product/product_attribute/list.htmlindex 3eb6a921b2..ac63faa574 100644--- a/templates/dashboard/product/product_attribute/list.html+++ b/templates/dashboard/product/product_attribute/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -42,13 +42,8 @@<table class="bordered highlight data-table data-table-description"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Dashboard attributes list table header name" %}- </a>- </th>+ {% trans "Name" context "Dashboard attributes list table header name" as label %}+ {% render_sorting_header 'name' label is_wide=True %}<th>{% trans "Values" context "Dashboard attributes list table header values" %}</th>diff --git a/templates/dashboard/product/product_class/list.html b/templates/dashboard/product/product_class/list.htmlindex c4bb3b0c63..9d3d25709c 100644--- a/templates/dashboard/product/product_class/list.html+++ b/templates/dashboard/product/product_class/list.html@@ -2,7 +2,7 @@{% load i18n %}{% load prices_i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -43,13 +43,9 @@<table class="bordered highlight data-table data-table-description"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Dashboard product types list table header name" %}- </a>- </th>+ {% trans "Name" context "Dashboard product types list table header name" as label %}+ {% render_sorting_header 'name' label is_wide=True %}+<th>{% trans "Product attributes" context "Product type item list text" %}</th>diff --git a/templates/dashboard/product/stock_location/list.html b/templates/dashboard/product/stock_location/list.htmlindex df22b096c3..cc7355631a 100644--- a/templates/dashboard/product/stock_location/list.html+++ b/templates/dashboard/product/stock_location/list.html@@ -1,7 +1,7 @@{% extends 'dashboard/base.html' %}{% load i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -40,13 +40,8 @@<table class="highlight bordered data-table"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Dashboard stock location table header name" %}- </a>- </th>+ {% trans "Name" context "Dashboard stock location table header name" as label %}+ {% render_sorting_header 'name' label is_wide=True %}</tr></thead><tbody>diff --git a/templates/dashboard/shipping/list.html b/templates/dashboard/shipping/list.htmlindex f1534e3b41..e622061a5b 100644--- a/templates/dashboard/shipping/list.html+++ b/templates/dashboard/shipping/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load prices_i18n %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load status %}{% load utils %}{% load static %}@@ -43,13 +43,9 @@<table class="bordered highlight responsive data-table"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="wide {% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Shipping methods table header" %}- </a>- </th>+ {% trans "Name" context "Shipping methods table header" as label %}+ {% render_sorting_header 'name' label is_wide=True %}+<th>{% trans "Price range" context "Shipping methods table header" %}</th>diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.htmlindex 376b5c1ed7..9ca233ee08 100644--- a/templates/dashboard/staff/list.html+++ b/templates/dashboard/staff/list.html@@ -2,7 +2,7 @@{% load i18n %}{% load prices_i18n %}{% load materializecss %}-{% load get_sort_by_toggle from shop %}+{% load render_sorting_header from shop %}{% load staticfiles %}{% load utils %}@@ -43,27 +43,14 @@<table class="bordered highlight responsive data-table"><thead><tr>- {% get_sort_by_toggle 'name' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Name" context "Staff members table header" %}- </a>- </th>- {% get_sort_by_toggle 'email' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Email" context "Staff members table header" %}- </a>- </th>- {% get_sort_by_toggle 'location' as toggle %}- <th class="{% if toggle.is_active %}active{% endif %}">- <a href="{{ toggle.url }}">- <svg data-src="{{ toggle.sorting_icon }}" />- {% trans "Location" context "Staff members table header" %}- </a>- </th>+ {% trans "Name" context "Staff members table header" as label %}+ {% render_sorting_header 'name' label %}++ {% trans "Email" context "Staff members table header" as label %}+ {% render_sorting_header 'email' label %}++ {% trans "Location" context "Staff members table header" as label %}+ {% render_sorting_header 'location' label %}</tr></thead><tbody>