(_('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):