From 809af8ba09a9effc7934113d31fa037e40fc4352 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 19 Jan 2015 17:33:57 +0100 Subject: [PATCH] [FIX] website_forum: no limit on user post list for moderators The limit on the list of answers and questions posted by a given forum user is purposely limited to reduce the performance penalty for displaying them all. (see 78fa86193612e6831453bba003a8045a7d3b7c6c) However seeing the full list is useful for forum moderators (e.g. when tracking down abuse), and there are only a few such users with high karma, so enabling it for them is negligible performance-wise. Fixes #3955 --- addons/website_forum/controllers/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index d9411fb12c9..bce1e3a9515 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -528,16 +528,19 @@ class WebsiteForum(http.Controller): (count_user_questions and current_user.karma > forum.karma_unlink_all))): return request.website.render("website_forum.private_profile", values) - # displaying only the 20 most recent questions - user_questions = Post.browse(cr, uid, user_question_ids[:20], context=context) + # limit length of visible posts by default for performance reasons, except for the high + # karma users (not many of them, and they need it to properly moderate the forum) + post_display_limit = None + if current_user.karma < forum.karma_unlink_all: + post_display_limit = 20 + user_questions = Post.browse(cr, uid, user_question_ids[:post_display_limit], context=context) user_answer_ids = Post.search(cr, uid, [ ('parent_id', '!=', False), ('forum_id', '=', forum.id), ('create_uid', '=', user.id), ], order='create_date desc', context=context) count_user_answers = len(user_answer_ids) - # displaying only the 20 most recent answers - user_answers = Post.browse(cr, uid, user_answer_ids[:20], context=context) + user_answers = Post.browse(cr, uid, user_answer_ids[:post_display_limit], context=context) # showing questions which user following obj_ids = Followers.search(cr, SUPERUSER_ID, [('res_model', '=', 'forum.post'), ('partner_id', '=', user.partner_id.id)], context=context)