Skip to content

Commit

Permalink
add deprecated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Mar 20, 2024
1 parent 1666553 commit d607d65
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions backend/geonature/utils/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(

Check warning on line 450 in backend/geonature/utils/config_schema.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/utils/config_schema.py#L450

Added line #L450 was not covered by tests
f"{deprecated_field} is deprecated - "
"Please use `EXPORT_OBSERVATIONS_CUSTOM_VIEWS` parameter to customize your synthese exports "
)
return data


# Map configuration
BASEMAP = [
Expand Down

0 comments on commit d607d65

Please sign in to comment.