[FIX] website_slides: limit auto subscription
In order to avoid spam and unwanted notification this commit limits auto subscription on channel when * creating a channel; * automatically telling a channel a new publication has been done; * creating a slide; As being a follower of a slide channel means following its slides user should choose manually to be follower of a channel, notably through the UI. A new way of managing subscription will come with elearning in mind and therefore auto subscription should be limited. Commit linked to task ID 1933820 and PR #30830.
This commit is contained in:
@@ -145,6 +145,10 @@ class Channel(models.Model):
|
||||
if self.visibility == 'public':
|
||||
self.group_ids = False
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
return super(Channel, self.with_context(mail_create_nosubscribe=True)).create(vals)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
res = super(Channel, self).write(vals)
|
||||
|
||||
@@ -234,7 +234,6 @@ class Slide(models.Model):
|
||||
if not self.user_has_groups('website.group_website_publisher'):
|
||||
values['website_published'] = False
|
||||
slide = super(Slide, self).create(values)
|
||||
slide.channel_id.message_subscribe(partner_ids=self.env.user.partner_id.ids)
|
||||
slide._post_publication()
|
||||
return slide
|
||||
|
||||
@@ -325,7 +324,7 @@ class Slide(models.Model):
|
||||
publish_template = slide.channel_id.publish_template_id
|
||||
html_body = publish_template.with_context(base_url=base_url)._render_template(publish_template.body_html, 'slide.slide', slide.id)
|
||||
subject = publish_template._render_template(publish_template.subject, 'slide.slide', slide.id)
|
||||
slide.channel_id.message_post(
|
||||
slide.channel_id.with_context(mail_create_nosubscribe=True).message_post(
|
||||
subject=subject,
|
||||
body=html_body,
|
||||
subtype='website_slides.mt_channel_slide_published',
|
||||
|
||||
Reference in New Issue
Block a user