From fadb3e155e8a9602d62fd2293eaf9f227ce2ec1c Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 22 Jun 2018 16:18:45 +0200 Subject: [PATCH] [FIX] addons: no unsubscribe for unsubscribed The `/groups` route display mail.channel and allow: - a public user to subscribe specifying a mail address - a logged in user to subscribe/unsubscribe itself The `/groups?unsubscribe` route is the same but only allow: - a public user to unsubscribe specifying a mail address - a logged in user to unsubscribe itself When a user is logged in, there is the oddity that all mail.channel appear as to "unsubscribe" even if the user is not subscribed. With this commit, the unsubscribe is shown only if user is subscribed. opw-1861208 closes #25439 --- .../static/src/js/website_mail_channel.snippet.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js b/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js index 9daba4bf666..e48cae79df4 100644 --- a/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js +++ b/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js @@ -8,6 +8,7 @@ sAnimation.registry.follow_alias = sAnimation.Class.extend({ start: function () { var self = this; this.is_user = false; + var unsubscribePage = window.location.search.slice(1).split('&').indexOf("unsubscribe") >= 0; this._rpc({ route: '/groups/is_member', params: { @@ -19,6 +20,9 @@ sAnimation.registry.follow_alias = sAnimation.Class.extend({ self.is_user = data.is_user; self.email = data.email; self.$target.find('.js_mg_link').attr('href', '/groups/' + self.$target.data('id')); + if (unsubscribePage && self.is_user) { + self.$target.find(".js_mg_follow_form").remove(); + } self.toggle_subscription(data.is_member ? 'on' : 'off', data.email); self.$target.removeClass("hidden"); });