diff --git a/apptax/admin/admin_view.py b/apptax/admin/admin_view.py index 24fdd808..7693f0a4 100644 --- a/apptax/admin/admin_view.py +++ b/apptax/admin/admin_view.py @@ -10,6 +10,7 @@ flash, g, has_app_context, + has_request_context, ) from flask_admin.model.template import macro from jinja2.utils import markupsafe @@ -216,7 +217,7 @@ def import_cd_nom_view(self, *args, **kwargs): class FilterTaxrefAttr(BaseSQLAFilter): def apply(self, query, value, alias=None): - if not has_app_context(): + if not has_app_context() or not has_request_context(): return () return query.join(CorTaxonAttribut).filter(CorTaxonAttribut.id_attribut == value) @@ -224,14 +225,14 @@ def operation(self): return "equals" def get_options(self, view): - if not has_app_context(): + if not has_app_context() or not has_request_context(): return () return [(attr.id_attribut, attr.label_attribut) for attr in BibAttributs.query.all()] class FilterBibList(BaseSQLAFilter): def apply(self, query, value, alias=None): - if not has_app_context(): + if not has_app_context() or not has_request_context(): return () return query.join(CorNomListe).join(BibListes).filter(BibListes.id_liste == value) @@ -239,7 +240,7 @@ def operation(self): return "equals" def get_options(self, view): - if not has_app_context(): + if not has_app_context() or not has_request_context(): return () return [(list.id_liste, list.nom_liste) for list in BibListes.query.all()]