Skip to content

Commit

Permalink
Change initconfig API REST proeperty group.mapcontrols from list to d…
Browse files Browse the repository at this point in the history
…ict.
  • Loading branch information
wlorenzetti committed Nov 8, 2023
1 parent 73f1334 commit 469b402
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions g3w-admin/core/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsCoordinateTransformContext
from copy import copy
import json


def update_serializer_data(serializer_data, data):
Expand Down Expand Up @@ -116,9 +117,6 @@ def to_representation(self, instance):
'extent': extent
}

# map controls
ret['mapcontrols'] = [mapcontrol.name for mapcontrol in instance.mapcontrols.all()]

# add projects to group
ret['projects'] = []
self.projects = {}
Expand Down Expand Up @@ -258,6 +256,21 @@ def to_representation(self, instance):
if layout_right_panel:
ret['layout']['rightpanel'] = layout_right_panel

# Mapcontrols
ret['mapcontrols'] = {}
for mapcontrol in instance.mapcontrols.all():
options = {}
if mapcontrol.name in ('nominatim', 'geolocation'):
for gp in json.loads(self.project.geocoding_providers):
if gp in settings.GEOCONDING_PROVIDERS:
options.update({
gp: settings.GEOCONDING_PROVIDERS[gp]
})

ret['mapcontrols'].update({
mapcontrol.name: options
})

return ret

class Meta:
Expand Down

0 comments on commit 469b402

Please sign in to comment.