Commit e37e1288 authored by Jérome Perrin's avatar Jérome Perrin

Activity Family for deferred style

Example configuration:

from `portal_activities/manageLoadBalancing`:

![image](/uploads/11e614bf8723e3cb81c7bac714a383b7/image.png)

in preferences:

![image](/uploads/9f8691ac140aab45904b98ce46aa11b4/image.png)

This way when users request lots of reports we always have at least one activity node to process other activities. ( document_conversion is a fictional example at this point )

/reviewed-on nexedi/erp5!1057
parents c27b84a4 51fca55a
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_deferred_report_activity_family_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
request = portal.REQUEST
format = request.get('format', '')
format_ = request.get('format', '')
skin_name = request.get('deferred_portal_skin', portal.portal_skins.getDefaultSkin())
previous_skin_selection = request.get('previous_skin_selection', None)
......@@ -43,10 +43,13 @@ if hasattr(form, 'ZScriptHTML_tryParams'):
for param in form.ZScriptHTML_tryParams():
params[param] = request.get(param)
else:
params['format'] = format
params['format'] = format_
activity_context.activate(
activity='SQLQueue', tag=tag, priority=priority).Base_renderSimpleView(
activity='SQLQueue',
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
tag=tag,
priority=priority,).Base_renderSimpleView(
localizer_language=localizer_language,
skin_name=skin_name,
request_form=request_form,
......
......@@ -20,7 +20,7 @@ if person_value.getDefaultEmailText('') in ('', None):
tag = 'active-report-%s' % random.randint(0, 1000)
priority = 2
format = request.get('format', '')
format_ = request.get('format', '')
skin_name = request['deferred_portal_skin']
# save request parameters (after calling the report_method which may tweak the
......@@ -29,14 +29,19 @@ request_other = portal.ERP5Site_filterRequestForDeferredStyle(request)
localizer_language = portal.Localizer.get_selected_language()
context.activate(activity="SQLQueue", tag=tag, after_tag=after_tag,
priority=priority).Base_computeReportSection(
context.activate(
activity="SQLQueue",
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
tag=tag,
after_tag=after_tag,
priority=priority,
).Base_computeReportSection(
form=form.getId(),
request_other=request_other,
user_name=user.getId(),
tag=tag,
skin_name=skin_name,
format=format,
format=format_,
priority=priority,
localizer_language=localizer_language,
**kw)
......
# pylint: disable=redefined-builtin
portal = context.getPortalObject()
form = context.restrictedTraverse(form)
......@@ -28,6 +29,7 @@ for idx, report_section in enumerate(report_section_list):
else:
doc = context
doc.activate(activity='SQLQueue',
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
active_process=active_process,
tag=tag,
priority=priority,
......@@ -42,7 +44,12 @@ if activity_context == portal:
# portal is not an active object
activity_context = portal.portal_simulation
activity_context.activate(activity='SQLQueue', after_tag=tag, priority=priority).Base_report(
activity_context.activate(
activity='SQLQueue',
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
after_tag=tag,
priority=priority,
).Base_report(
active_process_url=active_process.getRelativeUrl(),
skin_name=skin_name,
localizer_language=localizer_language,
......
......@@ -16,7 +16,6 @@ with portal.Localizer.translationContext(localizer_language):
else:
form = None
selection_name = request.get('prefixed_selection_name')
data = context.render_report_section.pt_render(
extra_context=dict(form=form,
first=report_section_idx == 0,
......
from Products.ERP5Type.Message import translateString
# pylint: disable=redefined-builtin
request = container.REQUEST
request.other.update(request_other)
......
# pylint: disable=redefined-builtin
from Products.PythonScripts.standard import newline_to_br, html_quote
portal = context.getPortalObject()
prefs = portal.portal_preferences
......@@ -18,7 +19,10 @@ if prefs.getPreferredDeferredReportStoredAsDocument():
(attachment.get('title', document.getStandardFilename(format=format)), document.getRelativeUrl()))
# pre-convert document before sending notification
if format:
document.activate(tag=pre_convert_tag).convert(format=format)
document.activate(
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
tag=pre_convert_tag,
).convert(format=format)
url_base = portal.ERP5Site_getAbsoluteUrl()
attachment_link_list = [
......@@ -52,7 +56,11 @@ if prefs.getPreferredDeferredReportStoredAsDocument():
message=message_html
)
portal.portal_notifications.activate(after_tag=pre_convert_tag, activity='SQLQueue').sendMessage(
portal.portal_notifications.activate(
activity='SQLQueue',
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
after_tag=pre_convert_tag,
).sendMessage(
recipient=user_name,
subject=subject,
message=message,
......
......@@ -76,6 +76,7 @@
<string>my_preferred_deferred_report_notification_message_reference</string>
<string>my_preferred_deferred_report_classification</string>
<string>my_preferred_deferred_report_publication_section</string>
<string>my_preferred_deferred_report_activity_family</string>
</list>
</value>
</item>
......
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