misc: fix prefilling of workflow form (#12557)
This commit is contained in:
parent
a121aa9318
commit
312d810c1f
|
@ -2130,7 +2130,6 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(pub,
|
|||
assert resp.content_type == 'application/pdf'
|
||||
assert resp.body.startswith('%PDF-')
|
||||
|
||||
|
||||
def test_formdata_form_file_download(pub):
|
||||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
|
@ -2177,6 +2176,38 @@ def test_formdata_form_file_download(pub):
|
|||
# codepath.
|
||||
resp = resp.follow()
|
||||
|
||||
def test_formdata_workflow_form_prefill(pub):
|
||||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
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', varname='yyy', prefill={'type': 'user', 'value': 'email'}))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
formdef = create_formdef()
|
||||
formdef.workflow_id = wf.id
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
|
||||
resp = login(get_app(pub), username='foo', password='foo').get('/test/')
|
||||
resp = resp.forms[0].submit('submit')
|
||||
assert 'Check values then click submit.' in resp.body
|
||||
resp = resp.forms[0].submit('submit')
|
||||
assert resp.status_int == 302
|
||||
resp = resp.follow()
|
||||
assert 'The form has been recorded' in resp.body
|
||||
assert resp.forms[0]['f1'].value == 'foo@localhost'
|
||||
|
||||
def test_form_map_field_back_and_submit(pub):
|
||||
formdef = create_formdef()
|
||||
formdef.fields = [
|
||||
|
|
|
@ -153,7 +153,7 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
if get_request().is_in_backoffice():
|
||||
prefill_user = get_publisher().substitutions.get_context_variables(
|
||||
).get('form_user')
|
||||
v = field.get_prefill_value(user=prefill_user)
|
||||
v, verified = field.get_prefill_value(user=prefill_user)
|
||||
if get_request().is_in_backoffice() and (
|
||||
field.prefill and field.prefill.get('type') == 'geoloc'):
|
||||
# turn off prefilling from geolocation attributes if
|
||||
|
|
Loading…
Reference in New Issue