Skip to content

Commit

Permalink
remove use of backref and rename relationship 'listes'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia authored and amandine-sahl committed Nov 9, 2023
1 parent 289b078 commit 1ab8c1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apptax/admin/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_dynamic_options(self, view):

class FilterBiblist(DynamicOptionsMixin, FilterEqual):
def apply(self, query, value, alias=None):
return query.join(Taxref.liste).filter(Taxref.liste.any(id_liste=value))
return query.join(Taxref.listes).filter(Taxref.listes.any(id_liste=value))

def get_dynamic_options(self, view):
if has_app_context():
Expand Down
9 changes: 6 additions & 3 deletions apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CorTaxonAttribut(db.Model):
valeur_attribut = db.Column(db.Text, nullable=False)
bib_attribut = db.relationship("BibAttributs")

taxon = db.relationship("Taxref", backref="attributs")
taxon = db.relationship("Taxref", back_populates="attributs")

def __repr__(self):
return self.valeur_attribut
Expand Down Expand Up @@ -174,6 +174,9 @@ class Taxref(db.Model):
foreign_keys=[cd_ref],
primaryjoin="Taxref.cd_ref == Taxref.cd_ref",
)
attributs = db.relationship("CorTaxonAttribut", back_populates="taxon")
listes = db.relationship("BibListes", secondary=cor_nom_liste, back_populates="noms")
medias = db.relationship("apptax.taxonomie.models.TMedias", back_populates="taxon")

@hybrid_property
def nom_vern_or_lb_nom(self):
Expand Down Expand Up @@ -210,7 +213,7 @@ class BibListes(db.Model):
primary_key=False,
)

noms = db.relationship("Taxref", secondary=cor_nom_liste, backref="liste")
noms = db.relationship("Taxref", secondary=cor_nom_liste, back_populates="listes")
regne = db.relationship("VMRegne")
group2_inpn = db.relationship("VMGroup2Inpn")

Expand Down Expand Up @@ -270,7 +273,7 @@ class TMedias(db.Model):

types = db.relationship(BibTypesMedia)

taxon = db.relationship(Taxref, backref="medias")
taxon = db.relationship(Taxref, back_populates="medias")

def __repr__(self):
return self.titre
Expand Down

0 comments on commit 1ab8c1e

Please sign in to comment.