Commit cf2805e6 authored by Jérome Perrin's avatar Jérome Perrin Committed by Gabriel Monnerat

Allow to select a notification message to set the text content when creating an event

parent c961dde4
......@@ -115,6 +115,11 @@ event_kw = {\n
# Create event\n
module = portal.getDefaultModule(portal_type=portal_type)\n
event = module.newContent(**event_kw)\n
\n
if notification_message:\n
event.Event_setTextContentFromNotificationMessage(\n
reference=notification_message)\n
\n
if not keep_draft:\n
if direction == \'incoming\':\n
# Support event_workflow and event_simulation_workflow\n
......@@ -135,7 +140,7 @@ event.Base_redirect(keep_items={\'portal_status_message\': message})\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, direction, portal_type, resource, text_content=None, batch_mode=False, keep_draft=False, **kw</string> </value>
<value> <string>title, direction, portal_type, resource, text_content=None, notification_message=None, batch_mode=False, keep_draft=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -81,6 +81,7 @@
<key> <string>center</string> </key>
<value>
<list>
<string>your_notification_message</string>
<string>your_text_content</string>
<string>your_keep_draft</string>
</list>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_notification_message</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</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>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Notification Message</string> </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>here/Event_getNotificationMessageItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -66,6 +66,12 @@ response = module.newContent(portal_type=response_event_portal_type,\n
follow_up_list=context.getFollowUpList(),\n
content_type=context.getContentType())\n
\n
if response_event_notification_message:\n
response.Event_setTextContentFromNotificationMessage(\n
reference=response_event_notification_message,\n
substitution_method_parameter_dict=dict(reply_body=context.getReplyBody(),\n
reply_subject=context.getReplySubject()))\n
\n
message = portal.Base_translateString(\'Response Created.\')\n
if response_workflow_action == \'send\':\n
# use doActionFor to initialise workflow variable\n
......@@ -82,7 +88,7 @@ else:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=None, response_event_portal_type=None, response_event_resource=None, response_event_title=None, response_event_text_content=None, response_event_start_date=None, response_workflow_action=None, **kw</string> </value>
<value> <string>form_id=None, response_event_portal_type=None, response_event_resource=None, response_event_title=None, response_event_text_content=None, response_event_start_date=None, response_workflow_action=None, response_event_notification_message=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return [\'\'] + [(notification_message.getTranslatedTitle(), notification_message.getReference())\n
for notification_message in context.getPortalObject().portal_catalog(\n
validation_state=\'validated\', portal_type=\'Notification Message\')]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Event_getNotificationMessageItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
notification_message = portal.portal_notifications.getDocumentValue(\n
language=language or context.getLanguage(),\n
reference=reference)\n
\n
if substitution_method_parameter_dict is None:\n
substitution_method_parameter_dict=dict()\n
# Notification method will receive the current event under "event_value" key.\n
# This way notification method can return properties from recipient or follow up of the event.\n
substitution_method_parameter_dict.setdefault(\'event_value\', context)\n
\n
target_format = "txt"\n
if context.getTextFormat() == \'text/html\':\n
target_format = "html"\n
\n
if notification_message is not None:\n
mime, text_content = notification_message.convert(target_format,\n
substitution_method_parameter_dict=substitution_method_parameter_dict)\n
context.setTextContent(text_content)\n
context.setAggregateList(notification_message.getProperty(\'aggregate_list\', []))\n
\n
if not context.hasTitle():\n
context.setTitle(notification_message.asSubjectText(\n
substitution_method_parameter_dict=substitution_method_parameter_dict))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference, language=None, substitution_method_parameter_dict=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Event_setTextContentFromNotificationMessage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -73,6 +73,7 @@
<key> <string>center</string> </key>
<value>
<list>
<string>your_response_event_notification_message</string>
<string>your_response_event_text_content</string>
<string>your_response_workflow_action</string>
</list>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_response_event_notification_message</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</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>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Notification Message</string> </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>here/Event_getNotificationMessageItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>def getSubstitutionMappingDict():\n
kw.update(\n
destination_title=event_value.getDestinationTitle() or \'\',\n
destination_portal_type=event_value.getDestination() and event_value.getDestinationValue().getTranslatedPortalType(),\n
destination_social_title=event_value.getDestination() and event_value.getDestinationValue().getProperty(\'social_title_translated_title\') or \'\',\n
destination_reference=event_value.getDestination() and event_value.getDestinationValue().getReference() or \'\',\n
source_title=event_value.getSourceTitle() or \'\',\n
)\n
return kw\n
\n
if context.hasLanguage():\n
with context.getPortalObject().Localizer.translationContext(context.getLanguage()):\n
return getSubstitutionMappingDict()\n
return getSubstitutionMappingDict()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>event_value, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>NotificationMessage_getSubstitutionMappingDictFromEvent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -76,6 +76,11 @@ event = module.newContent(portal_type=portal_type, \n
start_date=DateTime(),\n
follow_up=context.getRelativeUrl())\n
\n
\n
if notification_message:\n
event.Event_setTextContentFromNotificationMessage(\n
reference=notification_message)\n
\n
# Trigger appropriate workflow action\n
if not keep_draft:\n
if direction == \'incoming\':\n
......@@ -96,7 +101,7 @@ return event.Base_redirect(\'view\', keep_items = dict(portal_status_message=por
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', portal_type=None, title=None, resource=None, text_content=None,direction=None, source=None, destination=None, keep_draft=False, **kw</string> </value>
<value> <string>form_id=\'view\', portal_type=None, title=None, resource=None, text_content=None,direction=None, source=None, destination=None, keep_draft=False, notification_message=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -75,6 +75,7 @@
<key> <string>center</string> </key>
<value>
<list>
<string>your_notification_message</string>
<string>your_text_content</string>
<string>your_keep_draft</string>
</list>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_notification_message</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</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>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Notification Message</string> </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>here/Event_getNotificationMessageItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
623
\ No newline at end of file
624
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