From 04bf18adc2773e8342a96a633c037095c991b7b5 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Tue, 1 Aug 2023 13:52:44 +0200 Subject: [PATCH] improve taxon detail --- .../admin/templates/admin/details_taxref.html | 79 ++++++++++++++----- apptax/taxonomie/models.py | 12 ++- 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/apptax/admin/templates/admin/details_taxref.html b/apptax/admin/templates/admin/details_taxref.html index 7388dc43..314d9122 100644 --- a/apptax/admin/templates/admin/details_taxref.html +++ b/apptax/admin/templates/admin/details_taxref.html @@ -9,8 +9,14 @@
-
{{model.nom_complet}} {% if model.nom_vern %} - {{model.nom_vern}} {% endif %}
-
+
+
{{model.nom_complet}} {% if model.nom_vern %} - {{model.nom_vern}} {% endif %}
+
+ + + +
+
{{ model.phylum }} {% if model.classe %} > {% endif %} @@ -30,9 +36,37 @@
Listes Attributs Médias + Status + Synonymes
- - + +
-
+
diff --git a/apptax/taxonomie/models.py b/apptax/taxonomie/models.py index a44dc56d..cb89b388 100644 --- a/apptax/taxonomie/models.py +++ b/apptax/taxonomie/models.py @@ -170,6 +170,14 @@ class Taxref(db.Model): url = db.Column(db.Unicode) liste = db.relationship("BibListes", secondary=CorNomListe.__table__) + status = db.relationship("VBdcStatus") + rang = db.relationship("BibTaxrefRangs", uselist=False) + synonymes = db.relationship( + "Taxref", + lazy="joined", + foreign_keys=[cd_ref], + primaryjoin="Taxref.cd_ref == Taxref.cd_ref", + ) @hybrid_property def nom_vern_or_lb_nom(self): @@ -309,7 +317,7 @@ def __repr__(self): class BibTaxrefRangs(db.Model): __tablename__ = "bib_taxref_rangs" __table_args__ = {"schema": "taxonomie"} - id_rang = db.Column(db.Integer, primary_key=True) + id_rang = db.Column(db.Integer, ForeignKey("taxonomie.taxref.id_rang"), primary_key=True) nom_rang = db.Column(db.Unicode) tri_rang = db.Column(db.Integer) @@ -455,7 +463,7 @@ class TaxrefBdcStatutTaxon(db.Model): class VBdcStatus(db.Model): __tablename__ = "v_bdc_status" __table_args__ = {"schema": "taxonomie", "info": dict(is_view=True)} - cd_nom = db.Column(db.Integer, primary_key=True) + cd_nom = db.Column(db.Integer, ForeignKey("taxonomie.taxref.cd_ref"), primary_key=True) cd_ref = db.Column(db.Integer) rq_statut = db.Column(db.Unicode) code_statut = db.Column(db.Unicode, primary_key=True)