backoffice: display timeout as is when it's not a straight number (#25090)

This commit is contained in:
Frédéric Péters 2018-07-05 17:36:28 +02:00
parent 25150c2136
commit 1733df3518
2 changed files with 29 additions and 1 deletions

View File

@ -4238,3 +4238,28 @@ def test_backoffice_forms_condition_on_button(pub):
resp = resp.click('Management', index=0)
resp = resp.follow()
assert '8 open on 50' in resp.body # only the accepted ones
def test_workflow_inspect_page(pub):
create_superuser(pub)
create_environment(pub, set_receiver=True)
workflow = Workflow.get_default_workflow()
workflow.id = '2'
st1 = workflow.add_status('Status1')
jump = JumpWorkflowStatusItem()
jump.id = '_jump'
jump.timeout = '=86400'
jump.status = 'finished'
st1.items.append(jump)
jump.parent = st1
workflow.store()
app = login(get_app(pub))
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
assert '=86400' in resp.body
jump.timeout = '82800'
workflow.store()
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
assert '23 hours' in resp.body

View File

@ -1621,7 +1621,10 @@ class WorkflowStatusItem(XmlSerialisable):
return self.render_list_of_roles(self.by)
def get_timeout_parameter_view_value(self):
return seconds2humanduration(int(self.timeout or 0))
try:
return seconds2humanduration(int(self.timeout or 0))
except ValueError:
return self.timeout # probably an expression
def get_status_parameter_view_value(self):
for status in self.parent.parent.possible_status: