workflows: allow functions with duplicated name in dispatch settings (#44179)

This commit is contained in:
Frédéric Péters 2020-06-17 18:25:23 +02:00
parent 63e2d4e9e8
commit 36bce17ca3
2 changed files with 32 additions and 1 deletions

View File

@ -2740,6 +2740,37 @@ def test_workflows_edit_dispatch_action(pub):
{'value': 'FOOBAR', 'role_id': '1'}, {'value': 'BARFOO', 'role_id': '1'}]
def test_workflows_edit_dispatch_action_repeated_function(pub):
create_superuser(pub)
role = create_role()
Workflow.wipe()
workflow = Workflow(name='foo')
workflow.add_status(name='baz')
workflow.roles = {
'_receiver': 'Recipient',
'manager': 'Manager',
'manager2': 'Manager',
}
workflow.store()
app = login(get_app(pub))
resp = app.get('/backoffice/workflows/1/')
resp = resp.click('baz')
resp.forms[0]['action-formdata-action'] = 'Function/Role Linking'
resp = resp.forms[0].submit()
resp = resp.follow()
resp = resp.click('Function/Role Linking')
resp.form['role_key'].value = 'manager2'
resp = resp.form.submit('submit')
resp = resp.follow()
resp = resp.follow()
workflow = Workflow.get(workflow.id)
assert workflow.possible_status[0].items[0].role_key == 'manager2'
def test_workflows_edit_email_action(pub):
create_superuser(pub)
role = create_role()

View File

@ -138,7 +138,7 @@ class DispatchWorkflowStatusItem(WorkflowStatusItem):
self.parent.parent.roles = {}
form.add(SingleSelectWidget, '%srole_key' % prefix,
title=_('Function to Set'), value=self.role_key,
options=[(None, '----')] + list(self.parent.parent.roles.items()))
options=[(None, '----', None)] + [(x, y, x) for x, y in self.parent.parent.roles.items()])
dispatch_types = collections.OrderedDict(
[('manual', _('Simple')), ('automatic', _('Multiple'))])
if 'dispatch_type' in parameters: