Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add changes from review

michalf2c4fa2cc57a
diff --git a/saleor/core/templatetags/shop.py b/saleor/core/templatetags/shop.py
index 3f42b28ae4..5635906fa1 100644
--- a/saleor/core/templatetags/shop.py
+++ b/saleor/core/templatetags/shop.py
@@ -33,33 +33,27 @@ def get_sort_by_url(context, field, descending=False):
@register.assignment_tag(takes_context=True)
def get_sort_by_toggle(context, field):
'''
- This templatetag returns data needed for sorting querysets by links.
+ This templatetag returns data needed for sorting querysets by links toggle.
'''
request = context['request']
request_get = request.GET.copy()
sort_by = request_get.get('sort_by')
- arrow_src = ''
- active = ''
+ new_sort_by = field # sort_by param
+ sorting_icon = '' # path to icon indicating applied sorting
+ is_active = False # flag which determines if active sorting is on field
if sort_by:
# toggle existing sort_by
if field == sort_by: # descending sort
new_sort_by = u'-%s' % field
- arrow_src = static('/images/arrow_up_icon.svg')
- active = 'active'
+ sorting_icon = static('/images/arrow_up_icon.svg')
+ is_active = True
else: # ascending sort
- new_sort_by = field
if field == sort_by[1:]:
- arrow_src = static('/images/arrow_down_icon.svg')
- active = 'active'
- else:
- arrow_src = ''
- active = ''
- else:
- # first click on link
- new_sort_by = field # descending sort
+ sorting_icon = static('/images/arrow_down_icon.svg')
+ is_active = True
request_get['sort_by'] = new_sort_by
return {
'url': '%s?%s' % (request.path, request_get.urlencode()),
- 'is_active': active,
- 'arrow_src': arrow_src}
+ 'is_active': is_active,
+ 'sorting_icon': sorting_icon}
diff --git a/saleor/dashboard/category/filters.py b/saleor/dashboard/category/filters.py
index 23f38f8734..b5abcdd71e 100644
--- a/saleor/dashboard/category/filters.py
+++ b/saleor/dashboard/category/filters.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from django_filters import (FilterSet, OrderingFilter)
+from django_filters import OrderingFilter
from django.utils.translation import pgettext_lazy
from ...product.models import Category
diff --git a/saleor/dashboard/customer/filters.py b/saleor/dashboard/customer/filters.py
index 0dbd5851f9..7de4f63e64 100644
--- a/saleor/dashboard/customer/filters.py
+++ b/saleor/dashboard/customer/filters.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django_filters import (
- CharFilter, ChoiceFilter, FilterSet, OrderingFilter)
+ CharFilter, ChoiceFilter, OrderingFilter)
from ...core.utils.filters import filter_by_customer, filter_by_location
from django.utils.translation import pgettext_lazy
from django import forms
diff --git a/saleor/dashboard/discount/filters.py b/saleor/dashboard/discount/filters.py
index 991a66041f..1e6b559cf7 100644
--- a/saleor/dashboard/discount/filters.py
+++ b/saleor/dashboard/discount/filters.py
@@ -1,8 +1,8 @@
from __future__ import unicode_literals
from django_filters import (
- CharFilter, ChoiceFilter, DateFromToRangeFilter, FilterSet,
- ModelMultipleChoiceFilter, OrderingFilter, RangeFilter)
+ CharFilter, ChoiceFilter, DateFromToRangeFilter, ModelMultipleChoiceFilter,
+ OrderingFilter, RangeFilter)
from django.utils.translation import pgettext_lazy
from django import forms
diff --git a/saleor/dashboard/group/filters.py b/saleor/dashboard/group/filters.py
index b468f3d872..15ad50b80c 100644
--- a/saleor/dashboard/group/filters.py
+++ b/saleor/dashboard/group/filters.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.contrib.auth.models import Group
from django_filters import (
- CharFilter, FilterSet, ModelMultipleChoiceFilter, OrderingFilter)
+ CharFilter, ModelMultipleChoiceFilter, OrderingFilter)
from django.utils.translation import pgettext_lazy
from ...core.permissions import get_permissions
diff --git a/saleor/dashboard/order/filters.py b/saleor/dashboard/order/filters.py
index 2733f816d3..3b20632d02 100644
--- a/saleor/dashboard/order/filters.py
+++ b/saleor/dashboard/order/filters.py
@@ -1,8 +1,8 @@
from __future__ import unicode_literals
from django_filters import (
- CharFilter, ChoiceFilter, DateFromToRangeFilter, FilterSet, NumberFilter,
- RangeFilter, OrderingFilter)
+ CharFilter, ChoiceFilter, DateFromToRangeFilter, NumberFilter, RangeFilter,
+ OrderingFilter)
from django import forms
from django.utils.translation import pgettext_lazy
from payments import PaymentStatus
diff --git a/saleor/dashboard/product/filters.py b/saleor/dashboard/product/filters.py
index c0c67b2774..f42d12cad8 100644
--- a/saleor/dashboard/product/filters.py
+++ b/saleor/dashboard/product/filters.py
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
from django import forms
from django.utils.translation import pgettext_lazy
from django_filters import (
- CharFilter, ChoiceFilter, FilterSet, ModelMultipleChoiceFilter,
- RangeFilter, OrderingFilter)
+ CharFilter, ChoiceFilter, ModelMultipleChoiceFilter, RangeFilter,
+ OrderingFilter)
from ...product.models import (
Category, Product, ProductAttribute, ProductClass, StockLocation)
diff --git a/saleor/dashboard/shipping/filters.py b/saleor/dashboard/shipping/filters.py
index 538760c8e7..854e41b4fd 100644
--- a/saleor/dashboard/shipping/filters.py
+++ b/saleor/dashboard/shipping/filters.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django_filters import (
- FilterSet, CharFilter, ChoiceFilter, OrderingFilter, RangeFilter)
+ CharFilter, ChoiceFilter, OrderingFilter, RangeFilter)
from django.utils.translation import pgettext_lazy
from ...shipping.models import COUNTRY_CODE_CHOICES, ShippingMethod
diff --git a/saleor/dashboard/staff/filters.py b/saleor/dashboard/staff/filters.py
index a7efdd879a..446c8dc26a 100644
--- a/saleor/dashboard/staff/filters.py
+++ b/saleor/dashboard/staff/filters.py
@@ -1,8 +1,7 @@
from __future__ import unicode_literals
from django_filters import (
- CharFilter, ChoiceFilter, FilterSet, ModelMultipleChoiceFilter,
- OrderingFilter)
+ CharFilter, ChoiceFilter, ModelMultipleChoiceFilter, OrderingFilter)
from django.contrib.auth.models import Group
from django.utils.translation import pgettext_lazy
from django import forms
diff --git a/templates/dashboard/category/list.html b/templates/dashboard/category/list.html
index 276e9db3a0..505fb85caa 100644
--- a/templates/dashboard/category/list.html
+++ b/templates/dashboard/category/list.html
@@ -117,16 +117,16 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <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 {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Description" context "Category list table header description" %}
</a>
</th>
diff --git a/templates/dashboard/customer/list.html b/templates/dashboard/customer/list.html
index b599337ad3..602b7a1c7d 100644
--- a/templates/dashboard/customer/list.html
+++ b/templates/dashboard/customer/list.html
@@ -31,23 +31,23 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Customers table header" %}
</a>
</th>
{% get_sort_by_toggle 'email' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Email" context "Customers table header" %}
</a>
</th>
{% get_sort_by_toggle 'location' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Location" context "Customers table header" %}
</a>
</th>
diff --git a/templates/dashboard/discount/sale/list.html b/templates/dashboard/discount/sale/list.html
index 3df04fc755..2a906d4532 100644
--- a/templates/dashboard/discount/sale/list.html
+++ b/templates/dashboard/discount/sale/list.html
@@ -47,17 +47,18 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <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 {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
- {% trans "Discount" context "Sale (discount) table header" %}
+ <svg data-src="{{ toggle.sorting_icon }}" />
+ {% trans "Discount" context "Sale (discount) table header" %}
+ </a>
</th>
</tr>
</thead>
diff --git a/templates/dashboard/discount/voucher/list.html b/templates/dashboard/discount/voucher/list.html
index 75dd4fb05e..0907099a94 100644
--- a/templates/dashboard/discount/voucher/list.html
+++ b/templates/dashboard/discount/voucher/list.html
@@ -49,16 +49,16 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
- <a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
- {% trans "Name" context "Voucher table header" %}
- </a>
+ <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 {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Discount" context "Voucher table header" %}
</a>
</th>
@@ -66,30 +66,30 @@
{% trans "Apply to" context "Voucher table header" %}
</th>
{% get_sort_by_toggle 'start_date' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <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 {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <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 {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Used" context "Voucher table header" %}
</a>
</th>
{% get_sort_by_toggle 'limit' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Limit" context "Voucher table header" %}
</a>
</th>
diff --git a/templates/dashboard/group/list.html b/templates/dashboard/group/list.html
index be4bc4e482..b6d899db16 100644
--- a/templates/dashboard/group/list.html
+++ b/templates/dashboard/group/list.html
@@ -44,9 +44,9 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Dashboard groups list table header name" %}
</a>
</th>
diff --git a/templates/dashboard/includes/_orders_table.html b/templates/dashboard/includes/_orders_table.html
index 93058f8981..facf9ebf20 100644
--- a/templates/dashboard/includes/_orders_table.html
+++ b/templates/dashboard/includes/_orders_table.html
@@ -8,44 +8,44 @@
<thead>
<tr>
{% get_sort_by_toggle 'pk' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
#
</a>
</th>
{% get_sort_by_toggle 'email' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Customer" context "Orders table header" %}
</a>
</th>
{% get_sort_by_toggle 'created' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Placed on" context "Orders table header" %}
</a>
</th>
{% get_sort_by_toggle 'status' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Order status" context "Orders table header" %}
</a>
</th>
{% get_sort_by_toggle 'payment_status' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Payment status" context "Orders table header" %}
</a>
</th>
{% get_sort_by_toggle 'total' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Total" context "Orders table header" %}
</a>
</th>
diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.html
index b074043885..b38c01a7c2 100644
--- a/templates/dashboard/product/list.html
+++ b/templates/dashboard/product/list.html
@@ -75,16 +75,16 @@
</th>
<th></th>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Products list table header" %}
</a>
</th>
{% get_sort_by_toggle 'price' as toggle %}
- <th class="right-align {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Price" context "Products list table header" %}
</a>
</th>
diff --git a/templates/dashboard/product/product_attribute/list.html b/templates/dashboard/product/product_attribute/list.html
index 66a195d58a..f39448182e 100644
--- a/templates/dashboard/product/product_attribute/list.html
+++ b/templates/dashboard/product/product_attribute/list.html
@@ -43,9 +43,9 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Dashboard attributes list table header name" %}
</a>
</th>
diff --git a/templates/dashboard/product/product_class/list.html b/templates/dashboard/product/product_class/list.html
index d161c573b2..8d91537f66 100644
--- a/templates/dashboard/product/product_class/list.html
+++ b/templates/dashboard/product/product_class/list.html
@@ -44,9 +44,9 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Dashboard product types list table header name" %}
</a>
</th>
diff --git a/templates/dashboard/product/stock_location/list.html b/templates/dashboard/product/stock_location/list.html
index 388458f912..335bd8e81a 100644
--- a/templates/dashboard/product/stock_location/list.html
+++ b/templates/dashboard/product/stock_location/list.html
@@ -41,9 +41,9 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Dashboard stock location table header name" %}
</a>
</th>
diff --git a/templates/dashboard/shipping/list.html b/templates/dashboard/shipping/list.html
index 3d8fe05a1d..54d0efd708 100644
--- a/templates/dashboard/shipping/list.html
+++ b/templates/dashboard/shipping/list.html
@@ -41,9 +41,9 @@
<thead>
<tr>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Shipping methods table header" %}
</a>
</th>
diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.html
index 0d852ad4d1..23c70be26a 100644
--- a/templates/dashboard/staff/list.html
+++ b/templates/dashboard/staff/list.html
@@ -44,23 +44,23 @@
<thead>
<tr>
{% get_sort_by_toggle 'email' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Email" context "Staff members table header" %}
</a>
</th>
{% get_sort_by_toggle 'name' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Name" context "Staff members table header" %}
</a>
</th>
{% get_sort_by_toggle 'location' as toggle %}
- <th class="wide {{ toggle.is_active }}">
+ <th class="wide {% if toggle.is_active %}active{% endif %}">
<a href="{{ toggle.url }}">
- <svg data-src="{{ toggle.arrow_src }}" />
+ <svg data-src="{{ toggle.sorting_icon }}" />
{% trans "Location" context "Staff members table header" %}
</a>
</th>