Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Refactor sort_menu.py
michal85f866918098
diff --git a/saleor/product/filters.py b/saleor/product/filters.pyindex 93b5a6813d..3749768f26 100644--- a/saleor/product/filters.py+++ b/saleor/product/filters.py@@ -10,8 +10,6 @@ from django_prices.models import PriceFieldfrom .models import Product, ProductAttribute-# SORT_BY_FIELDS = (('name', pgettext_lazy('Sort by filter', 'name')),-# ('price', pgettext_lazy()))SORT_BY_FIELDS = [{'value': 'name','label': pgettext_lazy('Sort by filter', 'name')},diff --git a/saleor/product/templatetags/sort_menu.py b/saleor/product/templatetags/sort_menu.pyindex 0d78026939..46806cc0b1 100644--- a/saleor/product/templatetags/sort_menu.py+++ b/saleor/product/templatetags/sort_menu.py@@ -5,14 +5,9 @@ register = template.Library()@register.inclusion_tag('category/_sort_menu.html', takes_context=True)def sort_menu(context, attributes):- ordering_options = []- for attr in [a['value'] for a in attributes]:- ordering_options.append(attr)- ordering_options.append('-' + str(attr))- choices = [a['label'] for a in attributes]+ context['sort_by'] = \+ context['request'].GET.get('sort_by', 'name').strip('-')context['sort_by_choices'] = attributes- get_sort_by = context['request'].GET.get('sort_by', 'name')- context['choice'] = choices[int(ordering_options.index(get_sort_by) / 2)]- context['arrow_up'] = \- (context['request'].GET.get('sort_by', 'name')[0] != '-')+ context['arrow_down'] = \+ (context['request'].GET.get('sort_by', 'name').startswith('-'))return contextdiff --git a/templates/category/_sort_menu.html b/templates/category/_sort_menu.htmlindex 185aa882c3..420474abb7 100644--- a/templates/category/_sort_menu.html+++ b/templates/category/_sort_menu.html@@ -10,14 +10,14 @@<span>Sort by: <strong>- {{ choice }}+ {{ sort_by }}</strong></span><div class="sort-order-icon">- {% if arrow_up %}- <svg data-src="{% static "assets/arrow_up.svg" %}">- {% else %}+ {% if arrow_down %}<svg data-src="{% static "assets/arrow_down.svg" %}">+ {% else %}+ <svg data-src="{% static "assets/arrow_up.svg" %}">{% endif %}</div></div>