From 2ca91fc4e99dce2276aeae86d16d95efc149aa66 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 16 Oct 2021 19:19:07 +0200 Subject: [PATCH] added some relations --- app/models/formations.py | 9 +++++++++ app/models/formsemestre.py | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/models/formations.py b/app/models/formations.py index 5002ab08..bb822911 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -32,6 +32,7 @@ class NotesFormation(db.Model): ues = db.relationship("NotesUE", backref="formation", lazy="dynamic") formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation") + ues = db.relationship("NotesUE", lazy="dynamic", backref="formation") def __repr__(self): return f"<{self.__class__.__name__}(id={self.id}, dept_id={self.dept_id}, acronyme='{self.acronyme}')>" @@ -65,6 +66,10 @@ class NotesUE(db.Model): # coef UE, utilise seulement si l'option use_ue_coefs est activée: coefficient = db.Column(db.Float) + # relations + matieres = db.relationship("NotesMatiere", lazy="dynamic", backref="ue") + modules = db.relationship("NotesModule", lazy="dynamic", backref="ue") + def __repr__(self): return f"<{self.__class__.__name__}(id={self.id}, formation_id={self.formation_id}, acronyme='{self.acronyme}')>" @@ -84,6 +89,8 @@ class NotesMatiere(db.Model): titre = db.Column(db.Text()) numero = db.Column(db.Integer) # ordre de présentation + modules = db.relationship("NotesModule", lazy="dynamic", backref="matiere") + class NotesModule(db.Model): """Module""" @@ -110,6 +117,8 @@ class NotesModule(db.Model): # id de l'element pedagogique Apogee correspondant: code_apogee = db.Column(db.String(APO_CODE_STR_LEN)) module_type = db.Column(db.Integer) # NULL ou 0:defaut, 1: malus (NOTES_MALUS) + # Relations: + modimpls = db.relationship("NotesModuleImpl", backref="module", lazy="dynamic") class NotesTag(db.Model): diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 93b781b7..73830b06 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -70,9 +70,14 @@ class FormSemestre(db.Model): # code element annee Apogee, eg 'VRT1A' ou 'V2INLA,V2INCA,...' elt_annee_apo = db.Column(db.Text()) + # Relations: etapes = db.relationship( - "NotesFormsemestreEtape", cascade="all,delete", backref="notes_formsemestre" + "NotesFormsemestreEtape", cascade="all,delete", backref="formsemestre" ) + formsemestres = db.relationship( + "NotesModuleImpl", backref="formsemestre", lazy="dynamic" + ) + # Ancien id ScoDoc7 pour les migrations de bases anciennes # ne pas utiliser après migrate_scodoc7_dept_archive scodoc7_id = db.Column(db.Text(), nullable=True)