Skip to content

Commit

Permalink
Infer API_TAXHUB from API_ENDPOINT + remove use of API_TAXHUB in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Aug 2, 2023
1 parent 8dc224f commit 3036c5f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion backend/geonature/core/command/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def default_config():
required_fields = (
"URL_APPLICATION",
"API_ENDPOINT",
"API_TAXHUB",
"SECRET_KEY",
"SQLALCHEMY_DATABASE_URI",
)
Expand Down
21 changes: 13 additions & 8 deletions backend/geonature/utils/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 0 additions & 2 deletions config/default_config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion config/geonature_config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion docs/https.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <post_config_change>`.

Expand Down

0 comments on commit 3036c5f

Please sign in to comment.