[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) <tde@openerp.com>
This commit is contained in:
Martin Trigaux
2024-01-20 02:42:51 +00:00
parent 2ecbfdb363
commit 6f4dad6f28
4 changed files with 10 additions and 5 deletions
+6 -1
View File
@@ -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):
@@ -83,7 +83,7 @@
</record>
<function model="slide.channel" name="message_subscribe"
eval="[ref('website_slides.slide_channel_demo_0_gard_0')], [ref('base.partner_admin'), ref('base.partner_demo'), ref('base.partner_demo_portal')]"/>
eval="[ref('website_slides.slide_channel_demo_0_gard_0')], [ref('base.partner_admin'), ref('base.partner_demo')]"/>
<!-- CHANNEL 1: Taking care of Trees -->
<!-- ================================================== -->
@@ -200,7 +200,7 @@
</record>
<function model="slide.channel" name="message_subscribe"
eval="[ref('website_slides.slide_channel_demo_1_gard1')], [ref('base.partner_admin'), ref('base.partner_demo'), ref('base.partner_demo_portal')]"/>
eval="[ref('website_slides.slide_channel_demo_1_gard1')], [ref('base.partner_admin'), ref('base.partner_demo')]"/>
<!-- CHANNEL 2: Trees, Wood and Garden -->
@@ -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=_('<b>%s</b> is requesting access to this course.', partner.name),
@@ -376,7 +376,7 @@
</div>
</div>
</div>
<div t-else="" t-attf-class="alert my-0 bg-100 p-2 #{'o_wslides_js_channel_enroll' if not is_public_user else ''}"
<div t-else="" t-attf-class="alert my-0 bg-100 p-2 #{'o_wslides_js_channel_enroll' if not is_public_user and channel.user_id else ''}"
t-att-data-channel-id="channel.id">
Private Course
<div t-if="is_public_user">