From a76de4595e9a0ce86645fd25c6e7728e2dfc6285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 20 Aug 2014 12:01:50 +0200 Subject: [PATCH] [FIX] tools: mail: fixed read more link tha could be placed in a block to be removed, being considered as a quote --- openerp/addons/base/tests/test_mail.py | 6 ++ .../addons/base/tests/test_mail_examples.py | 69 +++++++++++++++++++ openerp/tools/mail.py | 5 ++ 3 files changed, 80 insertions(+) diff --git a/openerp/addons/base/tests/test_mail.py b/openerp/addons/base/tests/test_mail.py index 01193de9962..c3559743d89 100644 --- a/openerp/addons/base/tests/test_mail.py +++ b/openerp/addons/base/tests/test_mail.py @@ -342,6 +342,12 @@ class TestCleaner(unittest2.TestCase): for ext in test_mail_examples.BUG_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') + new_html = html_email_clean(test_mail_examples.BUG3, remove=True, shorten=True, max_length=250) + for ext in test_mail_examples.BUG_3_IN: + self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') + for ext in test_mail_examples.BUG_3_OUT: + self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') + def test_90_misc(self): # False boolean for text must return empty string new_html = html_email_clean(False) diff --git a/openerp/addons/base/tests/test_mail_examples.py b/openerp/addons/base/tests/test_mail_examples.py index 0760bd38bf8..48fedca5f00 100644 --- a/openerp/addons/base/tests/test_mail_examples.py +++ b/openerp/addons/base/tests/test_mail_examples.py @@ -1104,3 +1104,72 @@ BUG_2_OUT = [ 'Fwd: TR: OpenERP S.A' 'fait un mois' ] + + +# BUG 20/08/2014: READ MORE NOT APPEARING +BUG3 = """

OpenERP has been upgraded to version 8.0.

+

What's new in this upgrade?

+
+
    +
  • New Warehouse Management System:

    +
    +

    Schedule your picking, packing, receptions and internal moves automatically with Odoo using +your own routing rules. Define push and pull rules to organize a warehouse or to manage +product moves between several warehouses. Track in detail all stock moves, not only in your +warehouse but wherever else it's taken as well (customers, suppliers or manufacturing +locations).

    +
    +
  • +
  • New Product Configurator

    +
  • +
  • Documentation generation from website forum:

    +
    +

    New module to generate a documentation from questions and responses from your forum. +The documentation manager can define a table of content and any user, depending their karma, +can link a question to an entry of this TOC.

    +
    +
  • +
  • New kanban view of documents (resumes and letters in recruitement, project documents...)

    +
  • +
  • E-Commerce:

    +
    +
      +
    • Manage TIN in contact form for B2B.
    • +
    • Dedicated salesteam to easily manage leads and orders.
    • +
    +
    +
  • +
  • Better Instant Messaging.

    +
  • +
  • Faster and Improved Search view: Search drawer now appears on top of the results, and is open +by default in reporting views

    +
  • +
  • Improved User Interface:

    +
    +
      +
    • Popups has changed to be more responsive on tablets and smartphones.
    • +
    • New Stat Buttons: Forms views have now dynamic buttons showing some statistics abouts linked models.
    • +
    • Color code to check in one look availability of components in an MRP order.
    • +
    • Unified menu bar allows you to switch easily between the frontend (website) and backend
    • +
    • Results panel is now scrollable independently of the menu bars, keeping the navigation, +search bar and view switcher always within reach.
    • +
    +
    +
  • +
  • User signature is now in HTML.

    +
  • +
  • New development API.

    +
  • +
  • Remove support for Outlook and Thunderbird plugins

    +
  • +
+
+

Enjoy the new OpenERP Online!

read less
""" + +BUG_3_IN = [ + 'read more', + '...', +] +BUG_3_OUT = [ + 'New kanban view of documents' +] diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index d6ac1c1cb43..ab546895943 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -386,6 +386,11 @@ def html_email_clean(html, remove=False, shorten=False, max_length=300, expand_o node.set('in_quote', '1') node.set('tail_remove', '1') if node.tag == 'blockquote' or node.get('text_quote') or node.get('text_signature'): + # here no quote_begin because we want to be able to remove some quoted + # text without removing all the remaining context + node.set('in_quote', '1') + if node.getparent() is not None and node.getparent().get('in_quote'): + # inside a block of removed text but not in quote_begin (see above) node.set('in_quote', '1') # shorten: