+class QuestionListPaginatorContext(pagination.PaginatorContext):
+ def __init__(self):
+ super (QuestionListPaginatorContext, self).__init__('QUESTIONS_LIST', sort_methods=(
+ (_('active'), pagination.SimpleSort(_('active'), '-last_activity_at', _("most recently updated questions"))),
+ (_('newest'), pagination.SimpleSort(_('newest'), '-added_at', _("most recently asked questions"))),
+ (_('hottest'), pagination.SimpleSort(_('hottest'), '-extra_count', _("hottest questions"))),
+ (_('mostvoted'), pagination.SimpleSort(_('most voted'), '-score', _("most voted questions"))),
+ ), pagesizes=(15, 30, 50))
+
+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):
+ super (AnswerPaginatorContext, self).__init__('ANSWER_LIST', 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"))),
+ ), default_sort=_('votes'), sticky_sort = True, pagesizes=(5, 10, 20))
+
+class TagPaginatorContext(pagination.PaginatorContext):
+ def __init__(self):
+ super (TagPaginatorContext, self).__init__('TAG_LIST', sort_methods=(
+ (_('name'), pagination.SimpleSort(_('by name'), 'name', _("sorted alphabetically"))),
+ (_('used'), pagination.SimpleSort(_('by popularity'), '-used_count', _("sorted by frequency of tag use"))),
+ ), default_sort=_('used'), pagesizes=(30, 60, 120))
+