From 29d3f2c3498b7c2d1f2175823afc72ba7984533c Mon Sep 17 00:00:00 2001 From: hernani Date: Thu, 26 May 2011 15:51:37 +0000 Subject: [PATCH 1/1] Fixes a bug in the user profile. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1050 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/readers.py | 9 ++++++--- forum/views/users.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/forum/views/readers.py b/forum/views/readers.py index 6ee2c24..dccb05e 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -160,7 +160,7 @@ def question_list(request, initial, allowIgnoreTags=True, feed_url=None, paginator_context=None, - feed_sort='-added_at'): + feed_sort=('-added_at',)): questions = initial.filter_state(deleted=False) @@ -171,7 +171,8 @@ def question_list(request, initial, page_title = _("Questions") if request.GET.get('type', None) == 'rss': - questions = questions.order_by(feed_sort) + if feed_sort: + questions = questions.order_by(*feed_sort) return RssQuestionFeed(request, questions, page_title, list_description)(request) keywords = "" @@ -218,6 +219,7 @@ def search(request): @decorators.render('questions.html') def question_search(request, keywords): + rank_feed = False can_rank, initial = Question.objects.search(keywords) if can_rank: @@ -225,6 +227,7 @@ def question_search(request, keywords): if isinstance(can_rank, basestring): sort_order = can_rank + rank_feed = True paginator_context = QuestionListPaginatorContext() paginator_context.sort_methods[_('ranking')] = pagination.SimpleSort(_('relevance'), sort_order, _("most relevant questions")) @@ -239,7 +242,7 @@ def question_search(request, keywords): None, _("questions matching '%(keywords)s'") % {'keywords': keywords}, paginator_context=paginator_context, - feed_url=feed_url) + feed_url=feed_url, feed_sort=rank_feed and (can_rank,) or '-added_at') @decorators.render('tags.html', 'tags', _('tags'), weight=100) diff --git a/forum/views/users.py b/forum/views/users.py index 8441f96..0eeb122 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -315,7 +315,7 @@ def user_profile(request, user): Badge.objects.filter(awards__user=user).values('id').annotate(count=Count('cls')).order_by('-count')] return pagination.paginated(request, ( - ('questions', QuestionListPaginatorContext('USER_QUESTION_LIST', _('questions'), 15)), + ('questions', QuestionListPaginatorContext('USER_QUESTION_LIST', _('questions'), default_pagesize=15)), ('answers', UserAnswersPaginatorContext())), { "view_user" : user, "questions" : questions, -- 2.39.5