Commit 2236eda0 authored by Ivan Tyagov's avatar Ivan Tyagov

Added a script that can be called in workflow after scripts to notify...

Added a script that can be called in workflow after scripts to notify document's owner for a change in the workflow state of the document itself.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14739 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b43b9a60
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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 encoding="cdata"><![CDATA[
"""\n
This function sends a notification mail to users who have checked the\n
corresponding option in their preference and who have a Role in the\n
passed list of Roles in the context of the document.\n
"""\n
\n
owner_id = \'\'\n
user_ids = []\n
roles_to_inform = (\'Owner\', \'Assignor\', \'Author\',)\n
\n
# get list of user_ids from local roles\n
# XXX: find persons having good enough roles in this object\n
local_roles = context.showDict()[\'__ac_local_roles__\']\n
for user_id, groups in local_roles.items():\n
if \'Owner\' in groups:\n
owner_id = user_id\n
# check if this local role is interested to be informed\n
intersect = [k for k in groups if k in roles_to_inform]\n
if len(intersect) > 0:\n
user_ids.append(user_id)\n
\n
# find person owner of object\n
owners = context.portal_catalog(portal_type = \'Person\', \n
reference = owner_id)\n
# email templates\n
if event in (\'release\',):\n
subject_template = \'[DMS] Document owned by you was released.\'\n
email_template = """Your document "%(name)s" was released.\n
\n
click here: %(url)s/view to check it."""\n
elif event in (\'publish\',):\n
subject_template = \'[DMS] Document owned by you was published.\'\n
email_template = """Your document "%(name)s" was published.\n
\n
click here: %(url)s/view to check it."""\n
\n
# send email to owner\n
for person in owners:\n
email_subject = subject_template %dict(name = context.getTitle())\n
email_text = email_template % dict(name = context.getTitle(),\n
url = context.absolute_url())\n
email_to = person.getDefaultEmailText()\n
context.MailHost.send(messageText = email_text, \n
mto = email_to, \n
mfrom = \'dms@dms.nexedi.com\', \n
subject = email_subject)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>event=\'publish\'</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>event</string>
<string>owner_id</string>
<string>user_ids</string>
<string>roles_to_inform</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>context</string>
<string>local_roles</string>
<string>_getiter_</string>
<string>user_id</string>
<string>groups</string>
<string>append</string>
<string>$append0</string>
<string>k</string>
<string>intersect</string>
<string>len</string>
<string>owners</string>
<string>subject_template</string>
<string>email_template</string>
<string>person</string>
<string>dict</string>
<string>email_subject</string>
<string>email_text</string>
<string>email_to</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>publish</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Document_notifyOnChange</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</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