Browse Source

mail_digest: fwd port improvements from v10

pull/273/head
Simone Orsi 7 years ago
parent
commit
2d79643e1f
  1. 1
      mail_digest/controllers/digest_layout_preview.py
  2. 2
      mail_digest/templates/digest_default.xml
  3. 12
      mail_digest/tests/test_digest.py
  4. 7
      mail_digest/tests/test_preview.py

1
mail_digest/controllers/digest_layout_preview.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Simone Orsi <simone.orsi@camptocamp.com> # Copyright 2018 Simone Orsi <simone.orsi@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

2
mail_digest/templates/digest_default.xml

@ -24,7 +24,7 @@
<template id="default_digest_tmpl" name="Mail digest default template"> <template id="default_digest_tmpl" name="Mail digest default template">
<t t-call="mail_digest.digest_layout"> <t t-call="mail_digest.digest_layout">
<div id="mail_content"> <div id="mail_content">
<p>Hello <t t-esc="digest.partner_id.name" />,</p>
<p>Hello <t t-esc="digest.user_id.name" />,</p>
<div id="mail_inner_content"> <div id="mail_inner_content">
<t t-foreach="grouped_messages.keys()" t-as="gkey"> <t t-foreach="grouped_messages.keys()" t-as="gkey">
<t t-set="messages" t-value="grouped_messages[gkey]" /> <t t-set="messages" t-value="grouped_messages[gkey]" />

12
mail_digest/tests/test_digest.py

@ -194,26 +194,26 @@ class DigestCase(SavepointCase):
dig._get_email_values() dig._get_email_values()
def test_digest_message_body_sanitize(self): def test_digest_message_body_sanitize(self):
dig = self._create_for_partner(self.partner1)
dig = self._create_for_partner(self.user1.partner_id)
message = self.message_model.create({ message = self.message_model.create({
'body': '<p style="font-weight: bold">Body!</p>', 'body': '<p style="font-weight: bold">Body!</p>',
'subtype_id': self.subtype1.id, 'subtype_id': self.subtype1.id,
'res_id': self.partner3.id,
'res_id': self.user3.partner_id.id,
'model': 'res.partner', 'model': 'res.partner',
'partner_ids': [(4, self.partner1.id)]
'partner_ids': [(4, self.user1.partner_id.id)]
}) })
body = dig.message_body(message) body = dig.message_body(message)
self.assertEqual(body, '<p>Body!</p>') self.assertEqual(body, '<p>Body!</p>')
def test_digest_message_body_no_sanitize(self): def test_digest_message_body_no_sanitize(self):
dig = self._create_for_partner(self.partner1)
dig = self._create_for_partner(self.user1.partner_id)
dig.sanitize_msg_body = False dig.sanitize_msg_body = False
message = self.message_model.create({ message = self.message_model.create({
'body': '<p style="font-weight: bold">Body!</p>', 'body': '<p style="font-weight: bold">Body!</p>',
'subtype_id': self.subtype1.id, 'subtype_id': self.subtype1.id,
'res_id': self.partner3.id,
'res_id': self.user3.partner_id.id,
'model': 'res.partner', 'model': 'res.partner',
'partner_ids': [(4, self.partner1.id)]
'partner_ids': [(4, self.user1.partner_id.id)]
}) })
body = dig.message_body(message) body = dig.message_body(message)
self.assertEqual( self.assertEqual(

7
mail_digest/tests/test_preview.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Simone Orsi <simone.orsi@camptocamp.com> # Copyright 2017 Simone Orsi <simone.orsi@camptocamp.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
@ -55,3 +54,9 @@ class PreviewCase(SavepointCase):
patched_req.env = self.env patched_req.env = self.env
vals = self.ctrl._fake_tracking_vals() vals = self.ctrl._fake_tracking_vals()
self.assertEqual(len(vals), 2) self.assertEqual(len(vals), 2)
@mock.patch(REQUEST_PATH + '.request')
def test_render(self, patched_req):
patched_req.env = self.env
html = self.ctrl.digest_test()
self.assertTrue(html)
Loading…
Cancel
Save