]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/readers.py
Improves the answer position guessing.
[osqa.git] / forum / views / readers.py
index a60db45b2ea6735326b011618df9683dc3f4219c..4bdb58bc9a438e3d0722a4446f8011c45ec76bba 100644 (file)
@@ -40,19 +40,12 @@ class QuestionListPaginatorContext(pagination.PaginatorContext):
             (_('mostvoted'), pagination.SimpleSort(_('most voted'), '-score', _("most voted questions"))),
         ), pagesizes=(15, 30, 50), default_pagesize=default_pagesize, prefix=prefix)
 
-class AnswerSort(pagination.SimpleSort):
-    def apply(self, objects):
-        if self.label == _('votes'):
-            return objects.order_by('-marked', self.order_by, 'added_at')
-        else:
-            return objects.order_by('-marked', self.order_by)
-
 class AnswerPaginatorContext(pagination.PaginatorContext):
     def __init__(self, id='ANSWER_LIST', prefix='', default_pagesize=10):
         super (AnswerPaginatorContext, self).__init__(id, sort_methods=(
-            (_('oldest'), AnswerSort(_('oldest answers'), 'added_at', _("oldest answers will be shown first"))),
-            (_('newest'), AnswerSort(_('newest answers'), '-added_at', _("newest answers will be shown first"))),
-            (_('votes'), AnswerSort(_('popular answers'), '-score', _("most voted answers will be shown first"))),
+            (_('oldest'), pagination.SimpleSort(_('oldest answers'), ('-marked', 'added_at'), _("oldest answers will be shown first"))),
+            (_('newest'), pagination.SimpleSort(_('newest answers'), ('-marked', '-added_at'), _("newest answers will be shown first"))),
+            (_('votes'), pagination.SimpleSort(_('popular answers'), ('-marked', '-score', 'added_at'), _("most voted answers will be shown first"))),
         ), default_sort=_('votes'), sticky_sort = True, pagesizes=(5, 10, 20), default_pagesize=default_pagesize, prefix=prefix)
 
 class TagPaginatorContext(pagination.PaginatorContext):