From 6f4dad6f285fc9227a00cef0e27ba07945d16c06 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 11 Dec 2023 11:24:10 +0100 Subject: [PATCH] [FIX] website_slides: do not subscribe portal user Everytime somebody leaves a review, it sends a message to every follower of the subtype "Discussion". Portal users were subscribed without realising it. Issue 1: When subscribing via the controller, a user was subscribed to the "Discussion" subtype instead of "Presentation Published". Issue 2: When requesting access, if there is no responsible for a channel, the activity_schedule method fallback on the current user (portal) and subscribe him to the channel at the same time. If there is no responsible, there is nobody to request access to. Disable the o_wslides_js_channel_enroll to hide the request access popup and skip the activity_schedule if the method was called anyway (i.e. fix for stable without updating the view) DELETE FROM mail_followers_mail_message_subtype_rel r USING mail_followers f, res_users u WHERE u.partner_id=f.partner_id AND r.mail_followers_id=f.id AND r.mail_message_subtype_id=1 AND f.res_model = 'slide.channel' AND u.share = true; closes odoo/odoo#145742 Signed-off-by: Thibault Delavallee (tde) --- addons/website_slides/controllers/main.py | 7 ++++++- addons/website_slides/data/slide_user_demo.xml | 4 ++-- addons/website_slides/models/slide_channel.py | 2 +- .../views/website_slides_templates_course.xml | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 398b18c98df..a8413154fa0 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -938,7 +938,12 @@ class WebsiteSlides(WebsiteProfile): @http.route(['/slides/channel/subscribe'], type='json', auth='user', website=True) def slide_channel_subscribe(self, channel_id): - return request.env['slide.channel'].browse(channel_id).message_subscribe(partner_ids=[request.env.user.partner_id.id]) + # Presentation Published subtype + subtype = request.env.ref("website_slides.mt_channel_slide_published", raise_if_not_found=False) + if subtype: + return request.env['slide.channel'].browse(channel_id).message_subscribe( + partner_ids=[request.env.user.partner_id.id], subtype_ids=subtype.ids) + return True @http.route(['/slides/channel/unsubscribe'], type='json', auth='user', website=True) def slide_channel_unsubscribe(self, channel_id): diff --git a/addons/website_slides/data/slide_user_demo.xml b/addons/website_slides/data/slide_user_demo.xml index 2c12cb64073..3ef88b88309 100644 --- a/addons/website_slides/data/slide_user_demo.xml +++ b/addons/website_slides/data/slide_user_demo.xml @@ -83,7 +83,7 @@ + eval="[ref('website_slides.slide_channel_demo_0_gard_0')], [ref('base.partner_admin'), ref('base.partner_demo')]"/> @@ -200,7 +200,7 @@ + eval="[ref('website_slides.slide_channel_demo_1_gard1')], [ref('base.partner_admin'), ref('base.partner_demo')]"/> diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index 2fd3c465f61..e69c735fd77 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -1123,7 +1123,7 @@ class Channel(models.Model): additional_domain=[('request_partner_id', '=', partner.id)] ).mapped('res_id') for channel in self: - if channel.id not in requested_cids: + if channel.id not in requested_cids and channel.user_id: activities += channel.activity_schedule( 'website_slides.mail_activity_data_access_request', note=_('%s is requesting access to this course.', partner.name), diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 4d15702d5cb..f55848e440f 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -376,7 +376,7 @@ -
Private Course