workflows: ignore form errors when clicking on global action button (#39098)
This commit is contained in:
parent
b682b2e9c4
commit
cdb71d3628
|
@ -6385,6 +6385,61 @@ def test_condition_on_action(pub, emails):
|
|||
assert emails.get('New form2 (test condition on action)')
|
||||
|
||||
|
||||
def test_user_global_action_along_form(pub):
|
||||
# check it's possible to click on a global action button even if there's a
|
||||
# form with required fields.
|
||||
user = create_user(pub)
|
||||
|
||||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment.comment = 'HELLO WORLD GLOBAL ACTION'
|
||||
jump = action.append_item('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = ['_submitter']
|
||||
|
||||
status = workflow.get_status('new')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(fields.StringField(id='1', label='blah',
|
||||
type='string', required=True))
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'test global action'
|
||||
formdef.fields = []
|
||||
formdef.workflow_id = workflow.id
|
||||
formdef.workflow_roles = {}
|
||||
formdef.store()
|
||||
|
||||
formdef.data_class().wipe()
|
||||
|
||||
app = login(get_app(pub), username='foo', password='foo')
|
||||
resp = app.get(formdef.get_url())
|
||||
resp = resp.form.submit('submit')
|
||||
resp = resp.form.submit('submit')
|
||||
|
||||
assert formdef.data_class().count() == 1
|
||||
formdata = formdef.data_class().select()[0]
|
||||
|
||||
resp = app.get(formdata.get_url())
|
||||
assert resp.form['f1'].attrs['aria-required'] == 'true'
|
||||
assert 'button-action-1' in resp.form.fields
|
||||
resp = resp.form.submit('button-action-1')
|
||||
|
||||
resp = app.get(formdata.get_url())
|
||||
assert 'HELLO WORLD GLOBAL ACTION' in resp.text
|
||||
assert formdef.data_class().get(formdata.id).status == 'wf-finished'
|
||||
|
||||
|
||||
def test_email_actions(pub, emails):
|
||||
user = create_user(pub)
|
||||
|
||||
|
|
|
@ -1507,8 +1507,11 @@ class WorkflowStatus(object):
|
|||
|
||||
for action in filled.formdef.workflow.get_global_actions_for_user(filled, user):
|
||||
form.add_submit('button-action-%s' % action.id, action.name)
|
||||
if form.get_widget('button-action-%s' % action.id):
|
||||
form.get_widget('button-action-%s' % action.id).backoffice_info_text = action.backoffice_info_text
|
||||
widget = form.get_widget('button-action-%s' % action.id)
|
||||
if widget:
|
||||
widget.backoffice_info_text = action.backoffice_info_text
|
||||
widget.ignore_form_errors = True
|
||||
widget.attrs['formnovalidate'] = 'formnovalidate'
|
||||
|
||||
if form.widgets or form.submit_widgets:
|
||||
return form
|
||||
|
|
Loading…
Reference in New Issue