1113 |
1113 |
resp.body.index('<label for="form_prefill">Prefill</label>')
|
1114 |
1114 |
|
1115 |
1115 |
# complete the "prefill" field
|
1116 |
|
resp.forms[0]['prefill$type'] = 'String'
|
|
1116 |
resp.forms[0]['prefill$type'] = 'String / Template'
|
1117 |
1117 |
resp.forms[0]['prefill$value_string'] = 'test'
|
1118 |
1118 |
resp = resp.forms[0].submit('submit')
|
1119 |
1119 |
assert resp.location == 'http://example.net/backoffice/forms/1/fields/#itemId_1'
|
... | ... | |
1154 |
1154 |
app = login(get_app(pub))
|
1155 |
1155 |
|
1156 |
1156 |
resp = app.get('/backoffice/forms/1/fields/1/')
|
1157 |
|
resp.form['prefill$type'] = 'String'
|
|
1157 |
resp.form['prefill$type'] = 'String / Template'
|
1158 |
1158 |
resp.form['prefill$value_string'] = 'test'
|
1159 |
1159 |
resp = resp.form.submit('submit').follow()
|
1160 |
1160 |
assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'string', 'value': 'test'}
|
1161 |
1161 |
|
1162 |
1162 |
resp = app.get('/backoffice/forms/1/fields/1/')
|
1163 |
|
resp.form['prefill$type'] = 'Formula (Python)'
|
|
1163 |
resp.form['prefill$type'] = 'Python Expression'
|
1164 |
1164 |
resp.form['prefill$value_formula'] = 'True'
|
1165 |
1165 |
resp = resp.form.submit('submit').follow()
|
1166 |
1166 |
assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'formula', 'value': 'True'}
|
1167 |
1167 |
|
1168 |
1168 |
resp = app.get('/backoffice/forms/1/fields/1/')
|
1169 |
|
resp.form['prefill$type'] = 'String'
|
|
1169 |
resp.form['prefill$type'] = 'String / Template'
|
1170 |
1170 |
resp.form['prefill$value_string'] = '{{form_var_toto}}'
|
1171 |
1171 |
resp = resp.form.submit('submit').follow()
|
1172 |
1172 |
assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'string', 'value': '{{form_var_toto}}'}
|
1173 |
1173 |
|
1174 |
1174 |
# check error handling
|
1175 |
1175 |
resp = app.get('/backoffice/forms/1/fields/1/')
|
1176 |
|
resp.form['prefill$type'] = 'Formula (Python)'
|
|
1176 |
resp.form['prefill$type'] = 'Python Expression'
|
1177 |
1177 |
resp.form['prefill$value_formula'] = ':'
|
1178 |
1178 |
resp = resp.form.submit('submit')
|
1179 |
1179 |
assert 'invalid expression: unexpected EOF while parsing' in resp.body
|
1180 |
1180 |
|
1181 |
1181 |
resp = app.get('/backoffice/forms/1/fields/1/')
|
1182 |
|
resp.form['prefill$type'] = 'String'
|
|
1182 |
resp.form['prefill$type'] = 'String / Template'
|
1183 |
1183 |
resp.form['prefill$value_string'] = '{% if %}'
|
1184 |
1184 |
resp = resp.form.submit('submit')
|
1185 |
1185 |
assert 'syntax error in Django template: Unexpected end of expression' in resp.body
|
... | ... | |
1268 |
1268 |
resp = resp.follow()
|
1269 |
1269 |
resp = resp.click('Edit', href='1/')
|
1270 |
1270 |
assert resp.forms[0]['prefill$type'].options == [
|
1271 |
|
(u'None', True, u'None'), (u'Formula (Python)', False, u'Formula (Python)')]
|
|
1271 |
(u'None', True, u'None'), (u'Python Expression', False, u'Python Expression')]
|
1272 |
1272 |
|
1273 |
1273 |
def test_form_edit_page_field(pub):
|
1274 |
1274 |
create_superuser(pub)
|