+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))
+
+
+def feed(request):
+ return RssQuestionFeed(
+ Question.objects.filter_state(deleted=False).order_by('-last_activity_at'),
+ settings.APP_TITLE + _(' - ')+ _('latest questions'),
+ settings.APP_DESCRIPTION,
+ request)(request)
+
+