diff --git a/backend/geonature/core/gn_synthese/routes.py b/backend/geonature/core/gn_synthese/routes.py index 9899d9bb0b..36083f81be 100644 --- a/backend/geonature/core/gn_synthese/routes.py +++ b/backend/geonature/core/gn_synthese/routes.py @@ -911,7 +911,10 @@ def general_stats(permissions): - nb of datasets """ nb_allowed_datasets = db.session.scalar( - select(func.count("*")).select_from(TDatasets.select.filter_by_readable()) + select(func.count("*")) + .select_from(TDatasets) + .where(TDatasets.filter_by_readable().whereclause) + ) query = select( func.count(Synthese.id_synthese), diff --git a/backend/geonature/core/sensitivity/utils.py b/backend/geonature/core/sensitivity/utils.py index 2ccbfac848..5ec278ff83 100644 --- a/backend/geonature/core/sensitivity/utils.py +++ b/backend/geonature/core/sensitivity/utils.py @@ -37,23 +37,19 @@ def insert_sensitivity_referential(source, csvfile): defaults_nomenclatures = { statut_biologique_nomenclature_type: set( db.session.scalars( - sa.select(Nomenclature) - .where( + sa.select(Nomenclature).where( Nomenclature.nomenclature_type == statut_biologique_nomenclature_type, Nomenclature.mnemonique.in_(["Inconnu", "Non renseigné", "Non Déterminé"]), ) - .all() - ) + ).all() ), behaviour_nomenclature_type: set( db.session.scalars( - sa.select(Nomenclature) - .where( + sa.select(Nomenclature).where( Nomenclature.nomenclature_type == behaviour_nomenclature_type, Nomenclature.mnemonique.in_(["NSP", "1"]), ) - .all() - ) + ).all() ), } diff --git a/backend/geonature/core/users/routes.py b/backend/geonature/core/users/routes.py index a59c2311c6..5ac9726901 100644 --- a/backend/geonature/core/users/routes.py +++ b/backend/geonature/core/users/routes.py @@ -134,7 +134,7 @@ def get_role(id_role): :param id_role: the id user :type id_role: int """ - user = User.query.get_or_404(id_role) + user = DB.get_or_404(User, id_role) fields = user_fields.copy() if g.current_user == user: fields.add("email")