0001-forms-load-geolocation-javascript-for-geocoded-text-.patch
tests/test_form_pages.py | ||
---|---|---|
3996 | 3996 |
data = formdef.data_class().get(data_id) |
3997 | 3997 |
assert data.data == {'1': 'bla', '0': '1.234;-1.234'} |
3998 | 3998 | |
3999 |
def test_form_map_geolocation_text_field(pub): |
|
4000 |
formdef = create_formdef() |
|
4001 |
formdef.fields = [ |
|
4002 |
fields.MapField(id='0', label='map'), |
|
4003 |
fields.TextField(id='1', label='street', required=True, |
|
4004 |
prefill={'type': 'geolocation', 'value': 'road'}), |
|
4005 |
] |
|
4006 |
formdef.store() |
|
4007 |
resp = get_app(pub).get('/test/') |
|
4008 |
formdef.data_class().wipe() |
|
4009 |
assert 'qommon.map.js' in resp.text |
|
4010 |
assert 'qommon.geolocation.js' in resp.text |
|
4011 | ||
3999 | 4012 |
def test_form_map_field_prefill_address(pub): |
4000 | 4013 |
formdef = create_formdef() |
4001 | 4014 |
formdef.fields = [ |
wcs/qommon/form.py | ||
---|---|---|
519 | 519 | |
520 | 520 | |
521 | 521 |
class TextWidget(quixote.form.TextWidget): |
522 |
prefill_attributes = None |
|
523 | ||
522 | 524 |
def __init__(self, name, *args, **kwargs): |
523 | 525 |
self.validation_function = kwargs.pop('validation_function', None) |
524 | 526 |
super(TextWidget, self).__init__(name, *args, **kwargs) |
525 | 527 | |
528 |
def add_media(self): |
|
529 |
if self.prefill_attributes and 'geolocation' in self.prefill_attributes: |
|
530 |
get_response().add_javascript(['qommon.geolocation.js']) |
|
531 | ||
526 | 532 |
def _parse(self, request): |
527 | 533 |
quixote.form.TextWidget._parse(self, request) |
528 | 534 |
if self.value is not None: |
529 |
- |