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 from Products.ERP5Type.Message import translateString
portal = context.getPortalObject() portal = context.getPortalObject()
request = portal.REQUEST request = portal.REQUEST
format = request.get('format', '') format_ = request.get('format', '')
skin_name = request.get('deferred_portal_skin', portal.portal_skins.getDefaultSkin()) skin_name = request.get('deferred_portal_skin', portal.portal_skins.getDefaultSkin())
previous_skin_selection = request.get('previous_skin_selection', None) previous_skin_selection = request.get('previous_skin_selection', None)
...@@ -43,10 +43,13 @@ if hasattr(form, 'ZScriptHTML_tryParams'): ...@@ -43,10 +43,13 @@ if hasattr(form, 'ZScriptHTML_tryParams'):
for param in form.ZScriptHTML_tryParams(): for param in form.ZScriptHTML_tryParams():
params[param] = request.get(param) params[param] = request.get(param)
else: else:
params['format'] = format params['format'] = format_
activity_context.activate( 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, localizer_language=localizer_language,
skin_name=skin_name, skin_name=skin_name,
request_form=request_form, request_form=request_form,
......
...@@ -20,7 +20,7 @@ if person_value.getDefaultEmailText('') in ('', None): ...@@ -20,7 +20,7 @@ if person_value.getDefaultEmailText('') in ('', None):
tag = 'active-report-%s' % random.randint(0, 1000) tag = 'active-report-%s' % random.randint(0, 1000)
priority = 2 priority = 2
format = request.get('format', '') format_ = request.get('format', '')
skin_name = request['deferred_portal_skin'] skin_name = request['deferred_portal_skin']
# save request parameters (after calling the report_method which may tweak the # save request parameters (after calling the report_method which may tweak the
...@@ -29,14 +29,19 @@ request_other = portal.ERP5Site_filterRequestForDeferredStyle(request) ...@@ -29,14 +29,19 @@ request_other = portal.ERP5Site_filterRequestForDeferredStyle(request)
localizer_language = portal.Localizer.get_selected_language() localizer_language = portal.Localizer.get_selected_language()
context.activate(activity="SQLQueue", tag=tag, after_tag=after_tag, context.activate(
priority=priority).Base_computeReportSection( activity="SQLQueue",
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
tag=tag,
after_tag=after_tag,
priority=priority,
).Base_computeReportSection(
form=form.getId(), form=form.getId(),
request_other=request_other, request_other=request_other,
user_name=user.getId(), user_name=user.getId(),
tag=tag, tag=tag,
skin_name=skin_name, skin_name=skin_name,
format=format, format=format_,
priority=priority, priority=priority,
localizer_language=localizer_language, localizer_language=localizer_language,
**kw) **kw)
......
# pylint: disable=redefined-builtin
portal = context.getPortalObject() portal = context.getPortalObject()
form = context.restrictedTraverse(form) form = context.restrictedTraverse(form)
...@@ -28,6 +29,7 @@ for idx, report_section in enumerate(report_section_list): ...@@ -28,6 +29,7 @@ for idx, report_section in enumerate(report_section_list):
else: else:
doc = context doc = context
doc.activate(activity='SQLQueue', doc.activate(activity='SQLQueue',
node=portal.portal_preferences.getPreferredDeferredReportActivityFamily(),
active_process=active_process, active_process=active_process,
tag=tag, tag=tag,
priority=priority, priority=priority,
...@@ -42,7 +44,12 @@ if activity_context == portal: ...@@ -42,7 +44,12 @@ if activity_context == portal:
# portal is not an active object # portal is not an active object
activity_context = portal.portal_simulation 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(), active_process_url=active_process.getRelativeUrl(),
skin_name=skin_name, skin_name=skin_name,
localizer_language=localizer_language, localizer_language=localizer_language,
......
...@@ -16,7 +16,6 @@ with portal.Localizer.translationContext(localizer_language): ...@@ -16,7 +16,6 @@ with portal.Localizer.translationContext(localizer_language):
else: else:
form = None form = None
selection_name = request.get('prefixed_selection_name')
data = context.render_report_section.pt_render( data = context.render_report_section.pt_render(
extra_context=dict(form=form, extra_context=dict(form=form,
first=report_section_idx == 0, first=report_section_idx == 0,
......
from Products.ERP5Type.Message import translateString # pylint: disable=redefined-builtin
request = container.REQUEST request = container.REQUEST
request.other.update(request_other) request.other.update(request_other)
......
# pylint: disable=redefined-builtin
from Products.PythonScripts.standard import newline_to_br, html_quote from Products.PythonScripts.standard import newline_to_br, html_quote
portal = context.getPortalObject() portal = context.getPortalObject()
prefs = portal.portal_preferences prefs = portal.portal_preferences
...@@ -18,7 +19,10 @@ if prefs.getPreferredDeferredReportStoredAsDocument(): ...@@ -18,7 +19,10 @@ if prefs.getPreferredDeferredReportStoredAsDocument():
(attachment.get('title', document.getStandardFilename(format=format)), document.getRelativeUrl())) (attachment.get('title', document.getStandardFilename(format=format)), document.getRelativeUrl()))
# pre-convert document before sending notification # pre-convert document before sending notification
if format: 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() url_base = portal.ERP5Site_getAbsoluteUrl()
attachment_link_list = [ attachment_link_list = [
...@@ -52,7 +56,11 @@ if prefs.getPreferredDeferredReportStoredAsDocument(): ...@@ -52,7 +56,11 @@ if prefs.getPreferredDeferredReportStoredAsDocument():
message=message_html 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, recipient=user_name,
subject=subject, subject=subject,
message=message, message=message,
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<string>my_preferred_deferred_report_notification_message_reference</string> <string>my_preferred_deferred_report_notification_message_reference</string>
<string>my_preferred_deferred_report_classification</string> <string>my_preferred_deferred_report_classification</string>
<string>my_preferred_deferred_report_publication_section</string> <string>my_preferred_deferred_report_publication_section</string>
<string>my_preferred_deferred_report_activity_family</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ListField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_deferred_report_activity_family</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>unknown_selection</string> </key>
<value> <string>You selected an item that was not in the list.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Activity Family to Compute Reports</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\', \'\')] + context.getPortalObject().portal_activities.getFamilyNameList()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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