From 64da3c5e176f3e3904ac551674922caa7633d684 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sat, 7 Mar 2015 02:31:24 +0100 Subject: [PATCH] [FIX] website_forum: hide questions coming from abusive users When a user's karma is driven to a negative value due to repeated abuse or the posting of spam, automatically hide all their posts from public view. This will reduce the effectiveness of their abuse, and simplify moderation and cleanup. --- addons/website_forum/controllers/main.py | 6 ++++++ addons/website_forum/models/forum.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index bce1e3a9515..7a8c9fc27cd 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import werkzeug.exceptions import werkzeug.urls import werkzeug.wrappers import simplejson @@ -239,6 +240,11 @@ class WebsiteForum(http.Controller): @http.route(['''/forum//question/= res[post.id]['karma_downvote'], 'can_comment': uid == SUPERUSER_ID or user.karma >= res[post.id]['karma_comment'], 'can_comment_convert': uid == SUPERUSER_ID or user.karma >= res[post.id]['karma_comment_convert'], + 'can_view': (uid == SUPERUSER_ID or + user.karma >= res[post.id]['karma_close'] or + post.create_uid.karma > 0), }) return res @@ -335,6 +338,7 @@ class Post(osv.Model): 'can_downvote': fields.function(_get_post_karma_rights, string='Can Downvote', type='boolean', multi='_get_post_karma_rights'), 'can_comment': fields.function(_get_post_karma_rights, string='Can Comment', type='boolean', multi='_get_post_karma_rights'), 'can_comment_convert': fields.function(_get_post_karma_rights, string='Can Convert to Comment', type='boolean', multi='_get_post_karma_rights'), + 'can_view': fields.function(_get_post_karma_rights, string='Can View', type='boolean', multi='_get_post_karma_rights'), } _defaults = {