diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index bb63a423..51ccc07a 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -81,7 +81,10 @@ class WebsiteForum(http.Controller):
@http.route(['/forum'], type='http', auth="public", website=True)
def forum(self, **kwargs):
- forums = request.env['forum.forum'].search([])
+ domain = []
+ if not request.env.user.has_group('website.group_website_designer'):
+ domain += [('website_ids', '!=', False), ('website_ids', 'in', request.website.id)]
+ forums = request.env['forum.forum'].search(domain)
return request.render("website_forum.forum_all", {'forums': forums})
@http.route('/forum/new', type='json', auth="user", methods=['POST'], website=True)
@@ -117,7 +120,7 @@ class WebsiteForum(http.Controller):
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post):
Post = request.env['forum.post']
- domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active')]
+ domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), ('website_id', '=', request.website.id)]
if search:
domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)]
if tag:
@@ -408,6 +411,7 @@ class WebsiteForum(http.Controller):
'name': kwargs.get('post_name'),
'content': kwargs.get('content'),
'content_link': kwargs.get('content_link'),
+ 'website_id': request.website.id,
}
post.write(vals)
question = post.parent_id if post.parent_id else post
@@ -551,9 +555,9 @@ class WebsiteForum(http.Controller):
def users(self, forum, page=1, **searches):
User = request.env['res.users']
step = 30
- tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True)])
+ tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))])
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
- user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True)], limit=step, offset=pager['offset'], order='karma DESC')
+ user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))], limit=step, offset=pager['offset'], order='karma DESC')
# put the users in block of 3 to display them as a table
users = [[] for i in range(len(user_obj) // 3 + 1)]
for index, user in enumerate(user_obj):
@@ -723,7 +727,10 @@ class WebsiteForum(http.Controller):
values['image'] = base64.b64encode(image)
if request.uid == user.id: # the controller allows to edit only its own privacy settings; use partner management for other cases
- values['website_published'] = kwargs.get('website_published') == 'True'
+ if kwargs.get('website_published') == 'True':
+ values['website_ids'] = [(4, request.website.id)]
+ else:
+ values['website_ids'] = [(3, request.website.id)]
user.write(values)
return werkzeug.utils.redirect("/forum/%s/user/%d" % (slug(forum), user.id))
diff --git a/addons/website_forum/data/forum_demo.xml b/addons/website_forum/data/forum_demo.xml
index 47529bdc..3ed5aba0 100644
--- a/addons/website_forum/data/forum_demo.xml
+++ b/addons/website_forum/data/forum_demo.xml
@@ -28,6 +28,7 @@