From: Olivier Dony Date: Mon, 1 Dec 2014 18:30:57 +0000 (+0100) Subject: [FIX] website_forum: allow moderators to see misbehaving user profiles X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=0ddee644d657c1337fa4ddc319b505dec5600d4c;p=odoo%2Fodoo.git [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. --- diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 59cb537..9a88eac 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)