[FIX] tools: mail: fixed read more link tha could be placed in a block to be removed...
authorThibault Delavallée <tde@openerp.com>
Wed, 20 Aug 2014 10:01:50 +0000 (12:01 +0200)
committerThibault Delavallée <tde@openerp.com>
Wed, 20 Aug 2014 12:10:20 +0000 (14:10 +0200)
openerp/addons/base/tests/test_mail.py
openerp/addons/base/tests/test_mail_examples.py
openerp/tools/mail.py

index 01193de..c355974 100644 (file)
@@ -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)
index 0760bd3..48fedca 100644 (file)
@@ -1104,3 +1104,72 @@ BUG_2_OUT = [
     'Fwd: TR: OpenERP S.A'
     'fait un mois'
 ]
+
+
+# BUG 20/08/2014: READ MORE NOT APPEARING
+BUG3 = """<div class="oe_msg_body_long" style="/* display: none; */"><p>OpenERP has been upgraded to version 8.0.</p>
+<h2>What's new in this upgrade?</h2>
+<div class="document">
+<ul>
+<li><p class="first">New Warehouse Management System:</p>
+<blockquote>
+<p>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).</p>
+</blockquote>
+</li>
+<li><p class="first">New Product Configurator</p>
+</li>
+<li><p class="first">Documentation generation from website forum:</p>
+<blockquote>
+<p>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.</p>
+</blockquote>
+</li>
+<li><p class="first">New kanban view of documents (resumes and letters in recruitement, project documents...)</p>
+</li>
+<li><p class="first">E-Commerce:</p>
+<blockquote>
+<ul class="simple">
+<li>Manage TIN in contact form for B2B.</li>
+<li>Dedicated salesteam to easily manage leads and orders.</li>
+</ul>
+</blockquote>
+</li>
+<li><p class="first">Better Instant Messaging.</p>
+</li>
+<li><p class="first">Faster and Improved Search view: Search drawer now appears on top of the results, and is open
+by default in reporting views</p>
+</li>
+<li><p class="first">Improved User Interface:</p>
+<blockquote>
+<ul class="simple">
+<li>Popups has changed to be more responsive on tablets and smartphones.</li>
+<li>New Stat Buttons: Forms views have now dynamic buttons showing some statistics abouts linked models.</li>
+<li>Color code to check in one look availability of components in an MRP order.</li>
+<li>Unified menu bar allows you to switch easily between the frontend (website) and backend</li>
+<li>Results panel is now scrollable independently of the menu bars, keeping the navigation,
+search bar and view switcher always within reach.</li>
+</ul>
+</blockquote>
+</li>
+<li><p class="first">User signature is now in HTML.</p>
+</li>
+<li><p class="first">New development API.</p>
+</li>
+<li><p class="first">Remove support for Outlook and Thunderbird plugins</p>
+</li>
+</ul>
+</div>
+<p>Enjoy the new OpenERP Online!</p><span class="oe_mail_reduce"><a href="#">read less</a></span></div>"""
+
+BUG_3_IN = [
+    'read more',
+    '...',
+]
+BUG_3_OUT = [
+    'New kanban view of documents'
+]
index d6ac1c1..ab54689 100644 (file)
@@ -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: