workflows: adapt trigger roles label for functions (#76674) #888

Merged
fpeters merged 1 commits from wip/76674-trigger-role-labels into main 2023-12-04 14:40:03 +01:00
2 changed files with 24 additions and 1 deletions

View File

@ -1498,6 +1498,25 @@ def test_workflows_edit_jump_timeout(pub):
assert resp.text.count('ComputedExpressionWidget') == 1
def test_workflows_edit_jump_trigger_functions_roles_label(pub):
create_superuser(pub)
Workflow.wipe()
workflow = Workflow(name='foo')
st1 = workflow.add_status(name='baz')
jump = st1.add_action('jump')
workflow.store()
app = login(get_app(pub))
resp = app.get(jump.get_admin_url())
assert resp.pyquery('#form_label_by').text() == 'Functions or roles allowed to trigger'
pub.site_options.set('options', 'workflow-functions-only', 'true')
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
pub.site_options.write(fd)
resp = app.get(jump.get_admin_url())
assert resp.pyquery('#form_label_by').text() == 'Functions allowed to trigger'
def test_workflows_jump_target_links(pub):
create_superuser(pub)
Workflow.wipe()

View File

@ -230,10 +230,14 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
size=40,
)
if 'by' in parameters:
if get_publisher().has_site_option('workflow-functions-only'):
label = _('Functions allowed to trigger')
else:
label = _('Functions or roles allowed to trigger')
form.add(
WidgetList,
'%sby' % prefix,
title=_('Roles allowed to trigger'),
title=label,
element_type=SingleSelectWidget,
value=self.by,
add_element_label=self.get_add_role_label(),