Commit 30d115c8 authored by Jérome Perrin's avatar Jérome Perrin

Some fixes for ERP5 Workflow

See merge request !1532
parents f844ca79 91af570a
import urlparse
import unittest
from erp5.component.mixin.TestWorkflowMixin import TestWorkflowMixin
from Products.ERP5Type.Core.Workflow import ValidationFailed
......@@ -434,7 +435,10 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
modified_role_dict['View'] = ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Author', 'Manager')
self.workflow.state_draft.setStatePermissionRoleListDict(modified_role_dict)
self.tic()
self.workflow.Workflow_updateSecurityRoles()
ret = self.workflow.Workflow_updateSecurityRoles()
self.assertEqual(
urlparse.parse_qs(urlparse.urlparse(ret).query)['portal_status_message'],
["1 documents updated."])
self.tic()
self.assertEqual(text_document._View_Permission, ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Author', 'Manager'))
self.workflow.state_draft.setStatePermissionRoleListDict(default_role_dict)
......
"""
Changes permissions of all objects related to this workflow
"""
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
ACTIVITY_GROUPING_COUNT = 100
def updateRoleMappings(self, REQUEST=None):
"""
Changes permissions of all objects related to this workflow
"""
portal_type_id_list = self.getPortalTypeListForWorkflow()
if portal_type_id_list:
object_list = self.portal_catalog(portal_type=portal_type_id_list, limit=None)
portal_activities = self.portal_activities
portal_type_id_list = context.getPortalTypeListForWorkflow()
object_list = []
if portal_type_id_list:
object_list = portal.portal_catalog(portal_type=portal_type_id_list, limit=None)
portal_activities_activate = portal.portal_activities.activate
object_path_list = [x.path for x in object_list]
for i in xrange(0, len(object_list), ACTIVITY_GROUPING_COUNT):
current_path_list = object_path_list[i:i+ACTIVITY_GROUPING_COUNT]
portal_activities.activate(activity='SQLQueue',
priority=3)\
.callMethodOnObjectList(current_path_list,
portal_activities_activate(
activity='SQLQueue',
priority=3,
).callMethodOnObjectList(
current_path_list,
'updateRoleMappingsFor',
wf_id = self.getId())
else:
object_list = []
if REQUEST is not None:
message = 'No object updated.'
if object_list:
message = '%d object(s) updated: \n %s.' % (len(object_list),
', '.join([o.getTitleOrId() + ' (' + o.getPortalType() + ')'
for o in object_list]))
return message
else:
return len(object_list)
message = updateRoleMappings(context, context.REQUEST)
wf_id=context.getId(),
)
message = translateString('No document updated.')
if object_list:
message = translateString(
'${document_count} documents updated.',
mapping={'document_count': len(object_list)},
)
return context.Base_redirect(form_id, keep_items={'portal_status_message': message})
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=None</string> </value>
<value> <string>form_id=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -834,7 +834,6 @@ class Workflow(XMLObject):
if object_context is None:
# XXX(WORKFLOW): investigate: should I keep source value here, or can I use old_state (see test results also)
object_context = self.getStateChangeInformation(ob, self.getSourceValue())
object_context.REQUEST.other.update(kwargs)
for vdef in self.getVariableValueList():
variable_id = vdef.getId()
......
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