workflows: always prefix target status with "to" (#21228) #598
|
@ -1400,7 +1400,7 @@ def test_workflows_edit_jump_timeout(pub):
|
|||
resp.form['timeout'] = ''
|
||||
resp = resp.form.submit('submit').follow().follow()
|
||||
assert Workflow.get(workflow.id).possible_status[0].items[0].timeout is None
|
||||
assert 'Automatic Jump (baz)' in resp.text
|
||||
assert 'Automatic Jump (to baz)' in resp.text
|
||||
|
||||
resp = app.get('/backoffice/workflows/1/status/1/items/_jump/')
|
||||
resp.form['timeout'] = '90 minutes'
|
||||
|
|
|
@ -148,6 +148,22 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_jump_type_label(self):
|
||||
reasons = []
|
||||
if self.condition and self.condition.get('value'):
|
||||
reasons.append(_('condition'))
|
||||
if self.trigger:
|
||||
reasons.append(_('trigger'))
|
||||
if self.timeout:
|
||||
reasons.append(_('timeout'))
|
||||
return ', '.join([str(x) for x in reasons])
|
||||
|
||||
def get_jump_label(self, target_id):
|
||||
jump_type_label = self.get_jump_type_label()
|
||||
if jump_type_label:
|
||||
return '%s (%s)' % (self.description, jump_type_label)
|
||||
return self.description
|
||||
|
||||
def render_as_line(self):
|
||||
# override parent method to avoid mentioning the condition twice.
|
||||
return '%s (%s)' % (self.description, self.get_line_details())
|
||||
|
@ -158,21 +174,14 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
wf_status = self.get_target_status()
|
||||
if not wf_status:
|
||||
return _('broken')
|
||||
reasons = []
|
||||
if self.condition and self.condition.get('value'):
|
||||
reasons.append(_('condition'))
|
||||
if self.trigger:
|
||||
reasons.append(_('trigger'))
|
||||
if self.timeout:
|
||||
reasons.append(_('timeout'))
|
||||
|
||||
if reasons:
|
||||
return _('to %(name)s, %(reasons)s') % {
|
||||
jump_type_label = self.get_jump_type_label()
|
||||
if jump_type_label:
|
||||
return _('to %(name)s, %(jump_type_label)s') % {
|
||||
'name': wf_status[0].name,
|
||||
'reasons': ', '.join([str(x) for x in reasons]),
|
||||
'jump_type_label': jump_type_label,
|
||||
}
|
||||
else:
|
||||
return wf_status[0].name
|
||||
return _('to %s') % wf_status[0].name
|
||||
|
||||
def get_parameters(self):
|
||||
if hasattr(self, 'parent') and isinstance(self.parent, WorkflowGlobalAction):
|
||||
|
|
|
@ -23,6 +23,9 @@ class JumpOnSubmitWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
key = 'jumponsubmit'
|
||||
ok_in_global_action = False
|
||||
|
||||
def get_jump_label(self, target_id):
|
||||
return self.description
|
||||
|
||||
def get_line_details(self):
|
||||
if self.status:
|
||||
if self.get_target_status():
|
||||
|
|
Loading…
Reference in New Issue