summaryrefslogtreecommitdiff
path: root/addons/website_forum/controllers
diff options
context:
space:
mode:
authorjbm-odoo <jbm@odoo.com>2020-01-17 07:51:56 +0000
committerYannick Tivisse <yti@odoo.com>2020-02-28 08:58:43 +0000
commit49d64a8fb1fd79a6e53c3768183f6359d9bee6e4 (patch)
tree1dd92636aeb17c7234bff9dfb1cee9ab37db09ac /addons/website_forum/controllers
parentee519c222f0d1aec3f1b4082bbd76d13dedd07b2 (diff)
[IMP] website_forum: Add privacy
Add privacy on forum: public or private. If private, we must select one group that has access. For forum linked to eLearning course: the privacy of forum is the same as the course. If the course is not yet published, the forum will be invisible (unless we have the group group_website_slides_officer). If a forum linked to a course is unlinked or removed, the forum will become private and his group will be set to group_website_slides_officer. All posts and tags have the same access rules as their linked forum. closes odoo/odoo#43486 Taskid: 2169965 Related: odoo/upgrade#758 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/website_forum/controllers')
-rw-r--r--addons/website_forum/controllers/main.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index 6ad0af1f2f1..e14ab54a73f 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -48,19 +48,26 @@ class WebsiteForum(WebsiteProfile):
return request.render("website_forum.forum_all", {'forums': forums})
@http.route('/forum/new', type='json', auth="user", methods=['POST'], website=True)
- def forum_create(self, forum_name="New Forum", forum_mode="questions", add_menu=False):
- forum_id = request.env['forum.forum'].create({
+ def forum_create(self, forum_name="New Forum", forum_mode="questions", forum_privacy="public", forum_privacy_group=False, add_menu=False):
+ forum = {
'name': forum_name,
'mode': forum_mode,
+ 'privacy': forum_privacy,
'website_id': request.website.id,
- })
+ }
+ if forum_privacy == 'private' and forum_privacy_group:
+ forum['authorized_group_id'] = forum_privacy_group
+ forum_id = request.env['forum.forum'].create(forum)
if add_menu:
- request.env['website.menu'].create({
+ group = [int(forum_privacy_group)] if forum_privacy == 'private' else [request.env.ref('base.group_portal').id, request.env.ref('base.group_user').id]
+ menu_id = request.env['website.menu'].create({
'name': forum_name,
'url': "/forum/%s" % slug(forum_id),
'parent_id': request.website.menu_id.id,
'website_id': request.website.id,
+ 'group_ids': [(6, 0, group)]
})
+ forum_id.menu_id = menu_id
return "/forum/%s" % slug(forum_id)
def sitemap_forum(env, rule, qs):