[FIX] mass_mailing: render placeholder in mailing web view
The placeholders were rendered as empty string in the web version of the mailing (accessed through the "view online" link in the email). This fixes the problem. Technical note: we cannot use mail_mail.body_html (which contains already the rendered placeholder for the specific user) as it is marked for deletion so we render it from mailing_mailing.body_html. Task-2954282 closes odoo/odoo#100984 X-original-commit: 6b2d5db762ef198e9f07af95116c166b027eb383 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -167,23 +167,13 @@ class MassMailController(http.Controller):
|
||||
if not self._valid_unsubscribe_token(mailing_id, res_id, email, str(token)) and not request.env.user.has_group('mass_mailing.group_mass_mailing_user'):
|
||||
raise exceptions.AccessDenied()
|
||||
|
||||
res = mailing.convert_links()
|
||||
base_url = mailing.get_base_url().rstrip('/')
|
||||
urls_to_replace = [
|
||||
(base_url + '/unsubscribe_from_list', mailing._get_unsubscribe_url(email, res_id)),
|
||||
(base_url + '/view', mailing._get_view_url(email, res_id))
|
||||
]
|
||||
for url_to_replace, new_url in urls_to_replace:
|
||||
if url_to_replace in res[mailing_id]:
|
||||
res[mailing_id] = res[mailing_id].replace(url_to_replace, new_url if new_url else '#')
|
||||
|
||||
res[mailing_id] = res[mailing_id].replace(
|
||||
'class="o_snippet_view_in_browser"',
|
||||
'class="o_snippet_view_in_browser" style="display: none;"'
|
||||
)
|
||||
html_markupsafe = mailing._render_field('body_html', [res_id])[res_id]
|
||||
# Update generic URLs (without parameters) to final ones
|
||||
html_markupsafe = html_markupsafe.replace('/unsubscribe_from_list',
|
||||
mailing._get_unsubscribe_url(email, res_id))
|
||||
|
||||
return request.render('mass_mailing.view', {
|
||||
'body': res[mailing_id],
|
||||
'body': html_markupsafe,
|
||||
})
|
||||
|
||||
return request.redirect('/web')
|
||||
|
||||
@@ -26,7 +26,22 @@
|
||||
|
||||
<!-- Dummy layout to "view" a template content (html) -->
|
||||
<template id="view" name="Browser View">
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
|
||||
<style type="text/css">
|
||||
<!-- Hide the link view online as it is displayed online -->
|
||||
.o_snippet_view_in_browser {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Raw body inserted here because it is a rendered mailing, therefore internal content -->
|
||||
<t t-out="body"/>
|
||||
</body>
|
||||
</html>
|
||||
</template>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user