Commit bb96987c authored by Alexandre Boeglin's avatar Alexandre Boeglin

Add action, skins, scripts that allow updating workflows (workflow title and...

Add action, skins, scripts that allow updating workflows (workflow title and desc, state title and desc, transition title and desc, transition action name) from english glossary terms.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20864 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c09f1ad9
......@@ -51,7 +51,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>27.0</float> </value>
<value> <float>28.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_workflows_by_english_glossary</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Modify portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>27.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Workflows by English Glossary</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/GlossaryModule_viewWorkflowUpdateDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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>from Products.ERP5Type.Document import newTempBase\n
marker = []\n
\n
result = []\n
\n
portal_catalog = context.portal_catalog\n
portal_workflow = context.portal_workflow\n
portal_templates = context.portal_templates\n
\n
def get_term_list(business_field, reference):\n
term_list = portal_catalog(portal_type=\'Glossary Term\',\n
validation_state=\'validated\',\n
language_id=\'en\',\n
business_field_title=business_field,\n
reference=reference)\n
return [i.getObject() for i in term_list]\n
\n
def get_obj_and_reference_list(business_field):\n
result = []\n
bt = portal_templates.getInstalledBusinessTemplate("erp5_%s" % business_field)\n
for wf_id in bt.getTemplateWorkflowIdList():\n
wf = getattr(portal_workflow, wf_id)\n
if getattr(wf, "interactions", marker) is marker: # only way to make sure it is not an interaction workflow ?\n
result.append((wf, wf_id, \'workflow\'))\n
for state_id, state in wf.states.items():\n
result.append((state, state_id, \'state\'))\n
for trans_id, trans in wf.transitions.items():\n
result.append((trans, trans_id, \'transition\'))\n
if trans.trigger_type == 1 and trans.actbox_name: # 1 == TRIGGER_USER_ACTION\n
result.append((trans, "%s_actbox_name" % trans_id, \'action\'))\n
return result\n
\n
business_field_list = [i for i in business_field_list if i]\n
\n
line_list = []\n
c = 0\n
for business_field in business_field_list:\n
for wf_item, reference, type in get_obj_and_reference_list(business_field):\n
term_list = get_term_list(business_field, reference)\n
if not term_list:\n
continue\n
\n
line = newTempBase(context, \'tmp_glossary_wf_item_%s\' % c)\n
c += 1\n
if type == \'workflow\':\n
wf_item_path = wf_item.id\n
wf_item_title = wf_item.title\n
elif type == \'state\':\n
wf_item_path = \'%s/states/%s\' % (wf_item.aq_parent.aq_parent.id, wf_item.id)\n
wf_item_title = wf_item.title\n
elif type == \'transition\':\n
wf_item_path = \'%s/transitions/%s\' % (wf_item.aq_parent.aq_parent.id, wf_item.id)\n
wf_item_title = wf_item.title\n
else: # type == \'action\'\n
wf_item_path = \'%s/transitions/%s_actbox_name\' % (wf_item.aq_parent.aq_parent.id, wf_item.id)\n
wf_item_title = wf_item.actbox_name\n
\n
\n
line.edit(wf_item_path=wf_item_path,\n
wf_item_type=type,\n
wf_item_title=wf_item_title,\n
wf_item_edit_url = "%s/manage_properties" % wf_item.absolute_url(),\n
reference=reference,\n
term_list=term_list\n
)\n
line.setUid(wf_item_path)\n
line_list.append(line)\n
\n
return line_list\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>business_field_list, **kw</string> </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>business_field_list</string>
<string>kw</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>marker</string>
<string>result</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_catalog</string>
<string>portal_workflow</string>
<string>portal_templates</string>
<string>get_term_list</string>
<string>get_obj_and_reference_list</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>i</string>
<string>line_list</string>
<string>c</string>
<string>business_field</string>
<string>wf_item</string>
<string>reference</string>
<string>type</string>
<string>term_list</string>
<string>line</string>
<string>_inplacevar_</string>
<string>wf_item_path</string>
<string>wf_item_title</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GlossaryModule_getBusinessFieldWorkflowList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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>return brain.wf_item_edit_url\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>brain, **kw</string> </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>brain</string>
<string>kw</string>
<string>_getattr_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GlossaryModule_getWorkflowItemEditUrl</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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>prefix = \'field_listbox_term_\'\n
prefix_length = len(prefix)\n
suffix = \'_actbox_name\'\n
suffix_length = len(suffix)\n
portal_workflow = context.portal_workflow\n
portal_catalog = context.portal_catalog\n
\n
for i in kw.keys():\n
is_action = 0\n
if not(i.startswith(prefix) and kw[i]):\n
continue\n
\n
term_uid = int(kw[i])\n
term = portal_catalog(uid=term_uid)[0].getObject()\n
\n
wf_item_path = i[prefix_length:]\n
if wf_item_path.endswith(suffix):\n
wf_item_path = wf_item_path[:-suffix_length]\n
is_action = 1\n
wf_item = portal_workflow.restrictedTraverse(wf_item_path)\n
\n
if wf_item.meta_type == "Workflow":\n
wf_item.setProperties(term.getTitle(), description=term.getDescription(), manager_bypass=wf_item.manager_bypass)\n
elif wf_item.meta_type == "Workflow State":\n
wf_item.setProperties(term.getTitle(), description=term.getDescription(),\n
transitions=wf_item.transitions, type_list=wf_item.type_list)\n
else: # wf_item.meta_type == "Workflow Transition"\n
if not is_action:\n
wf_item.setProperties(\n
term.getTitle(),\n
wf_item.new_state_id,\n
description=term.getDescription(),\n
\n
trigger_type=wf_item.trigger_type,\n
script_name=wf_item.script_name,\n
after_script_name=wf_item.after_script_name,\n
actbox_name = wf_item.actbox_name,\n
actbox_url = wf_item.actbox_url,\n
actbox_category = wf_item.actbox_category)\n
else:\n
wf_item.setProperties(\n
wf_item.title,\n
wf_item.new_state_id,\n
description=term.getDescription(),\n
\n
trigger_type=wf_item.trigger_type,\n
script_name=wf_item.script_name,\n
after_script_name=wf_item.after_script_name,\n
actbox_name = term.getTitle(),\n
actbox_url = wf_item.actbox_url,\n
actbox_category = wf_item.actbox_category)\n
\n
portal_status_message = context.Base_translateString(\'Workflows updated.\')\n
context.Base_redirect(keep_items={\'portal_status_message\':portal_status_message})\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>**kw</string> </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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>kw</string>
<string>prefix</string>
<string>len</string>
<string>prefix_length</string>
<string>suffix</string>
<string>suffix_length</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_workflow</string>
<string>portal_catalog</string>
<string>_getiter_</string>
<string>i</string>
<string>is_action</string>
<string>_getitem_</string>
<string>int</string>
<string>term_uid</string>
<string>term</string>
<string>wf_item_path</string>
<string>wf_item</string>
<string>portal_status_message</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GlossaryModule_updateWorkflowByTerm</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>GlossaryModule_updateWorkflowByTerm</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_term</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GlossaryModule_viewWorkflowAndTermComparisonDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>GlossaryModule_viewWorkflowAndTermConparisonDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Workflows</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>GlossaryModule_viewWorkflowAndTermComparisonDialog</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>You can update existing field\'s title and description by english glossary.</string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_business_field_list</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GlossaryModule_viewWorkflowUpdateDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>GlossaryModule_viewFieldUpdateDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Compare</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
* The glossary module "Update Workflows by English Glossary" Action uses DCorkflow's API method "setProperties". In case of future patches or updates, this must be reviewed, as there is a risk of overwriting important data
\ No newline at end of file
227
\ No newline at end of file
228
\ No newline at end of file
......@@ -13,6 +13,7 @@ Glossary Module | export_po_file
Glossary Module | find_terms_from_property_sheet
Glossary Module | find_terms_from_workflow
Glossary Module | update_fields_by_english_glossary
Glossary Module | update_workflows_by_english_glossary
Glossary Module | view
Glossary Term | view
Preference | subversion
......
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