From 44c8764f9f7ef76fcd8be4811cceab4968c0f888 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Mon, 18 Mar 2024 17:25:00 +0100 Subject: [PATCH] add deprecated warnings --- backend/geonature/utils/config_schema.py | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/backend/geonature/utils/config_schema.py b/backend/geonature/utils/config_schema.py index 50861a9230..9fce3d906e 100644 --- a/backend/geonature/utils/config_schema.py +++ b/backend/geonature/utils/config_schema.py @@ -4,13 +4,9 @@ import os -from marshmallow import ( - Schema, - fields, - validates_schema, - ValidationError, - post_load, -) +from warnings import warn + +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 ( @@ -441,6 +437,22 @@ class Synthese(Schema): # Activate the blurring of sensitive observations. Otherwise, exclude them BLUR_SENSITIVE_OBSERVATIONS = fields.Boolean(load_default=True) + @pre_load + def warn_deprecated(self, data, **kwargs): + deprecated = { + "EXPORT_ID_SYNTHESE_COL", + "EXPORT_ID_DIGITISER_COL", + "EXPORT_OBSERVERS_COL", + "EXPORT_GEOJSON_4326_COL", + "EXPORT_GEOJSON_LOCAL_COL", + } + for deprecated_field in deprecated & set(data.keys()): + warn( + f"{deprecated_field} is deprecated - " + "Please use `EXPORT_OBSERVATIONS_CUSTOM_VIEWS` parameter to customize your synthese exports " + ) + return data + # Map configuration BASEMAP = [