1085 |
1085 |
# go back to the status page, this will exercise the substitution variables
|
1086 |
1086 |
# codepath.
|
1087 |
1087 |
resp = resp.follow()
|
|
1088 |
|
|
1089 |
def test_form_map_field_back_and_submit(pub):
|
|
1090 |
formdef = create_formdef()
|
|
1091 |
formdef.fields = [
|
|
1092 |
fields.MapField(id='0', label='map'),
|
|
1093 |
fields.StringField(id='1', label='street', required=False,
|
|
1094 |
prefill={'type': 'geolocation', 'value': 'road'}),
|
|
1095 |
]
|
|
1096 |
formdef.store()
|
|
1097 |
resp = get_app(pub).get('/test/')
|
|
1098 |
formdef.data_class().wipe()
|
|
1099 |
assert 'qommon.map.js' in resp.body
|
|
1100 |
assert 'qommon.geolocation.js' in resp.body
|
|
1101 |
# with a real user interaction this would get set by javascript
|
|
1102 |
resp.forms[0]['f0$latlng'] = '1.234;-1.234'
|
|
1103 |
assert 'data-geolocation="road"' in resp.body
|
|
1104 |
|
|
1105 |
# check summary page
|
|
1106 |
resp = resp.forms[0].submit('submit')
|
|
1107 |
assert 'Check values then click submit.' in resp.body
|
|
1108 |
assert 'data-init-lng="-1.234"' in resp.body
|
|
1109 |
assert 'data-init-lat="1.234"' in resp.body
|
|
1110 |
|
|
1111 |
# get back to the map field
|
|
1112 |
resp = resp.forms[0].submit('previous')
|
|
1113 |
# check the field is still marked as holding the road
|
|
1114 |
assert 'data-geolocation="road"' in resp.body
|
|
1115 |
assert resp.forms[0]['f0$latlng'].value == '1.234;-1.234'
|
|
1116 |
|
|
1117 |
# back to summary page
|
|
1118 |
resp = resp.forms[0].submit('submit')
|
|
1119 |
|
|
1120 |
# and submitting the form
|
|
1121 |
resp = resp.forms[0].submit('submit')
|
|
1122 |
assert resp.status_int == 302
|
|
1123 |
resp = resp.follow()
|
|
1124 |
assert 'The form has been recorded' in resp.body
|
|
1125 |
assert formdef.data_class().count() == 1
|
|
1126 |
data_id = formdef.data_class().select()[0].id
|
|
1127 |
data = formdef.data_class().get(data_id)
|
|
1128 |
assert data.data == {'1': None, '0': '1.234;-1.234'}
|