Thibault Delavallée (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/7.0-context-threads-notification-nwi into 
lp:openobject-addons/7.0.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-context-threads-notification-nwi/+merge/143676
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-context-threads-notification-nwi/+merge/143676
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/7.0-context-threads-notification-nwi.
=== modified file 'mail/mail_followers.py'
--- mail/mail_followers.py	2012-12-27 16:44:25 +0000
+++ mail/mail_followers.py	2013-01-17 12:45:34 +0000
@@ -112,19 +112,21 @@
             return True
         # browse as SUPERUSER_ID because of access to res_partner not necessarily allowed
         msg = self.pool.get('mail.message').browse(cr, SUPERUSER_ID, msg_id, context=context)
+        
+        
         notify_partner_ids = self.get_partners_to_notify(cr, uid, msg, context=context)
         if not notify_partner_ids:
             return True
 
         # add the context in the email
         # TDE FIXME: commented, to be improved in a future branch
-        # quote_context = self.pool.get('mail.message').message_quote_context(cr, uid, msg_id, context=context)
+        quote_context = self.pool.get('mail.message').message_quote_context(cr, uid, msg_id, context=context)
 
         mail_mail = self.pool.get('mail.mail')
         # add signature
-        body_html = msg.body
-        # if quote_context:
-            # body_html = tools.append_content_to_html(body_html, quote_context, plaintext=False)
+        body_html = msg.body.replace('<p>','<p style="padding:0; margin:0;padding-bottom:5px;">')
+        if quote_context:
+            body_html = tools.append_content_to_html(body_html, quote_context, plaintext=False)
         signature = msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0].signature or ''
         if signature:
             body_html = tools.append_content_to_html(body_html, signature, plaintext=True, container_tag='div')

=== modified file 'mail/mail_message.py'
--- mail/mail_message.py	2013-01-15 11:39:20 +0000
+++ mail/mail_message.py	2013-01-17 12:45:34 +0000
@@ -355,7 +355,7 @@
         try:
             body_html = html_email_clean(message.body)
         except Exception:
-            body_html = '<p><b>Encoding Error : </b><br/>Unable to convert this message (id: %s).</p>' % message.id
+            body_html = '    <b>Encoding Error : </b><br/>Unable to convert this message (id: %s).</p>' % message.id
             _logger.exception(Exception)
 
         return {'id': message.id,
@@ -780,31 +780,74 @@
 
     # 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 = """<div>
-    % if message:
-        ${display_message(message)}
-    % endif
-    % for ctx_msg in context_messages:
-        ${display_message(ctx_msg)}
-    % endfor
-    % if add_expandable:
+    MAIL_TEMPLATE = """
+    <style type="text/css">
+        p {padding:0; margin:0;padding-bottom:5px;}
+    </style>
+    <br/>
+    <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0"> 
+        % if message:
+            ${display_message(message)}
+        % endif
+        
+        <p>--</p>
+        ${display_header_threads(header_message)}
+        
+        % for ctx_msg in context_messages:
+            ${display_message(ctx_msg)}
+        % endfor
+    </table>
+    
+     % if add_expandable:
         ${display_expandable()}
-    % endif
-    ${display_message(header_message)}
-    </div>
+     % endif
 
     <%def name="display_message(message)">
-        <div>
-            Subject: ${message.subject}<br />
-            Body: ${message.body}
-        </div>
+        <tr>
+            <td>
+                <table width="98%" align="right" cellpadding="5" cellspacing="0" border="0">    
+                    <tr>
+                        <td valign="top" width="100%">
+                            <font size="2" face="Arial" color="#4c4c4c">
+                                    ${message.body}
+                                    <font color="#7c7bad" size="1">${message.author_id.name}</font>
+                                    <font color="#B7B7D5">-</font>
+                                    <font size="1">${message.date}</font>
+                            </font>
+                        </td>
+                    </tr>
+                </table>
+            </td>
+        </tr>  
+    </%def>
+    
+    <%def name="display_header_threads(message)">
+        <tr>
+            <td bgcolor="EDEDF6">
+                <table width="100%" cellpadding="5" cellspacing="0" border="0">
+                    <tbody>
+                        <tr>
+                            
+                            <td valign="top" width="100%">
+                                <font size="2" face="Arial" color="#4c4c4c">
+                                    <b>${message.subject}</b>
+                                    ${message.body}
+                                    <font color="#7c7bad" size="1">${message.author_id.name}</font>
+                                    <font color="#B7B7D5">-</font>
+                                    <font size="1">${message.date}</font>
+                                </font>
+                            </td>
+                        </tr>
+                    </tbody>
+                </table>
+            </td>
+        </tr>
     </%def>
 
     <%def name="display_expandable()">
-        <div>This is an expandable.</div>
+        <table width="100%" cellpadding="10" border="0"><tr><td width="100%" align="center"><font size="2" color="gray" face="Arial">---- </font><a href="#"><font size="2" color="gray" face="Arial">show ${rest_messages} more message(s)</font></a><font size="3" color="gray" face="Arial"> ----</font></td></tr></table>
     </%def>
     """
-
     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
@@ -820,30 +863,34 @@
         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)
 
+        all_context_message= len(self.search(cr, uid, [('parent_id', '=', message.parent_id.id),('id', '<', message.id),]))
+        
         if len(context_ids) >= limit:
             add_expandable = True
+            rest_messages = all_context_message - limit
             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,
+                                                        rest_messages=rest_messages,
                                                         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()
+            result = result.strip().replace('<p>','<p style="padding:0; margin:0;padding-bottom:5px;">')
             return result
         except Exception:
             _logger.exception("failed to render mako template for quoting message")

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to