diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py
index 752a1527d31..d840bb93784 100644
--- a/addons/website/models/ir_qweb.py
+++ b/addons/website/models/ir_qweb.py
@@ -290,13 +290,6 @@ class HTML(orm.AbstractModel):
for child in element.iterchildren(tag=etree.Element))
return '\n'.join(content)
- def value_to_html(self, cr, uid, value, column, options=None, context=None):
- if options and options.get("nofollow") and value:
- base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url', context=context)
- for match in re.findall(r'' % base_url, value):
- value = re.sub(match, match[:3] + 'rel="nofollow" ' + match[3:], value)
- return super(HTML, self).value_to_html(cr, uid, value, column, options, context=context)
-
class Image(orm.AbstractModel):
"""
Widget options:
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py
index 6c517ce3a44..a04531745bd 100644
--- a/addons/website_forum/models/forum.py
+++ b/addons/website_forum/models/forum.py
@@ -3,6 +3,7 @@
from datetime import datetime
import logging
import math
+import re
import uuid
from werkzeug.exceptions import Forbidden
@@ -278,8 +279,18 @@ class Post(models.Model):
self.can_comment = user.karma >= self.karma_comment
self.can_comment_convert = user.karma >= self.karma_comment_convert
+ def _update_content(self, content, forum_id):
+ forum = self.env['forum.forum'].browse(forum_id)
+ if content and self.env.user.karma < forum.karma_dofollow:
+ for match in re.findall(r'', content):
+ content = re.sub(match, match[:3] + 'rel="nofollow" ' + match[3:], content)
+ return content
+
@api.model
def create(self, vals):
+ if 'content' in vals and vals.get('forum_id'):
+ vals['content'] = self._update_content(vals['content'], vals['forum_id'])
+
post = super(Post, self.with_context(mail_create_nolog=True)).create(vals)
# deleted or closed questions
if post.parent_id and (post.parent_id.state == 'close' or post.parent_id.active is False):
@@ -308,6 +319,8 @@ class Post(models.Model):
@api.multi
def write(self, vals):
+ if 'content' in vals:
+ vals['content'] = self._update_content(vals['content'], self.forum_id.id)
if 'state' in vals:
if vals['state'] in ['active', 'close'] and any(not post.can_close for post in self):
raise KarmaError('Not enough karma to close or reopen a post.')
diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml
index d6f85b9efb1..a9bb1cf8bb6 100644
--- a/addons/website_forum/views/website_forum.xml
+++ b/addons/website_forum/views/website_forum.xml
@@ -637,8 +637,7 @@
-
-
+
@@ -738,8 +737,7 @@
style="display: inline-block;"/>
On
-
-
+
-
@@ -818,8 +816,7 @@
-
-
+
@@ -1107,8 +1104,7 @@