소스 검색

Enable sorting by order number in template. Add django-sorting as a requirement

master
Asia Biega 13 년 전
부모
커밋
de23e84758
6개의 변경된 파일48개의 추가작업 그리고 4개의 파일을 삭제
  1. 3
    1
      oscar/__init__.py
  2. 4
    2
      oscar/templates/catalogue/partials/pagination.html
  3. 2
    1
      oscar/templates/dashboard/orders/order_list.html
  4. 37
    0
      oscar/templatetags/display_tags.py
  5. 1
    0
      requirements.txt
  6. 1
    0
      setup.py

+ 3
- 1
oscar/__init__.py 파일 보기

@@ -4,7 +4,7 @@ import os
4 4
 # a full release
5 5
 
6 6
 VERSION = (0, 2, 0, 'beta', 1)
7
-    
7
+
8 8
 def get_short_version():
9 9
     return '%s.%s' % (VERSION[0], VERSION[1])
10 10
 
@@ -57,6 +57,8 @@ OSCAR_CORE_APPS = [
57 57
     'oscar.apps.dashboard.offers',
58 58
     'oscar.apps.dashboard.ranges',
59 59
     'oscar.apps.dashboard.vouchers',
60
+
61
+    'django_sorting',
60 62
 ]
61 63
 
62 64
 

+ 4
- 2
oscar/templates/catalogue/partials/pagination.html 파일 보기

@@ -1,11 +1,13 @@
1
+{% load display_tags %}
2
+
1 3
 <div>
2 4
     <ul class="pager">
3 5
         {% if page_obj.has_previous %}
4
-        <li class="previous"><a href="?page={{ page_obj.previous_page_number }}">previous</a></li>
6
+        <li class="previous"><a href="?{% get_parameters page %}page={{ page_obj.previous_page_number }}">previous</a></li>
5 7
         {% endif %}
6 8
         <li class="current">Page {{ page_obj.number }} of {{ paginator.num_pages }}</li>
7 9
         {% if page_obj.has_next %}
8
-        <li class="next"><a href="?page={{ page_obj.next_page_number }}">next</a></li>
10
+        <li class="next"><a href="?{% get_parameters page %}page={{ page_obj.next_page_number }}">next</a></li>
9 11
         {% endif %}
10 12
     </ul>
11 13
 </div>

+ 2
- 1
oscar/templates/dashboard/orders/order_list.html 파일 보기

@@ -1,5 +1,6 @@
1 1
 {% extends 'dashboard/layout.html' %}
2 2
 {% load currency_filters %}
3
+{% load sorting_tags %}
3 4
 {% block body_class %}orders{% endblock %}
4 5
 {% block title %}
5 6
 Order management | {{ block.super }}
@@ -81,7 +82,7 @@ Order management | {{ block.super }}
81 82
 <table class="table table-striped table-bordered">
82 83
     <tr>
83 84
         <th></th>
84
-        <th>Order number</th>
85
+        <th>{% anchor 'number' 'Order number' %}</th>
85 86
         <th>Total inc tax</th>
86 87
         <th>Date of purchase</th>
87 88
         <th>Number of items</th>

+ 37
- 0
oscar/templatetags/display_tags.py 파일 보기

@@ -0,0 +1,37 @@
1
+from django import template
2
+
3
+register = template.Library()
4
+
5
+def get_parameters(parser, token):
6
+    """
7
+        {% get_parameters except_field %}
8
+    """
9
+
10
+    args = token.split_contents()
11
+    if len(args) < 2:
12
+        raise template.TemplateSyntaxError, "get_parameters tag takes at least 1 argument"
13
+    return GetParametersNode(args[1].strip())
14
+
15
+
16
+class GetParametersNode(template.Node):
17
+    """
18
+        Renders current get parameters except for the specified parameter
19
+    """
20
+    def __init__(self, field):
21
+        self.field = field
22
+
23
+    def render(self, context):
24
+        request = context['request']
25
+        getvars = request.GET.copy()
26
+
27
+        if self.field in getvars:
28
+            del getvars[self.field]
29
+
30
+        if len(getvars.keys()) > 0:
31
+            get_params = "%s&" % getvars.urlencode()
32
+        else:
33
+            get_params = ''
34
+
35
+        return get_params
36
+
37
+get_parameters = register.tag(get_parameters)

+ 1
- 0
requirements.txt 파일 보기

@@ -13,3 +13,4 @@ twill==0.9
13 13
 PyHamcrest==1.6
14 14
 South==0.7.3
15 15
 purl==0.3.2
16
+django-sorting==0.1

+ 1
- 0
setup.py 파일 보기

@@ -33,6 +33,7 @@ setup(name='django-oscar',
33 33
           'django-treebeard==1.61',
34 34
           'sorl-thumbnail==11.12',
35 35
           'python-memcached==1.48',
36
+          'django-sorting==0.1',
36 37
           ],
37 38
       # See http://pypi.python.org/pypi?%3Aaction=list_classifiers
38 39
       classifiers=['Environment :: Web Environment',

Loading…
취소
저장