Commit 9c1799e5 authored by Romain Courteaud's avatar Romain Courteaud

Use portal_notifications to send report to the user.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24227 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21d05285
...@@ -59,7 +59,7 @@ RESPONSE = request.RESPONSE\n ...@@ -59,7 +59,7 @@ RESPONSE = request.RESPONSE\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n N_ = portal.Base_translateString\n
active_process = portal.portal_activities.newActiveProcess()\n active_process = portal.portal_activities.newActiveProcess()\n
email_to = \'jerome@nexedi.com\' # XXX \n user_name = context.portal_membership.getAuthenticatedMember().getUserName()\n
\n \n
skin_name = \'ODT\' # hardcoded for now\n skin_name = \'ODT\' # hardcoded for now\n
tag = \'active-report-%s\' % random.randint(0, 1000)\n tag = \'active-report-%s\' % random.randint(0, 1000)\n
...@@ -100,7 +100,7 @@ portal.portal_simulation.activate(after_tag=tag).Base_report(\n ...@@ -100,7 +100,7 @@ portal.portal_simulation.activate(after_tag=tag).Base_report(\n
title=form.getProperty(\'title\'),\n title=form.getProperty(\'title\'),\n
request_other=request_other,\n request_other=request_other,\n
form_path=form.getPhysicalPath(),\n form_path=form.getPhysicalPath(),\n
email_to=email_to,\n user_name=user_name,\n
)\n )\n
\n \n
context.activate(after_tag=tag).getTitle()\n context.activate(after_tag=tag).getTitle()\n
...@@ -155,7 +155,7 @@ return context.Base_redirect(\'view\', keep_items=dict(\n ...@@ -155,7 +155,7 @@ return context.Base_redirect(\'view\', keep_items=dict(\n
<string>portal</string> <string>portal</string>
<string>N_</string> <string>N_</string>
<string>active_process</string> <string>active_process</string>
<string>email_to</string> <string>user_name</string>
<string>skin_name</string> <string>skin_name</string>
<string>random</string> <string>random</string>
<string>tag</string> <string>tag</string>
......
...@@ -53,9 +53,7 @@ ...@@ -53,9 +53,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>request = container.REQUEST\n
request = container.REQUEST\n
request.other.update(request_other)\n request.other.update(request_other)\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
ap = portal.restrictedTraverse(active_process_url)\n ap = portal.restrictedTraverse(active_process_url)\n
...@@ -76,52 +74,25 @@ report_data = context.report_view.pt_render(\n ...@@ -76,52 +74,25 @@ report_data = context.report_view.pt_render(\n
rendered_report_item_list=[r[1] for r in report_section_list],\n rendered_report_item_list=[r[1] for r in report_section_list],\n
form=portal.restrictedTraverse(form_path)))\n form=portal.restrictedTraverse(form_path)))\n
\n \n
email_from = portal.getProperty(\'email_from_address\')\n attachment_list = (\n
if portal.getProperty(\'email_from_name\'):\n {\'mime_type\': request.RESPONSE.getHeader(\'content-type\').split(\';\')[0],\n
email_from = \'"%s" <%s>\' % (portal.getProperty(\'email_from_name\'), email_from)\n \'content\': report_data,\n
\'name\': [x[len(\'filename=\'):] for x in request.RESPONSE.getHeader(\n
\'content-disposition\').split(\';\') \\\n
if x.startswith(\'filename=\')][0]},)\n
\n \n
if 0: # send an email ?\n # XXX Use notification message to improve message content\n
portal.MailHost.send(\'\'\'From:%(mfrom)s\n portal.portal_notifications.sendMessage(\n
To:%(mto)s\n recipient=user_name,\n
Subject:%(subject)s\n subject=title,\n
Content-Type: Multipart/Mixed;\n message=\'\\nYour report is attached.\\n\\n\' \\\n
boundary="Boundary-00=_GJWGGr2lsPnqbw0"\n \'Maybe here we could sum up the parameters, date, user etc ?\\n\\n\',\n
\n message_text_format=\'text/plain\',\n
--Boundary-00=_GJWGGr2lsPnqbw0\n notifier_list=(\'Mail Message\',),\n
Content-Type: text/plain;\n store_as_event=False,\n
charset="utf-8"\n attachment_list=attachment_list,\n
Content-Transfer-Encoding: 7bit\n )\n
Content-Disposition: inline\n </string> </value>
\n
Your report is attached.\n
\n
Maybe here we could sum up the parameters, date, user etc ?\n
\n
--Boundary-00=_GJWGGr2lsPnqbw0\n
Content-Type: application/pdf;\n
name="CasParticuliers.pdf"\n
Content-Transfer-Encoding: 8bit\n
Content-Disposition: attachment;\n
\tfilename="%(subject)s.pdf"\n
\n
%(report_data)s\n
\'\'\' % dict(subject=title,\n
mfrom=email_from,\n
mto=email_to,\n
report_data=report_data))\n
\n
# TODO: this should use portal_contributions\n
doc = portal.document_module.newContent(portal_type=\'File\',\n
title=N_(title),\n
language=localizer_language,\n
data=report_data)\n
\n
content_type = request.RESPONSE.getHeader(\'Content-Type\')\n
if content_type:\n
doc.setContentType(content_type.split(\';\')[0])\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -131,7 +102,7 @@ if content_type:\n ...@@ -131,7 +102,7 @@ if content_type:\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>active_process_url, skin_name, localizer_language, title, request_other, form_path, email_to</string> </value> <value> <string>active_process_url, skin_name, localizer_language, title, request_other, form_path, user_name</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -163,7 +134,7 @@ if content_type:\n ...@@ -163,7 +134,7 @@ if content_type:\n
<string>title</string> <string>title</string>
<string>request_other</string> <string>request_other</string>
<string>form_path</string> <string>form_path</string>
<string>email_to</string> <string>user_name</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>container</string> <string>container</string>
<string>request</string> <string>request</string>
...@@ -180,9 +151,10 @@ if content_type:\n ...@@ -180,9 +151,10 @@ if content_type:\n
<string>dict</string> <string>dict</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>report_data</string> <string>report_data</string>
<string>email_from</string> <string>x</string>
<string>doc</string> <string>len</string>
<string>content_type</string> <string>attachment_list</string>
<string>False</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
19 20
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment