[IMP] website_mail_channel: unsubscribing unsubscribed address
Before this fix, if a (non-registered) user tried to unsubscribe an address *not registered*, they'd get an unsub link, click on it, and get a "Invalid or expired confirmation link." message, usually wondering what the bloody hell happened. Provide a clearer message in that case.
This commit is contained in:
@@ -6,7 +6,7 @@ import werkzeug
|
||||
from datetime import datetime
|
||||
from dateutil import relativedelta
|
||||
|
||||
from odoo import http, fields, tools
|
||||
from odoo import http, fields, tools, _
|
||||
from odoo.http import request
|
||||
from odoo.addons.website.models.website import slug
|
||||
|
||||
@@ -228,8 +228,16 @@ class MailGroup(http.Controller):
|
||||
def confirm_unsubscribe(self, channel, partner_id, token, **kw):
|
||||
subscriber = request.env['mail.channel.partner'].search([('channel_id', '=', channel.id), ('partner_id', '=', partner_id)])
|
||||
if not subscriber:
|
||||
# not registered, maybe already unsubsribed
|
||||
return request.render('website_mail_channel.invalid_token_subscription')
|
||||
# FIXME: remove try/except in master
|
||||
try:
|
||||
return request.render(
|
||||
'website_mail_channel.not_subscribed', {
|
||||
'partner_id': partner_id
|
||||
})
|
||||
except ValueError:
|
||||
return _("The address %s is already unsubscribed or was never subscribed to any mailing list") % (
|
||||
partner_id.email
|
||||
)
|
||||
|
||||
subscriber_token = channel._generate_action_token(partner_id, action='unsubscribe')
|
||||
if token != subscriber_token:
|
||||
|
||||
@@ -291,3 +291,18 @@ msgstr ""
|
||||
msgid "your email..."
|
||||
msgstr ""
|
||||
|
||||
#. module: website_mail_channel
|
||||
#: model:ir.ui.view,arch_db:website_mail_channel.not_subscribed
|
||||
msgid "The address"
|
||||
msgstr ""
|
||||
|
||||
#. module: website_mail_channel
|
||||
#: model:ir.ui.view,arch_db:website_mail_channel.not_subscribed
|
||||
msgid "is already unsubscribed or was never subscribed to the mailing list, you may want to check that the address was correct."
|
||||
msgstr ""
|
||||
|
||||
#. module: website_mail_channel
|
||||
#: code:addons/website_mail_channel/controllers/main.py:238
|
||||
#, python-format
|
||||
msgid "The address %s is already unsubscribed or was never subscribed to any mailing list"
|
||||
msgstr ""
|
||||
|
||||
@@ -338,4 +338,19 @@
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="not_subscribed" name="Email address was not subscribed">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap" class="oe_structure oe_empty">
|
||||
<div class="container">
|
||||
<p>
|
||||
The address <t t-esc="partner_id.email"/> is already
|
||||
unsubscribed or was never subscribed to the mailing
|
||||
list, you may want to check that the address was
|
||||
correct.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user