From d928195a5b8304a1c0d58c17f80cda2b403dfebf Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 11 Jun 2024 19:52:03 +0200 Subject: [PATCH] wip: rename and document UMAP_IMPORTERS --- docs/config/settings.md | 40 +++++++++++++++++++++++++++ umap/settings/base.py | 12 +------- umap/tests/integration/test_import.py | 2 +- umap/views.py | 2 +- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/docs/config/settings.md b/docs/config/settings.md index fe7273bd..8d12d55d 100644 --- a/docs/config/settings.md +++ b/docs/config/settings.md @@ -211,6 +211,46 @@ Which feed to display on the home page. Three valid values: - `"highlighted"`, which shows the maps that have been starred by a staff member - `None`, which does not show any map on the home page +#### UMAP_IMPORTERS + +Activate preset importers to connect uMap with external sources. + +Must be a dict in the form: `{"importer_name": {"option1": "value"}}`. + +Only the key is mandatory to activate an importer (eg. `{"overpass": {}}`). + +Example: + +``` +UMAP_IMPORTERS = { + "geodatamine": {"name": "my custom name"}, + "overpass": {"url": "https://overpass-api.de/api/interpreter"}, + "communesfr": {"name": "Communes françaises"}, + "datasets": { + "choices": [ + { + "label": "Régions", + "url": "https://domain.org/path/to/file.geojson", + "format": "geojson", + }, + { + "label": "Départements", + "url": "https://domain.org/path/to/other/file.csv", + "format": "csv", + }, + ] + }, +} + +``` + +Available importers: + +- `overpass`: very lite form to build a URL retrieving data from Overpass API. +- `geodatamine`: allow to interact with [GéoDataMine](https://geodatamine.fr/) API +- `communesfr`: download French communes boundaries, from https://geo.api.gouv.fr/ +- `datasets`: define URLs you want to promote to users, with a `name` and a `format` + #### UMAP_MAPS_PER_PAGE How many maps to show in maps list, like search or home page. diff --git a/umap/settings/base.py b/umap/settings/base.py index 4a925c92..efad5281 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -259,17 +259,7 @@ UMAP_DEFAULT_SHARE_STATUS = None UMAP_DEFAULT_EDIT_STATUS = None UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False UMAP_HOME_FEED = "latest" -UMAP_EXPERIMENTAL_IMPORTERS = { - # "overpass": {"url": "https://overpass-api.de/api/interpreter"}, - # "geodatamine": {}, - # "communesfr": {}, - # "presets": { - # "choices": [ - # {"label": "Régions", "url": "https://france-geojson.gregoiredavid.fr/repo/regions.geojson", "format": "geojson"}, - # {"label": "Départements", "url": "https://france-geojson.gregoiredavid.fr/repo/departements.geojson", "format": "geojson"}, - # ] - # } -} +UMAP_IMPORTERS = {} UMAP_READONLY = env("UMAP_READONLY", default=False) UMAP_GZIP = True diff --git a/umap/tests/integration/test_import.py b/umap/tests/integration/test_import.py index e8aa8e30..4be6ab8b 100644 --- a/umap/tests/integration/test_import.py +++ b/umap/tests/integration/test_import.py @@ -527,7 +527,7 @@ def test_import_geojson_from_url(page, live_server, tilelayer): def test_overpass_import_with_bbox(page, live_server, tilelayer, settings): - settings.UMAP_EXPERIMENTAL_IMPORTERS = { + settings.UMAP_IMPORTERS = { "overpass": {"url": "https://my.overpass.io/interpreter"} } page.goto(f"{live_server.url}/map/new/") diff --git a/umap/views.py b/umap/views.py index 93bbcfcb..349e66d5 100644 --- a/umap/views.py +++ b/umap/views.py @@ -505,7 +505,7 @@ class MapDetailMixin: "featuresHaveOwner": settings.UMAP_DEFAULT_FEATURES_HAVE_OWNERS, "websocketEnabled": settings.WEBSOCKET_ENABLED, "websocketURI": settings.WEBSOCKET_FRONT_URI, - "importers": settings.UMAP_EXPERIMENTAL_IMPORTERS, + "importers": settings.UMAP_IMPORTERS, } created = bool(getattr(self, "object", None)) if (created and self.object.owner) or (not created and not user.is_anonymous):