Commit 2ed3f5fb authored by Jérome Perrin's avatar Jérome Perrin

deferred_style: make the notify script a parameter

This enables reuse of deferred style API to produce a report, but do
something else with the report.
parent 73f68fb8
# pylint: disable=redefined-builtin
portal = context.getPortalObject()
if notify_report_complete_kwargs is None:
notify_report_complete_kwargs = {}
form = context.restrictedTraverse(form)
request = container.REQUEST
......@@ -58,5 +60,7 @@ activity_context.activate(
form_path=form.getPhysicalPath(),
user_name=user_name,
format=format,
report_section_count=len(report_section_list)
)
report_section_count=len(report_section_list),
notify_report_complete_script_id=notify_report_complete_script_id,
notify_report_complete_kwargs=notify_report_complete_kwargs,
)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form, request_other, user_name, tag, skin_name, format, priority, localizer_language, **kw</string> </value>
<value> <string>form, request_other, user_name, tag, skin_name, format, priority, localizer_language, notify_report_complete_script_id=\'ERP5Site_notifyReportComplete\', notify_report_complete_kwargs=None, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
# Render a "normal" form or an OOo template in an activity and send it by email
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
if notify_report_complete_kwargs is None:
notify_report_complete_kwargs = {}
request = portal.REQUEST
report_format = request_form.get('format', '')
if portal.portal_preferences.getPreferredDeferredReportStoredAsDocument():
......@@ -31,9 +33,11 @@ with portal.Localizer.translationContext(localizer_language):
'content': '%s' % report_data,
'name': attachment_name},)
portal.ERP5Site_notifyReportComplete(
getattr(portal, notify_report_complete_script_id)(
user_name=user_name,
subject=str(translateString(attachment_name.rsplit('.', 1)[0])),
message='',
attachment_list=attachment_list,
format=report_format)
format=report_format,
**notify_report_complete_kwargs
)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>localizer_language, skin_name, request_form, deferred_style_dialog_method, user_name, params</string> </value>
<value> <string>localizer_language, skin_name, request_form, deferred_style_dialog_method, user_name, params, notify_report_complete_script_id=\'ERP5Site_notifyReportComplete\', notify_report_complete_kwargs=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -51,9 +51,11 @@ with portal.Localizer.translationContext(localizer_language):
'content': '%s' % report_data,
'name': attachment_name},)
portal.ERP5Site_notifyReportComplete(
getattr(portal, notify_report_complete_script_id)(
user_name=user_name,
subject=title,
message='',
attachment_list=attachment_list,
format=format)
format=format,
**notify_report_complete_kwargs
)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_process_url, skin_name, localizer_language, title, request_other, form_path, user_name, format, report_section_count</string> </value>
<value> <string>active_process_url, skin_name, localizer_language, title, request_other, form_path, user_name, format, report_section_count, notify_report_complete_script_id, notify_report_complete_kwargs</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
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