From 0ddee644d657c1337fa4ddc319b505dec5600d4c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 1 Dec 2014 19:30:57 +0100 Subject: [PATCH] [FIX] website_forum: allow moderators to see misbehaving user profiles This is to help forum moderators to fight against spammers. It was previously difficult as the spammer profile became unreachable as soon as their karma went below 1, even if they had other questions or answers still published. --- addons/website_forum/controllers/main.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 59cb5377b97..9a88eac68c5 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -506,18 +506,27 @@ class WebsiteForum(http.Controller): Data = request.registry["ir.model.data"] user = User.browse(cr, SUPERUSER_ID, user_id, context=context) - if not user.exists() or user.karma < 1: + current_user = User.browse(cr, SUPERUSER_ID, uid, context=context) + + # Users with high karma can see users with karma <= 0 for + # moderation purposes, IFF they have posted something (see below) + if (not user.exists() or + (user.karma < 1 and current_user.karma < forum.karma_unlink_all)): return werkzeug.utils.redirect("/forum/%s" % slug(forum)) values = self._prepare_forum_values(forum=forum, **post) - if user_id != request.session.uid and not user.website_published: - return request.website.render("website_forum.private_profile", values) + # questions and answers by user - user_questions, user_answers = [], [] user_question_ids = Post.search(cr, uid, [ ('parent_id', '=', False), ('forum_id', '=', forum.id), ('create_uid', '=', user.id), ], order='create_date desc', context=context) count_user_questions = len(user_question_ids) + + if (user_id != request.session.uid and not + (user.website_published or + (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)