diff options
Diffstat (limited to 'saleor')
-rw-r--r-- | saleor/core/templatetags/shop.py | 13 | ||||
-rw-r--r-- | saleor/product/views.py | 5 |
2 files changed, 4 insertions, 14 deletions
diff --git a/saleor/core/templatetags/shop.py b/saleor/core/templatetags/shop.py index 78273c64..598baa6e 100644 --- a/saleor/core/templatetags/shop.py +++ b/saleor/core/templatetags/shop.py @@ -7,7 +7,6 @@ except ImportError: from django.template import Library from django.utils.http import urlencode -from ...product.filters import DEFAULT_SORT register = Library() @@ -28,15 +27,3 @@ def get_sort_by_url(context, field, descending=False): else: request_get['sort_by'] = field return '%s?%s' % (request.path, urlencode(request_get)) - - -@register.inclusion_tag('category/_sort_by.html', takes_context=True) -def sort_by(context, attributes): - ctx = { - 'request': context['request'], - 'sort_by': (context['request'].GET.get('sort_by', DEFAULT_SORT) - .strip('-')), - 'sort_by_choices': attributes, - 'arrow_down': (context['request'].GET.get('sort_by', DEFAULT_SORT) - .startswith('-'))} - return ctx diff --git a/saleor/product/views.py b/saleor/product/views.py index 3581c867..1a793226 100644 --- a/saleor/product/views.py +++ b/saleor/product/views.py @@ -127,8 +127,11 @@ def category_index(request, path, category_id): product_filter.qs, PAGINATE_BY, request.GET.get('page')) products_and_availability = list(products_with_availability( products_paginated, request.discounts, request.currency)) + sort_by = request.GET.get('sort_by', DEFAULT_SORT) ctx = {'category': category, 'filter': product_filter, 'products': products_and_availability, 'products_paginated': products_paginated, - 'sort_by_choices': SORT_BY_FIELDS} + 'sort_by_choices': SORT_BY_FIELDS, + 'sort_by_label': sort_by.strip('-'), + 'is_descending': sort_by.startswith('-')} return TemplateResponse(request, 'category/index.html', ctx) |