diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 671309cd3ee..eca19d58f87 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -886,78 +886,6 @@ class mail_message(osv.Model): # Messaging API #------------------------------------------------------ - # TDE note: this code is not used currently, will be improved in a future merge, when quoted context - # will be added to email send for notifications. Currently only WIP. - MAIL_TEMPLATE = """
- % if message: - ${display_message(message)} - % endif - % for ctx_msg in context_messages: - ${display_message(ctx_msg)} - % endfor - % if add_expandable: - ${display_expandable()} - % endif - ${display_message(header_message)} -
- - <%def name="display_message(message)"> -
- Subject: ${message.subject}
- Body: ${message.body} -
- - - <%def name="display_expandable()"> -
This is an expandable.
- - """ - - def message_quote_context(self, cr, uid, id, context=None, limit=3, add_original=False): - """ - 1. message.parent_id = False: new thread, no quote_context - 2. get the lasts messages in the thread before message - 3. get the message header - 4. add an expandable between them - - :param dict quote_context: options for quoting - :return string: html quote - """ - add_expandable = False - - message = self.browse(cr, uid, id, context=context) - if not message.parent_id: - return '' - context_ids = self.search(cr, uid, [ - ('parent_id', '=', message.parent_id.id), - ('id', '<', message.id), - ], limit=limit, context=context) - - if len(context_ids) >= limit: - add_expandable = True - context_ids = context_ids[0:-1] - - context_ids.append(message.parent_id.id) - context_messages = self.browse(cr, uid, context_ids, context=context) - header_message = context_messages.pop() - - try: - if not add_original: - message = False - result = MakoTemplate(self.MAIL_TEMPLATE).render_unicode(message=message, - context_messages=context_messages, - header_message=header_message, - add_expandable=add_expandable, - # context kw would clash with mako internals - ctx=context, - format_exceptions=True) - result = result.strip() - return result - except Exception: - _logger.exception("failed to render mako template for quoting message") - return '' - return result - def _notify(self, cr, uid, newid, context=None, force_send=False, user_signature=True): """ Add the related record followers to the destination partner_ids if is not a private message. Call mail_notification.notify to manage the email sending diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index c7f1056c59a..32001696b8a 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -210,24 +210,6 @@ class test_mail(TestMail): self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') - def test_10_message_quote_context(self): - """ Tests designed for message_post. """ - cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs - - msg1_id = self.mail_message.create(cr, uid, {'body': 'Thread header about Zap Brannigan', 'subject': 'My subject'}) - msg2_id = self.mail_message.create(cr, uid, {'body': 'First answer, should not be displayed', 'subject': 'Re: My subject', 'parent_id': msg1_id}) - msg3_id = self.mail_message.create(cr, uid, {'body': 'Second answer', 'subject': 'Re: My subject', 'parent_id': msg1_id}) - msg4_id = self.mail_message.create(cr, uid, {'body': 'Third answer', 'subject': 'Re: My subject', 'parent_id': msg1_id}) - msg_new_id = self.mail_message.create(cr, uid, {'body': 'My answer I am propagating', 'subject': 'Re: My subject', 'parent_id': msg1_id}) - - result = self.mail_message.message_quote_context(cr, uid, msg_new_id, limit=3) - self.assertIn('Thread header about Zap Brannigan', result, 'Thread header content should be in quote.') - self.assertIn('Second answer', result, 'Answer should be in quote.') - self.assertIn('Third answer', result, 'Answer should be in quote.') - self.assertIn('expandable', result, 'Expandable should be present.') - self.assertNotIn('First answer, should not be displayed', result, 'Old answer should not be in quote.') - self.assertNotIn('My answer I am propagating', result, 'Thread header content should be in quote.') - def test_11_notification_url(self): """ Tests designed to test the URL added in notification emails. """ cr, uid, group_pigs = self.cr, self.uid, self.group_pigs