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
needed through DCWorkflow API extension.
"""
kw = {}
# Try to access the workflow defined by the action
try:
workflow_tool = context.portal_workflow
......@@ -15,9 +13,8 @@ except AttributeError:
# If this is a worklist action, read the worklist definition
worklist = workflow.getWorklistValueByReference(action['worklist_id'])
for varkey in worklist.getVarMatchKeys():
kw[varkey] = worklist.getVarMatch(varkey)
kw = worklist.getIdentityCriterionDict()
# Automatically filter workflists per portal type
# so that the same state can be used for different
# worklists and they are not merged
......
......@@ -13,9 +13,10 @@ workflow = portal.portal_workflow.ticket_workflow
workflow_state_var = workflow.variables.getStateVar()
for worklist in workflow.worklists.objectValues():
identity_criterion_dict = worklist.getIdentityCriterionDict()
if portal_type \
and 'portal_type' in worklist.getVarMatchKeys() \
and portal_type not in worklist.getVarMatch('portal_type'):
and 'portal_type' in worklist.getCriterionPropertyList() \
and portal_type not in identity_criterion_dict.get('portal_type'):
continue
query_list = [{
......@@ -27,8 +28,7 @@ for worklist in workflow.worklists.objectValues():
'value': role, } for role in worklist.getGuardRoleList()]
}]
for key in worklist.getVarMatchKeys():
value = worklist.getVarMatch(key)
for key, value in identity_criterion_dict.iteritems():
if key == workflow_state_var:
# instead of having {'validation_state': 'draft'}, we want to have
# {'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 @@
</item>
<item>
<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>
<key> <string>encoding</string> </key>
......@@ -80,7 +97,9 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
<list>
<string>listbox_identity</string>
</list>
</value>
</item>
<item>
......@@ -90,14 +109,12 @@
<string>my_id</string>
<string>my_reference</string>
<string>my_title</string>
<string>my_criterion_property_list</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</string>
<string>my_icon</string>
<string>my_action_type2</string>
<string>my_action_type</string>
</list>
</value>
......@@ -152,6 +169,10 @@
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>title</string>
</list>
</value>
......@@ -42,6 +41,10 @@
<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>
......@@ -57,6 +60,10 @@
<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>
......@@ -64,18 +71,18 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>The category of the transition displayed in Action Box.</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
<value> <string>my_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </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>Display in Action Box Category</string> </value>
......
......@@ -10,14 +10,14 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>description</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_matched_portal_type_list</string> </value>
<value> <string>my_action_type2</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -42,10 +42,6 @@
<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>
......@@ -61,20 +57,6 @@
<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>
......@@ -82,27 +64,21 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>The category of the transition displayed in Action Box.</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_parallel_list_field</string> </value>
<value> <string>my_string_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>Cataloged Portal Type Matches</string> </value>
<value> <string>Display in Action Box Category</string> </value>
</item>
</dictionary>
</value>
......@@ -110,17 +86,4 @@
</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.getId(), x.getId()) for x in here.getPortalObject().portal_types.objectValues()]</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_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
AttributeBlacklistedConstraint
CaptchaPreference
GeographicalPoint
Interaction
Worklist
\ No newline at end of file
Interaction
\ No newline at end of file
......@@ -510,21 +510,7 @@ class Workflow(XMLObject):
action_box_name = worklist_definition.getActionName()
guard_role_list = worklist_definition.getGuardRoleList()
if action_box_name:
variable_match = {}
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
variable_match = worklist_definition.getIdentityCriterionDict()
portal_type_match = variable_match.get('portal_type')
if portal_type_match:
# in case the current workflow is not associated with portal_types
......@@ -540,8 +526,7 @@ class Workflow(XMLObject):
not check_guard or
worklist_definition.checkGuard(security_manager,
self,
portal,
check_roles=False)
portal)
):
format_data = TemplateDict()
format_data._push(info)
......
......@@ -35,10 +35,12 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.id_as_reference import IdAsReferenceMixin
from Products.ERP5Type.XMLObject import XMLObject
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+:)?(.*)')
class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin):
class Worklist(IdAsReferenceMixin("worklist_"), GuardableMixin, Predicate):
"""
A ERP5 Worklist.
Four Variable: portal_type; simulation_state; validation_state; causality_state
......@@ -59,9 +61,9 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin):
'DublinCore',
'Reference',
'Comment',
'Worklist',
'Guard',
'ActionInformation',
'Predicate',
)
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -124,69 +126,31 @@ class Worklist(IdAsReferenceMixin("worklist_"), XMLObject, GuardableMixin):
workflow_variable_id_list.append(worklist_variable_value.getId())
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,
'getVarMatchKeys')
@deprecated('getVarMatchKeys() deprecated; use getCriterionPropertyList()')
def getVarMatchKeys(self):
key_list = []
if self.getMatchedPortalTypeList():
key_list.append('portal_type')
if self.getMatchedSimulationStateList():
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
"""
DCWorkflow API
"""
return self.getCriterionPropertyList()
security.declareProtected(Permissions.AccessContentsInformation,
'getVarMatch')
@deprecated('getVarMatch() deprecated; use getIdentityCriterionDict()')
def getVarMatch(self, id):
""" return value of matched keys"""
matches = None
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)
""" return value of matched keys"""
return tuple(self._identity_criterion.get(id, ()))
# XXX(PERF): hack to see Category Tool responsability in new workflow slowness
security.declareProtected(Permissions.AccessContentsInformation,
'getActionType')
def getActionType(self):
......
......@@ -103,7 +103,7 @@ class PropertySheetTool(BaseTool):
'State/acquire_permission_property',
'State/selected_property',
'State/state_type_property',
'Worklist',
'Predicate',
'Workflow',
'Workflow/manager_bypass_property',
'Workflow/state_variable_property',
......
......@@ -46,9 +46,12 @@ from sets import ImmutableSet
from zLOG import LOG, WARNING
WORKLIST_METADATA_KEY = 'metadata'
SECURITY_PARAMETER_ID = 'local_roles'
COUNT_COLUMN_TITLE = 'count'
SECURITY_PARAMETER_ID = 'local_roles'
from AccessControl.SecurityInfo import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('SECURITY_PARAMETER_ID')
class WorkflowTool(BaseTool, OriginalWorkflowTool):
"""
A new container for DC workflow and workflow;
......
......@@ -50,7 +50,6 @@ class GuardableMixin(ExpressionMixin('guard_expression')):
security_manager,
workflow,
current_object,
check_roles=True,
**kw):
"""
Checks conditions in this guard. Original source code from DCWorkflow
......@@ -78,17 +77,16 @@ class GuardableMixin(ExpressionMixin('guard_expression')):
break
else:
return False
if check_roles:
guard_role_list = self.getGuardRoleList()
if guard_role_list:
# Require at least one of the given roles.
if user_roles is None:
user_roles = getRoles()
for role in guard_role_list:
if role in user_roles:
break
else:
return False
guard_role_list = self.getGuardRoleList()
if guard_role_list:
# Require at least one of the given roles.
if user_roles is None:
user_roles = getRoles()
for role in guard_role_list:
if role in user_roles:
break
else:
return False
guard_group_list = self.getGuardGroupList()
if guard_group_list:
# Require at least one of the specified groups.
......
......@@ -1045,24 +1045,8 @@ def convertToERP5Workflow(self, temp_object=False):
worklist.setTitle(qdef.title)
worklist.setReference(qdef.id)
worklist.setDescription(qdef.description)
for key, values in qdef.var_matches.items():
if key == 'portal_type':
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
for key, value in qdef.var_matches.items():
worklist.setCriterion(key, value)
worklist.setAction(qdef.actbox_url)
worklist.setActionType(qdef.actbox_category)
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