Merge lp:~openerp-dev/openobject-addons/trunk-signature-jsh into lp:openobject-addons

Proposed by Jaysinh Shukla(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-signature-jsh
Merge into: lp:openobject-addons
Diff against target: 101 lines (+10/-12)
5 files modified
crm_partner_assign/crm_partner_assign_data.xml (+1/-1)
hr_recruitment/hr_recruitment_data.xml (+2/-2)
mail/mail_followers.py (+2/-3)
mail/tests/test_mail_features.py (+3/-4)
portal/portal_demo.xml (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-signature-jsh
Reviewer Review Type Date Requested Status
Thibault Delavallée (OpenERP) (community) technical Needs Fixing
Review via email: mp+215863@code.launchpad.net

Description of the change

Modified 'mail' module to accept HTML tags as signature. The change is because of modification in 'signature' field of 'res.users'. Previously it was 'text' now 'html'. Modified test condition in which text of body is striped downed and compared to striped downed signature. For detaild explaination of test case kindly observe the following example.

Previous test case ('signature' is 'text') :
  Is 'By Admin' In html2plaintext('Mail body' + ' By Admin') ? <- No broke.

Now After change in signature field ('signature' is 'html) :
  Is '<b>By Admin</b>' In html2plaintext('Mail body' + ' <b>By Admin</b>') ? <- Broke the condition. Because html2plaintext will remove the '<b>' tag.

To not break the test condition after changing 'signature' field observ following example :
  Is html2plaintext('<b>By Admin</b>') In ('Mail body' + ' <b>By Admin</b>') ? <- YES !

To post a comment you must log in.
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Hello,

You should grep signature and all addons and see if your change has an impact.

Notably, I would like you to check the following things :
- account_followup/report/account_followup_print.py: uses user signature -> how does it behave with html tags and things like that ?
- hr_evaluation/hr_evaluation.py: user signature seems to be used, so same question
- crm_partner_assign/crm_partner_assign_data.xml: user signature is used in a pre, it wlil give some strange result

Best regards,

review: Needs Fixing (technical)
9336. By Amit Vora(OpenERP)

[MRG] merge with main branch

9337. By Amit Vora(OpenERP)

[IMP] use safe for signature field

9338. By Amit Vora(OpenERP)

[MRG] merge with main branch

9339. By Amit Vora(OpenERP)

[IMP] improve code

9340. By Mehul Mehta(OpenERP)

[Merge] Merged with lp:openobject-addons

9341. By Mehul Mehta(OpenERP)

[IMP] improved a signature in portal_demo file

9342. By Mehul Mehta(OpenERP)

minor changes apply

9343. By Sunil Sharma(OpenERP)

[mrg]:lp:openobject-addons

9344. By Amit Vora(OpenERP)

[MRG] merge with main branch

Unmerged revisions

9344. By Amit Vora(OpenERP)

[MRG] merge with main branch

9343. By Sunil Sharma(OpenERP)

[mrg]:lp:openobject-addons

9342. By Mehul Mehta(OpenERP)

minor changes apply

9341. By Mehul Mehta(OpenERP)

[IMP] improved a signature in portal_demo file

9340. By Mehul Mehta(OpenERP)

[Merge] Merged with lp:openobject-addons

9339. By Amit Vora(OpenERP)

[IMP] improve code

9338. By Amit Vora(OpenERP)

[MRG] merge with main branch

9337. By Amit Vora(OpenERP)

[IMP] use safe for signature field

9336. By Amit Vora(OpenERP)

[MRG] merge with main branch

9335. By Jaysinh Shukla(OpenERP)

[IMP]:mail Unnecessary comments removed. Improved mail test case.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'crm_partner_assign/crm_partner_assign_data.xml'
2--- crm_partner_assign/crm_partner_assign_data.xml 2013-11-22 19:44:15 +0000
3+++ crm_partner_assign/crm_partner_assign_data.xml 2014-05-16 09:33:42 +0000
4@@ -48,7 +48,7 @@
5 <p>Thanks,</p>
6
7 <pre>
8-${ctx['partner_id'].user_id and ctx['partner_id'].user_id.signature or ''}
9+${ctx['partner_id'].user_id and ctx['partner_id'].user_id.signature | safe or ''}
10 </pre>
11 % if not ctx['partner_id'].user_id:
12 PS: It looks like you do not have an account manager assigned to you, please contact us.
13
14=== modified file 'hr_recruitment/hr_recruitment_data.xml'
15--- hr_recruitment/hr_recruitment_data.xml 2014-02-12 09:56:06 +0000
16+++ hr_recruitment/hr_recruitment_data.xml 2014-05-16 09:33:42 +0000
17@@ -33,7 +33,7 @@
18 <p>If you want more details, feel free to contact us by phone.</p>
19 <p>Kind regards,</p>
20 <br/>
21- ${object.user_id and object.user_id.signature or ''}]]></field>
22+ ${object.user_id and object.user_id.signature | safe or ''}]]></field>
23 </record>
24
25 <record id="applicant_interest" model="email.template">
26@@ -51,7 +51,7 @@
27 If I do not answer, please let me a message with some schedules to call you back.</p>
28 <p>Kind regards,</p>
29 <br/>
30- ${object.user_id.signature}]]></field>
31+ ${object.user_id.signature | safe}]]></field>
32 </record>
33
34 <!-- HR Recruitment Source -->
35
36=== modified file 'mail/mail_followers.py'
37--- mail/mail_followers.py 2014-04-23 12:53:19 +0000
38+++ mail/mail_followers.py 2014-05-16 09:33:42 +0000
39@@ -119,11 +119,10 @@
40 # add user signature
41 user = self.pool.get("res.users").browse(cr, SUPERUSER_ID, [user_id], context=context)[0]
42 if user.signature:
43- signature = plaintext2html(user.signature)
44+ signature = user.signature
45 else:
46 signature = "--<br />%s" % user.name
47- footer = tools.append_content_to_html(footer, signature, plaintext=False, container_tag='p')
48-
49+ footer = tools.append_content_to_html(footer, signature, plaintext=False)
50 # add company signature
51 if user.company_id.website:
52 website_url = ('http://%s' % user.company_id.website) if not user.company_id.website.lower().startswith(('http:', 'https:')) \
53
54=== modified file 'mail/tests/test_mail_features.py'
55--- mail/tests/test_mail_features.py 2014-04-17 09:41:33 +0000
56+++ mail/tests/test_mail_features.py 2014-05-16 09:33:42 +0000
57@@ -22,10 +22,9 @@
58 from openerp.addons.mail.mail_mail import mail_mail
59 from openerp.addons.mail.mail_thread import mail_thread
60 from openerp.addons.mail.tests.common import TestMail
61-from openerp.tools import mute_logger, email_split
62+from openerp.tools import mute_logger, email_split, html2plaintext
63 from openerp.tools.mail import html_sanitize
64
65-
66 class test_mail(TestMail):
67
68 def test_000_alias_setup(self):
69@@ -474,7 +473,7 @@
70 'message_post: notification email body alternative should contain the body')
71 self.assertNotIn('<p>', sent_email['body_alternative'],
72 'message_post: notification email body alternative still contains html')
73- self.assertIn(user_raoul.signature, sent_email['body_alternative'],
74+ self.assertIn(html2plaintext(user_raoul.signature), sent_email['body_alternative'],
75 'message_post: notification email body alternative should contain the sender signature')
76 self.assertFalse(sent_email['references'],
77 'message_post: references should be False when sending a message that is not a reply')
78@@ -545,7 +544,7 @@
79 'message_post: notification email body alternative should contain the body')
80 self.assertNotIn('<p>', sent_email['body_alternative'],
81 'message_post: notification email body alternative still contains html')
82- self.assertIn(user_raoul.signature, sent_email['body_alternative'],
83+ self.assertIn(html2plaintext(user_raoul.signature), sent_email['body_alternative'],
84 'message_post: notification email body alternative should contain the sender signature')
85 self.assertIn(msg_message_id, sent_email['references'],
86 'message_post: notification email references lacks parent message message_id')
87
88=== modified file 'portal/portal_demo.xml'
89--- portal/portal_demo.xml 2014-04-09 10:16:04 +0000
90+++ portal/portal_demo.xml 2014-05-16 09:33:42 +0000
91@@ -18,8 +18,8 @@
92 <field name="partner_id" ref="partner_demo_portal"/>
93 <field name="login">portal</field>
94 <field name="password">portal</field>
95- <field name="signature">--
96-Mr Demo Portal</field>
97+ <field name="signature"><![CDATA[<span>--<br/>
98+Mr Demo Portal</span>]]></field>
99 <!-- Avoid auto-including this user in any default group -->
100 <field name="groups_id" eval="[(5,)]"/>
101 </record>

Subscribers

People subscribed via source and target branches

to all changes: