diff --git a/apptax/admin/filters.py b/apptax/admin/filters.py index 78cb590f..4a2bed91 100644 --- a/apptax/admin/filters.py +++ b/apptax/admin/filters.py @@ -64,9 +64,6 @@ def get_dynamic_options(self, view): yield from [(list.id_liste, list.nom_liste) for list in BibListes.query.all()] -from flask_admin.model.filters import BaseBooleanFilter - - class FilterIsValidName(BaseFilter): def apply(self, query, value, alias=None): if int(value) == 1: @@ -80,11 +77,11 @@ def operation(self): class FilterMedia(BaseFilter): def apply(self, query, value, alias=None): + medias_filter = Taxref.medias.any() if int(value) == 1: - return query.join(TMedias, TMedias.cd_ref == Taxref.cd_ref) + return query.filter(medias_filter) else: - # TODO - return query + return query.filter(~medias_filter) def operation(self): return lazy_gettext("equal") @@ -92,11 +89,11 @@ def operation(self): class FilterAttributes(BaseFilter): def apply(self, query, value, alias=None): + attr_filter = Taxref.attributs.any() if int(value) == 1: - return query.join(CorTaxonAttribut, CorTaxonAttribut.cd_ref == Taxref.cd_ref) + return query.filter(attr_filter) else: - # TODO - return query + return query.filter(~attr_filter) def operation(self): return lazy_gettext("equal") diff --git a/apptax/taxonomie/models.py b/apptax/taxonomie/models.py index d6c1b3a4..2f4517fa 100644 --- a/apptax/taxonomie/models.py +++ b/apptax/taxonomie/models.py @@ -131,7 +131,7 @@ class CorNomListe(db.Model): primary_key=True, ) - taxref = db.relationship("Taxref") + # backref : Medias et Attributs bib_liste = db.relationship("BibListes")