Skip to content

Commit

Permalink
Enable sorting by order number in template. Add django-sorting as a r…
Browse files Browse the repository at this point in the history
…equirement
  • Loading branch information
asiabiega committed May 29, 2012
1 parent a818590 commit 38bc5b4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
4 changes: 3 additions & 1 deletion oscar/__init__.py
Expand Up @@ -4,7 +4,7 @@
# a full release

VERSION = (0, 2, 0, 'RC', 1)

def get_short_version():
return '%s.%s' % (VERSION[0], VERSION[1])

Expand Down Expand Up @@ -56,6 +56,8 @@ def get_version():
'oscar.apps.dashboard.offers',
'oscar.apps.dashboard.ranges',
'oscar.apps.dashboard.vouchers',

'django_sorting',
]


Expand Down
6 changes: 4 additions & 2 deletions oscar/templates/catalogue/partials/pagination.html
@@ -1,11 +1,13 @@
{% load display_tags %}

<div>
<ul class="pager">
{% if page_obj.has_previous %}
<li class="previous"><a href="?page={{ page_obj.previous_page_number }}">previous</a></li>
<li class="previous"><a href="?{% get_parameters page %}page={{ page_obj.previous_page_number }}">previous</a></li>
{% endif %}
<li class="current">Page {{ page_obj.number }} of {{ paginator.num_pages }}</li>
{% if page_obj.has_next %}
<li class="next"><a href="?page={{ page_obj.next_page_number }}">next</a></li>
<li class="next"><a href="?{% get_parameters page %}page={{ page_obj.next_page_number }}">next</a></li>
{% endif %}
</ul>
</div>
3 changes: 2 additions & 1 deletion oscar/templates/dashboard/orders/order_list.html
@@ -1,5 +1,6 @@
{% extends 'dashboard/layout.html' %}
{% load currency_filters %}
{% load sorting_tags %}
{% block body_class %}orders{% endblock %}
{% block title %}
Order management | {{ block.super }}
Expand Down Expand Up @@ -81,7 +82,7 @@ <h2>{{ queryset_description }}</h2>
<table class="table table-striped table-bordered">
<tr>
<th></th>
<th>Order number</th>
<th>{% anchor 'number' 'Order number' %}</th>
<th>Total inc tax</th>
<th>Date of purchase</th>
<th>Number of items</th>
Expand Down
37 changes: 37 additions & 0 deletions oscar/templatetags/display_tags.py
@@ -0,0 +1,37 @@
from django import template

register = template.Library()

def get_parameters(parser, token):
"""
{% get_parameters except_field %}
"""

args = token.split_contents()
if len(args) < 2:
raise template.TemplateSyntaxError, "get_parameters tag takes at least 1 argument"
return GetParametersNode(args[1].strip())


class GetParametersNode(template.Node):
"""
Renders current get parameters except for the specified parameter
"""
def __init__(self, field):
self.field = field

def render(self, context):
request = context['request']
getvars = request.GET.copy()

if self.field in getvars:
del getvars[self.field]

if len(getvars.keys()) > 0:
get_params = "%s&" % getvars.urlencode()
else:
get_params = ''

return get_params

get_parameters = register.tag(get_parameters)
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -13,3 +13,4 @@ twill==0.9
PyHamcrest==1.6
South==0.7.3
purl==0.3.2
django-sorting==0.1
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -33,6 +33,7 @@
'django-treebeard==1.61',
'sorl-thumbnail==11.12',
'python-memcached==1.48',
'django-sorting==0.1',
],
# See http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=['Environment :: Web Environment',
Expand Down

0 comments on commit 38bc5b4

Please sign in to comment.