Skip to content

Commit

Permalink
test request context
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Mar 16, 2023
1 parent b651315 commit 04566c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apptax/admin/admin_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
flash,
g,
has_app_context,
has_request_context,
)
from flask_admin.model.template import macro
from jinja2.utils import markupsafe
Expand Down Expand Up @@ -216,30 +217,30 @@ 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)

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)

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()]

Expand Down

0 comments on commit 04566c5

Please sign in to comment.