misc: make identifier of status manual actions unique (#75321)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7e4375e203
commit
cb6fe33c70
|
@ -835,7 +835,7 @@ def test_backoffice_multi_actions_jump(pub):
|
|||
ids.append(checkbox._value)
|
||||
checkbox.checked = True
|
||||
|
||||
resp = resp.forms['multi-actions'].submit('button-action-st-new-accept')
|
||||
resp = resp.forms['multi-actions'].submit('button-action-st-new-accept-_accept')
|
||||
assert '?job=' in resp.location
|
||||
resp = resp.follow()
|
||||
assert 'Executing task "Accept" on forms' in resp.text
|
||||
|
@ -905,7 +905,7 @@ def test_backoffice_multi_actions_jump_condition(pub):
|
|||
}
|
||||
workflow.store()
|
||||
|
||||
resp = resp.forms['multi-actions'].submit('button-action-st-new-accept')
|
||||
resp = resp.forms['multi-actions'].submit('button-action-st-new-accept-_accept')
|
||||
assert '?job=' in resp.location
|
||||
resp = resp.follow()
|
||||
assert 'Executing task "Accept" on forms' in resp.text
|
||||
|
|
|
@ -881,7 +881,7 @@ class Workflow(StorableObject):
|
|||
class StatusAction:
|
||||
def __init__(self, action):
|
||||
self.status_id = action.parent.id
|
||||
self.id = 'st-%s-%s' % (self.status_id, action.identifier)
|
||||
self.id = 'st-%s-%s-%s' % (self.status_id, action.identifier, action.id)
|
||||
self.name = action.get_label()
|
||||
self.status_action = True
|
||||
self.require_confirmation = action.require_confirmation
|
||||
|
@ -897,14 +897,20 @@ class Workflow(StorableObject):
|
|||
actions = []
|
||||
choices = [x for x in get_actions(self) if x.key == 'choice' and x.identifier]
|
||||
|
||||
seen = set()
|
||||
for action in choices:
|
||||
roles = action.by or []
|
||||
functions = [x for x in roles if x in (self.roles or [])]
|
||||
roles = [x for x in roles if x not in (self.roles or [])]
|
||||
if functions or roles:
|
||||
status_action = StatusAction(action)
|
||||
if status_action.id in seen:
|
||||
# prevent multiple action with the same identifier to be shown
|
||||
continue
|
||||
seen.add(status_action.id)
|
||||
actions.append(
|
||||
{
|
||||
'action': StatusAction(action),
|
||||
'action': status_action,
|
||||
'roles': roles,
|
||||
'functions': functions,
|
||||
'statuses': [action.parent.id],
|
||||
|
|
Loading…
Reference in New Issue