]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/utils/pagination.py
Fixes the answer count on the question page, makes searched sort by relevance by...
[osqa.git] / forum / utils / pagination.py
index 684992ca3cb595cdab385912bd59a4a0a33cb7a3..393fac0d0a9584aeb700a6bd5142b008fdead540 100644 (file)
@@ -49,6 +49,9 @@ class PaginatorContext(object):
         else:
             self.has_pagesize = False
 
+        self.force_sort = None
+        self.sticky_sort = False
+
 
 
 class labels(object):
@@ -83,10 +86,6 @@ def paginated(request, list_name, context, tpl_context):
     else:
         pagesize = 30
 
-
-
-
-
     try:
         page = int(request.GET.get(labels.PAGE, 1))
     except ValueError:
@@ -99,10 +98,10 @@ def paginated(request, list_name, context, tpl_context):
     if context.has_sort:
         if request.GET.get(labels.SORT, None):
             sort = request.GET[labels.SORT]
-            if session_prefs.get('sticky_sort', False):
+            if context.sticky_sort or session_prefs.get('sticky_sort', False):
                 session_prefs[labels.SORT] = sort
         else:
-            sort = session_prefs.get(labels.SORT, context.default_sort)
+            sort = context.force_sort or session_prefs.get(labels.SORT, context.default_sort)
 
         if not sort in context.sort_methods:
             sort = context.default_sort