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 committed Nov 9, 2023
1 parent f8d5de0 commit a1cfcc3
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -56,7 +56,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
12 changes: 9 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 @@ -173,6 +173,12 @@ 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 @@ -209,7 +215,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 @@ -269,7 +275,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 a1cfcc3

Please sign in to comment.