Commit 49de5527 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: ERP5Workflow: Worklist is a Predicate.

parent 0ff01552
...@@ -4,8 +4,6 @@ It includes some copy / paste of code from DCWorkflow. Refactoring ...@@ -4,8 +4,6 @@ It includes some copy / paste of code from DCWorkflow. Refactoring
needed through DCWorkflow API extension. needed through DCWorkflow API extension.
""" """
kw = {}
# Try to access the workflow defined by the action # Try to access the workflow defined by the action
try: try:
workflow_tool = context.portal_workflow workflow_tool = context.portal_workflow
...@@ -15,9 +13,8 @@ except AttributeError: ...@@ -15,9 +13,8 @@ except AttributeError:
# If this is a worklist action, read the worklist definition # If this is a worklist action, read the worklist definition
worklist = workflow.getWorklistValueByReference(action['worklist_id']) worklist = workflow.getWorklistValueByReference(action['worklist_id'])
for varkey in worklist.getVarMatchKeys(): kw = worklist.getIdentityCriterionDict()
kw[varkey] = worklist.getVarMatch(varkey)
# Automatically filter workflists per portal type # Automatically filter workflists per portal type
# so that the same state can be used for different # so that the same state can be used for different
# worklists and they are not merged # worklists and they are not merged
......
...@@ -13,9 +13,10 @@ workflow = portal.portal_workflow.ticket_workflow ...@@ -13,9 +13,10 @@ workflow = portal.portal_workflow.ticket_workflow
workflow_state_var = workflow.variables.getStateVar() workflow_state_var = workflow.variables.getStateVar()
for worklist in workflow.worklists.objectValues(): for worklist in workflow.worklists.objectValues():
identity_criterion_dict = worklist.getIdentityCriterionDict()
if portal_type \ if portal_type \
and 'portal_type' in worklist.getVarMatchKeys() \ and 'portal_type' in worklist.getCriterionPropertyList() \
and portal_type not in worklist.getVarMatch('portal_type'): and portal_type not in identity_criterion_dict.get('portal_type'):
continue continue
query_list = [{ query_list = [{
...@@ -27,8 +28,7 @@ for worklist in workflow.worklists.objectValues(): ...@@ -27,8 +28,7 @@ for worklist in workflow.worklists.objectValues():
'value': role, } for role in worklist.getGuardRoleList()] 'value': role, } for role in worklist.getGuardRoleList()]
}] }]
for key in worklist.getVarMatchKeys(): for key, value in identity_criterion_dict.iteritems():
value = worklist.getVarMatch(key)
if key == workflow_state_var: if key == workflow_state_var:
# instead of having {'validation_state': 'draft'}, we want to have # instead of having {'validation_state': 'draft'}, we want to have
# {'translated_validation_state_title': 'Brouillon'} # {'translated_validation_state_title': 'Brouillon'}
......
workflow = context.getParentValue()
state_variable = workflow.getStateVariable()
from Products.ERP5Type.Tool.WorkflowTool import SECURITY_PARAMETER_ID
item_list = [(state_variable, state_variable),
(SECURITY_PARAMETER_ID, SECURITY_PARAMETER_ID)]
for variable in workflow.getVariableValueList():
if variable.isForCatalog():
variable_reference = variable.getReference()
item_list.append((variable_reference, variable_reference))
return item_list
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Worklist_getCriterionPropertyItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -35,7 +35,24 @@ ...@@ -35,7 +35,24 @@
</item> </item>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>Base_edit</string> </value> <value> <string>Predicate_edit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list>
<string>membership_criterion_category_list</string>
<string>membership_criterion_document_list</string>
</list>
</value>
</item> </item>
<item> <item>
<key> <string>encoding</string> </key> <key> <string>encoding</string> </key>
...@@ -80,7 +97,9 @@ ...@@ -80,7 +97,9 @@
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <value>
<list/> <list>
<string>listbox_identity</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -90,14 +109,12 @@ ...@@ -90,14 +109,12 @@
<string>my_id</string> <string>my_id</string>
<string>my_reference</string> <string>my_reference</string>
<string>my_title</string> <string>my_title</string>
<string>my_criterion_property_list</string>
<string>my_description</string> <string>my_description</string>
<string>my_matched_portal_type_list</string>
<string>my_matched_simulation_state_list</string>
<string>my_matched_validation_state_list</string>
<string>my_matched_causality_state_list</string>
<string>my_action_name</string> <string>my_action_name</string>
<string>my_action</string> <string>my_action</string>
<string>my_icon</string> <string>my_icon</string>
<string>my_action_type2</string>
<string>my_action_type</string> <string>my_action_type</string>
</list> </list>
</value> </value>
...@@ -152,6 +169,10 @@ ...@@ -152,6 +169,10 @@
<key> <string>update_action</string> </key> <key> <string>update_action</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>description</string>
<string>title</string> <string>title</string>
</list> </list>
</value> </value>
...@@ -42,6 +41,10 @@ ...@@ -42,6 +41,10 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -57,6 +60,10 @@ ...@@ -57,6 +60,10 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -64,18 +71,18 @@ ...@@ -64,18 +71,18 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>The category of the transition displayed in Action Box.</string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value> <value> <string>my_category</string> </value>
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Display in Action Box Category</string> </value> <value> <string>Display in Action Box Category</string> </value>
......
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>items</string> <string>description</string>
<string>title</string> <string>title</string>
</list> </list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_matched_portal_type_list</string> </value> <value> <string>my_action_type2</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -42,10 +42,6 @@ ...@@ -42,10 +42,6 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -61,20 +57,6 @@ ...@@ -61,20 +57,6 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </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> </dictionary>
</value> </value>
</item> </item>
...@@ -82,27 +64,21 @@ ...@@ -82,27 +64,21 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>The category of the transition displayed in Action Box.</string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_parallel_list_field</string> </value> <value> <string>my_string_field</string> </value>
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </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> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Cataloged Portal Type Matches</string> </value> <value> <string>Display in Action Box Category</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -110,17 +86,4 @@ ...@@ -110,17 +86,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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: [(x.getId(), x.getId()) for x in here.getPortalObject().portal_types.objectValues()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
<?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>my_matched_causality_state_list</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_parallel_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>Matched Causality State</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>python: [(x.getTitle(), x.getReference()) for x in here.getParent().objectValues(portal_type=\'State\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>my_matched_simulation_state_list</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_parallel_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>Matched Simulation State</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>python: [(x.getTitle(), x.getReference()) for x in here.getParent().objectValues(portal_type=\'State\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>my_matched_validation_state_list</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_parallel_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>Matched Validation State</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>python: [(x.getTitle(), x.getReference()) for x in here.getParent().objectValues(portal_type=\'State\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Worklist</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?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/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>matched_causality_state</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matched_causality_state_property</string> </value>
</item>
<item>
<key> <string>multivalued</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matched_portal_type_property</string> </value>
</item>
<item>
<key> <string>multivalued</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matched_simulation_state_property</string> </value>
</item>
<item>
<key> <string>multivalued</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matched_validation_state_property</string> </value>
</item>
<item>
<key> <string>multivalued</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -193,5 +193,4 @@ XMLObject ...@@ -193,5 +193,4 @@ XMLObject
AttributeBlacklistedConstraint AttributeBlacklistedConstraint
CaptchaPreference CaptchaPreference
GeographicalPoint GeographicalPoint
Interaction Interaction
Worklist \ No newline at end of file
\ No newline at end of file
...@@ -510,21 +510,7 @@ class Workflow(XMLObject): ...@@ -510,21 +510,7 @@ class Workflow(XMLObject):
action_box_name = worklist_definition.getActionName() action_box_name = worklist_definition.getActionName()
guard_role_list = worklist_definition.getGuardRoleList() guard_role_list = worklist_definition.getGuardRoleList()
if action_box_name: if action_box_name:
variable_match = {} variable_match = worklist_definition.getIdentityCriterionDict()
for key in worklist_definition.getVarMatchKeys():
var = worklist_definition.getVarMatch(key)
if isinstance(var, Expression):
if state_change_information is None:
state_change_information = StateChangeInfo(portal, self,
kwargs=info.__dict__.copy())
if expression_context is None:
expression_context = createExpressionContext(state_change_information)
evaluated_value = var(expression_context)
if isinstance(evaluated_value, (str, int, long)):
evaluated_value = [str(evaluated_value)]
else:
evaluated_value = [x % info for x in var]
variable_match[key] = evaluated_value
portal_type_match = variable_match.get('portal_type') portal_type_match = variable_match.get('portal_type')
if portal_type_match: if portal_type_match:
# in case the current workflow is not associated with portal_types # in case the current workflow is not associated with portal_types
...@@ -540,8 +526,7 @@ class Workflow(XMLObject): ...@@ -540,8 +526,7 @@ class Workflow(XMLObject):
not check_guard or not check_guard or
worklist_definition.checkGuard(security_manager, worklist_definition.checkGuard(security_manager,
self, self,
portal, portal)
check_roles=False)
): ):
format_data = TemplateDict() format_data = TemplateDict()
format_data._push(info) format_data._push(info)
......
...@@ -35,10 +35,12 @@ from Products.ERP5Type import Permissions ...@@ -35,10 +35,12 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.id_as_reference import IdAsReferenceMixin from Products.ERP5Type.id_as_reference import IdAsReferenceMixin
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.mixin.guardable import GuardableMixin from Products.ERP5Type.mixin.guardable import GuardableMixin
from Products.ERP5Type.Core.Predicate import Predicate
from Products.ERP5Type.Utils import deprecated
tales_re = re.compile(r'(\w+:)?(.*)') tales_re = re.compile(r'(\w+:)?(.*)')
class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin): class Worklist(IdAsReferenceMixin("worklist_"), GuardableMixin, Predicate):
""" """
A ERP5 Worklist. A ERP5 Worklist.
Four Variable: portal_type; simulation_state; validation_state; causality_state Four Variable: portal_type; simulation_state; validation_state; causality_state
...@@ -59,9 +61,9 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin): ...@@ -59,9 +61,9 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin):
'DublinCore', 'DublinCore',
'Reference', 'Reference',
'Comment', 'Comment',
'Worklist',
'Guard', 'Guard',
'ActionInformation', 'ActionInformation',
'Predicate',
) )
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -124,69 +126,31 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin): ...@@ -124,69 +126,31 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin):
workflow_variable_id_list.append(worklist_variable_value.getId()) workflow_variable_id_list.append(worklist_variable_value.getId())
return res return res
security.declareProtected(Permissions.AccessContentsInformation,
'getVariableMatchDict')
def getIdentityCriterionDict(self):
"""
XXX: Move this to Predicate class?
"""
return dict(self._identity_criterion)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVarMatchKeys') 'getVarMatchKeys')
@deprecated('getVarMatchKeys() deprecated; use getCriterionPropertyList()')
def getVarMatchKeys(self): def getVarMatchKeys(self):
key_list = [] """
if self.getMatchedPortalTypeList(): DCWorkflow API
key_list.append('portal_type') """
if self.getMatchedSimulationStateList(): return self.getCriterionPropertyList()
key_list.append('simulation_state')
if self.getMatchedValidationStateList():
key_list.append('validation_state')
if self.getMatchedCausalityState():
key_list.append('causality_state')
key_list += [dynamic_variable.getReference() for dynamic_variable in self.objectValues()
if dynamic_variable.getVariableDefaultValue() or dynamic_variable.getVariableDefaultExpression()]
return key_list
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVarMatch') 'getVarMatch')
@deprecated('getVarMatch() deprecated; use getIdentityCriterionDict()')
def getVarMatch(self, id): def getVarMatch(self, id):
""" return value of matched keys""" """ return value of matched keys"""
matches = None return tuple(self._identity_criterion.get(id, ()))
if id == 'portal_type':
v = self.getMatchedPortalTypeList()
if v: matches = tuple(v)
elif id in ['validation_state', 'simulation_state', 'causality_state']:
if id == 'validation_state':
match_reference_list = self.getMatchedValidationStateList()
elif id == 'simulation_state':
match_reference_list = self.getMatchedSimulationStateList()
elif id == 'causality_state':
match_reference_list = self.getMatchedCausalityStateList()
matches = tuple(match_reference_list)
elif id:
# Local dynamic variable:
dynamic_variable = self._getOb('variable_'+id)
dynamic_variable_value = dynamic_variable.getVariableDefaultValue()
if dynamic_variable_value:
matches = [dynamic_variable_value]
# Override initial value if expression set:
dynamic_variable_default_expression = dynamic_variable.getVariableDefaultExpressionInstance()
if dynamic_variable_default_expression:
matches = dynamic_variable_default_expression
if matches not in ([], None):
if not isinstance(matches, (tuple, Expression)):
# Old version, convert it.
matches = tuple(matches)
return matches
else:
return ()
security.declareProtected(Permissions.AccessContentsInformation,
'getVarMatchText')
def getVarMatchText(self, id):
values = self.getVarMatch(id)
if isinstance(values, Expression):
return values.text
return '; '.join(values)
# XXX(PERF): hack to see Category Tool responsability in new workflow slowness # XXX(PERF): hack to see Category Tool responsability in new workflow slowness
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getActionType') 'getActionType')
def getActionType(self): def getActionType(self):
......
...@@ -103,7 +103,7 @@ class PropertySheetTool(BaseTool): ...@@ -103,7 +103,7 @@ class PropertySheetTool(BaseTool):
'State/acquire_permission_property', 'State/acquire_permission_property',
'State/selected_property', 'State/selected_property',
'State/state_type_property', 'State/state_type_property',
'Worklist', 'Predicate',
'Workflow', 'Workflow',
'Workflow/manager_bypass_property', 'Workflow/manager_bypass_property',
'Workflow/state_variable_property', 'Workflow/state_variable_property',
......
...@@ -46,9 +46,12 @@ from sets import ImmutableSet ...@@ -46,9 +46,12 @@ from sets import ImmutableSet
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
WORKLIST_METADATA_KEY = 'metadata' WORKLIST_METADATA_KEY = 'metadata'
SECURITY_PARAMETER_ID = 'local_roles'
COUNT_COLUMN_TITLE = 'count' COUNT_COLUMN_TITLE = 'count'
SECURITY_PARAMETER_ID = 'local_roles'
from AccessControl.SecurityInfo import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('SECURITY_PARAMETER_ID')
class WorkflowTool(BaseTool, OriginalWorkflowTool): class WorkflowTool(BaseTool, OriginalWorkflowTool):
""" """
A new container for DC workflow and workflow; A new container for DC workflow and workflow;
......
...@@ -50,7 +50,6 @@ class GuardableMixin(ExpressionMixin('guard_expression')): ...@@ -50,7 +50,6 @@ class GuardableMixin(ExpressionMixin('guard_expression')):
security_manager, security_manager,
workflow, workflow,
current_object, current_object,
check_roles=True,
**kw): **kw):
""" """
Checks conditions in this guard. Original source code from DCWorkflow Checks conditions in this guard. Original source code from DCWorkflow
...@@ -78,17 +77,16 @@ class GuardableMixin(ExpressionMixin('guard_expression')): ...@@ -78,17 +77,16 @@ class GuardableMixin(ExpressionMixin('guard_expression')):
break break
else: else:
return False return False
if check_roles: guard_role_list = self.getGuardRoleList()
guard_role_list = self.getGuardRoleList() if guard_role_list:
if guard_role_list: # Require at least one of the given roles.
# Require at least one of the given roles. if user_roles is None:
if user_roles is None: user_roles = getRoles()
user_roles = getRoles() for role in guard_role_list:
for role in guard_role_list: if role in user_roles:
if role in user_roles: break
break else:
else: return False
return False
guard_group_list = self.getGuardGroupList() guard_group_list = self.getGuardGroupList()
if guard_group_list: if guard_group_list:
# Require at least one of the specified groups. # Require at least one of the specified groups.
......
...@@ -1045,24 +1045,8 @@ def convertToERP5Workflow(self, temp_object=False): ...@@ -1045,24 +1045,8 @@ def convertToERP5Workflow(self, temp_object=False):
worklist.setTitle(qdef.title) worklist.setTitle(qdef.title)
worklist.setReference(qdef.id) worklist.setReference(qdef.id)
worklist.setDescription(qdef.description) worklist.setDescription(qdef.description)
for key, values in qdef.var_matches.items(): for key, value in qdef.var_matches.items():
if key == 'portal_type': worklist.setCriterion(key, value)
worklist.setMatchedPortalTypeList(values)
elif key == 'simulation_state':
worklist.setMatchedSimulationStateList(values)
elif key == 'validation_state':
worklist.setMatchedValidationStateList(values)
elif key == 'causality_state':
worklist.setMatchedCausalityState(values)
else:
# dynamic variable.
worklist_variable_value = worklist.newContent(portal_type='Worklist Variable',
reference=key)
if isinstance(values, Expression):
worklist_variable_value.setVariableDefaultExpression(values.text)
else:
worklist_variable_value.setVariableDefaultValue(values[0]) #XXX(WORKFLOW): to be changed
worklist.setAction(qdef.actbox_url) worklist.setAction(qdef.actbox_url)
worklist.setActionType(qdef.actbox_category) worklist.setActionType(qdef.actbox_category)
worklist.setIcon(qdef.actbox_icon) worklist.setIcon(qdef.actbox_icon)
......
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