Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for geocoding mapcontrol. #726

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion g3w-admin/client/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def testGroupConfigApiView(self):
'extent': [-180.0, -90.0, 180.0, 90.0]
})
print(resp["group"]["mapcontrols"])
self.assertEqual(resp["group"]["mapcontrols"], {'zoom': {}, 'zoombox': {}, 'zoomtoextent': {}, 'query': {}, 'querybbox': {}, 'querybypolygon': {}, 'overview': {}, 'scaleline': {}, 'geolocation': {}, 'streetview': {}, 'geocoding': {}, 'addlayers': {}, 'length': {}, 'area': {}, 'mouseposition': {}, 'scale': {}})
self.assertEqual(resp["group"]["mapcontrols"], {'zoom': {}, 'zoombox': {}, 'zoomtoextent': {}, 'query': {}, 'querybbox': {}, 'querybypolygon': {}, 'overview': {}, 'scaleline': {}, 'geolocation': {}, 'streetview': {}, 'geocoding': {'providers': {}}, 'addlayers': {}, 'length': {}, 'area': {}, 'mouseposition': {}, 'scale': {}})
self.assertEqual(resp["group"]["header_logo_img"], "logo_img/qgis-logo.png")
self.assertEqual(resp["group"]["name"], "Gruppo 1")
self.assertIsNone(resp["group"]["header_logo_link"])
Expand Down
13 changes: 7 additions & 6 deletions g3w-admin/core/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,14 @@ def to_representation(self, instance):
ret['mapcontrols'] = {}
for mapcontrol in instance.mapcontrols.all():
options = {}
if mapcontrol.name in ('nominatim', 'geocoding') and self.project.geocoding_providers:
if mapcontrol.name in ('nominatim', 'geocoding'):
options = {'providers': {}}
for gp in json.loads(self.project.geocoding_providers):
if gp in settings.GEOCODING_PROVIDERS:
options['providers'].update({
gp: settings.GEOCODING_PROVIDERS[gp]
})
if self.project.geocoding_providers:
for gp in json.loads(self.project.geocoding_providers):
if gp in settings.GEOCODING_PROVIDERS:
options['providers'].update({
gp: settings.GEOCODING_PROVIDERS[gp]
})

ret['mapcontrols'].update({
mapcontrol.name: options
Expand Down
Loading