workflows: add form action details in list of actions (#76014) #669

Merged
fpeters merged 1 commits from wip/76014-form-action-line-details into main 2023-09-15 08:01:00 +02:00
3 changed files with 25 additions and 1 deletions

View File

@ -1584,7 +1584,7 @@ def test_workflows_edit_display_form_action(pub):
resp.forms[0]['action-interaction'] = 'Form'
resp = resp.forms[0].submit().follow()
resp = resp.click(re.compile('^Form$'))
resp = resp.click(r'Form \(not completed\)')
resp.form['varname'] = 'myform'
resp = resp.forms[0].submit('submit').follow()
# fields page

View File

@ -794,3 +794,22 @@ def test_workflow_form_file_access(pub):
account.user_id = user.id
account.store()
login(get_app(pub), username='foo2', password='foo2').get(resp.pyquery('#t1').attr.href, status=403)
def test_workflow_form_line_details(pub):
workflow = Workflow(name='choice')
st1 = workflow.add_status('Status1', 'st1')
display_form = st1.add_action('form')
assert display_form.get_line_details() == 'not completed'
role = pub.role_class(name='foorole')
role.store()
display_form.by = [role.id]
assert display_form.get_line_details() == 'not completed'
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
display_form.formdef.fields = [
fields.BlockField(id='1', label='test', block_slug='foobar', varname='fooblock'),
]
assert display_form.get_line_details() == 'by foorole'

View File

@ -135,6 +135,11 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
# force new defaut value
self.hide_submit_button = True
def get_line_details(self):
if not self.formdef or not self.by:
return _('not completed')
return _('by %s') % self.render_list_of_roles(self.by)
@property
def submit_button_label(self):
# make submit button go to fields page when there are not yet any field.