Skip to content

Commit

Permalink
Read Default search provider in themeConfig.json when it is used (#76)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Gwendoline Andres <[email protected]>
  • Loading branch information
gwenandres and gwenandres authored Dec 19, 2023
1 parent 6bb247d commit cc7ef77
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion src/plugins/themes/controllers/themes_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def create_form(self, theme=None):
form = ThemeForm(url=theme["url"])

crslist = ThemeUtils.get_crs(self.app, self.handler)
defaultSearchProvidersList = ThemeUtils.get_default_search_providers(self.app, self.handler)
defaultSearchProvidersList = self.themesconfig.get('defaultSearchProviders', [])

form.url.choices = [("", "---")] + ThemeUtils.get_projects(self.app, self.handler)
form.thumbnail.choices = ThemeUtils.get_mapthumbs(self.app, self.handler)
Expand Down
20 changes: 0 additions & 20 deletions src/plugins/themes/utils/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,3 @@ def get_crs(app, handler):
return (["EPSG:3857", "EPSG:3857"],
["EPSG:4647", "EPSG:4647"],
["EPSG:25832", "EPSG:25832"])

@staticmethod
def get_default_search_providers(app, handler):
"""Return default search providers"""
current_handler = handler()
config_in_path = current_handler.config().get("input_config_path")
tenantConfig = os.path.join(config_in_path, current_handler.tenant, 'tenantConfig.json')

try:
with open(tenantConfig, encoding="utf-8") as fh:
config = json.load(fh)
if "themesConfig" in config:
themes_config = config["themesConfig"]
if "defaultSearchProviders" in themes_config:
return themes_config["defaultSearchProviders"]
except IOError as e:
app.logger.error("Error reading tenantConfig.json: {}".format(
e.strerror))

return (["coordinates"])

0 comments on commit cc7ef77

Please sign in to comment.