diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-05-17 16:52:02 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-05-17 16:52:02 -0400 |
commit | ec01ef0d3b0637d5b32a94ff7e554b38497c1d29 (patch) | |
tree | 9aced30c62d3a2d7e248d35e7379497fee41aeb6 | |
parent | 9ab32169cc98e9d03c244cb8c150df33c45bb7a1 (diff) | |
parent | f44de3d77708d86c46428dc2b6e05aaa9c0597a0 (diff) | |
download | askbot-ec01ef0d3b0637d5b32a94ff7e554b38497c1d29.tar.gz askbot-ec01ef0d3b0637d5b32a94ff7e554b38497c1d29.tar.bz2 askbot-ec01ef0d3b0637d5b32a94ff7e554b38497c1d29.zip |
Merge branch 'github'
-rw-r--r-- | askbot/models/question.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/askbot/models/question.py b/askbot/models/question.py index c772804a..8a00a3c3 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -344,7 +344,7 @@ class ThreadManager(BaseQuerySetManager): #a special case: "personalized" main page only == #if followed is the only available scope - #if total number (regardless of users selections) + #if total number (regardless of users selections) #followed questions is < than a pagefull - we should mix in a list of #random questions if askbot_settings.ALL_SCOPE_ENABLED == askbot_settings.UNANSWERED_SCOPE_ENABLED == False: @@ -890,13 +890,17 @@ class Thread(models.Model): thread_posts = thread_posts.filter(groups__in=groups) thread_posts = thread_posts.distinct()#important for >1 group - thread_posts = thread_posts.order_by( - { + order_by_method = { 'latest':'-added_at', 'oldest':'added_at', 'votes':'-points' - }[sort_method] - ) + } + if sort_method in order_by_method: + order_by = order_by_method[sort_method] + else: + order_by = order_by_method['latest'] + + thread_posts = thread_posts.order_by(order_by) #1) collect question, answer and comment posts and list of post id's answers = list() post_map = dict() |