diff --git a/backend/geonature/core/command/main.py b/backend/geonature/core/command/main.py index dffd7ad452..1818ee231a 100644 --- a/backend/geonature/core/command/main.py +++ b/backend/geonature/core/command/main.py @@ -138,7 +138,6 @@ def default_config(): required_fields = ( "URL_APPLICATION", "API_ENDPOINT", - "API_TAXHUB", "SECRET_KEY", "SQLALCHEMY_DATABASE_URI", ) diff --git a/backend/geonature/utils/config_schema.py b/backend/geonature/utils/config_schema.py index 395bc4e347..fb38be57d0 100644 --- a/backend/geonature/utils/config_schema.py +++ b/backend/geonature/utils/config_schema.py @@ -3,14 +3,9 @@ """ import os +import warnings -from marshmallow import ( - Schema, - fields, - validates_schema, - ValidationError, - post_load, -) +from marshmallow import Schema, fields, validates_schema, ValidationError, post_load, pre_load from marshmallow.validate import OneOf, Regexp, Email, Length from geonature.core.gn_synthese.synthese_config import ( @@ -527,7 +522,7 @@ class GnGeneralSchemaConf(Schema): DEBUG = fields.Boolean(load_default=False) URL_APPLICATION = fields.Url(required=True) API_ENDPOINT = fields.Url(required=True) - API_TAXHUB = fields.Url(required=True) + API_TAXHUB = fields.Url() CODE_APPLICATION = fields.String(load_default="GN") XML_NAMESPACE = fields.String(load_default="{http://inpn.mnhn.fr/mtd}") MTD_API_ENDPOINT = fields.Url(load_default="https://preprod-inpn.mnhn.fr/mtd") @@ -582,6 +577,16 @@ def validate_account_autovalidation(self, data, **kwargs): "AUTO_ACCOUNT_CREATION, VALIDATOR_EMAIL", ) + @pre_load + def _pre_load(self, data, **kwargs): + if "API_TAXHUB" in data: + warnings.warn( + "Le paramètre API_TAXHUB est déprécié, il sera automatiquement déduit API_ENDPOINT et supprimé dans la version 2.14", + Warning, + ) + data["API_TAXHUB"] = f"{data['API_ENDPOINT']}/taxhub/api" + return data + @post_load def insert_module_config(self, data, **kwargs): for dist in iter_modules_dist(): diff --git a/config/default_config.toml.example b/config/default_config.toml.example index 988d6bc3ad..e539be77c4 100644 --- a/config/default_config.toml.example +++ b/config/default_config.toml.example @@ -41,8 +41,6 @@ URL_APPLICATION = "http://url.com/geonature" # URL de l'API de GeoNature. Remplacer "url.com" par votre domaine ou IP API_ENDPOINT = "http://url.com/geonature/api" -# URL de l'API de Taxhub -API_TAXHUB = "http://127.0.0.1:5000/api/" # Type de session SESSION_TYPE = "filesystem" diff --git a/config/geonature_config.toml.sample b/config/geonature_config.toml.sample index 16ca60b648..6625c7a8df 100644 --- a/config/geonature_config.toml.sample +++ b/config/geonature_config.toml.sample @@ -6,7 +6,6 @@ SQLALCHEMY_DATABASE_URI = "postgresql://monuser:monpassachanger@localhost:5432/mabase" URL_APPLICATION = 'http://url.com/geonature' API_ENDPOINT = 'http://url.com/geonature/api' -API_TAXHUB = 'http://url.com/taxhub/api' # Remplacer par une clé alétoire complexe SECRET_KEY = 'super secret key' diff --git a/docs/https.rst b/docs/https.rst index 7d577558b0..ae283229cc 100644 --- a/docs/https.rst +++ b/docs/https.rst @@ -60,7 +60,6 @@ Modifier les éléments suivants : URL_APPLICATION = 'https://mondomaine.fr/geonature' API_ENDPOINT = 'https://mondomaine.fr/geonature/api' - API_TAXHUB = 'https://mondomaine.fr/taxhub/api' Pour que ces modifications soient prises en compte, exécuter les :ref:`actions à effecture après modification de la configuration `.