diff --git a/app/models/but_validations.py b/app/models/but_validations.py index d5e622ece..0c202be41 100644 --- a/app/models/but_validations.py +++ b/app/models/but_validations.py @@ -59,7 +59,11 @@ class ApcValidationRCUE(db.Model): parcour = db.relationship("ApcParcours") def __repr__(self): - return f"<{self.__class__.__name__} {self.id} {self.etud} {self.ue1}/{self.ue2}:{self.code!r}>" + return f"""<{self.__class__.__name__} {self.id} {self.etud} { + self.ue1}/{self.ue2}:{self.code!r}>""" + + def __str__(self): + return f"""décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}: {self.code}""" def niveau(self) -> ApcNiveau: """Le niveau de compétence associé à cet RCUE.""" @@ -301,6 +305,9 @@ class ApcValidationAnnee(db.Model): def __repr__(self): return f"<{self.__class__.__name__} {self.id} {self.etud} BUT{self.ordre}/{self.annee_scolaire}:{self.code!r}>" + def __str__(self): + return f"""décision sur année BUT{self.ordre} {self.annee_scolaire} : {self.code}""" + def to_dict_bul(self) -> dict: "dict pour bulletins" return { diff --git a/app/models/events.py b/app/models/events.py index 4e566cbd9..39938978b 100644 --- a/app/models/events.py +++ b/app/models/events.py @@ -13,7 +13,6 @@ from app import email from app import log from app.auth.models import User from app.models import SHORT_STR_LEN -from app.models.formsemestre import FormSemestre from app.models.moduleimpls import ModuleImpl import app.scodoc.sco_utils as scu from app.scodoc import sco_preferences @@ -170,10 +169,12 @@ class ScolarNews(db.Model): log(f"news: {news}") news.notify_by_mail() - def get_news_formsemestre(self) -> FormSemestre: + def get_news_formsemestre(self) -> "FormSemestre": """formsemestre concerné par la nouvelle None si inexistant """ + from app.models.formsemestre import FormSemestre + formsemestre_id = None if self.type == self.NEWS_INSCR: formsemestre_id = self.object diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index ef700ace5..5742da15b 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -31,9 +31,11 @@ from app.models.groups import GroupDescr, Partition import app.scodoc.sco_utils as scu from app.models.but_refcomp import parcours_formsemestre from app.models.etudiants import Identite +from app.models.formations import Formation from app.models.modules import Module from app.models.moduleimpls import ModuleImpl from app.models.ues import UniteEns +from app.models.validations import ScolarFormSemestreValidation from app.scodoc import sco_codes_parcours from app.scodoc import sco_preferences @@ -648,6 +650,46 @@ class FormSemestre(db.Model): ) db.session.commit() + def etud_validations_description_html(self, etudid: int) -> str: + """Description textuelle des validations de jury de cet étudiant dans ce semestre""" + from app.models.but_validations import ApcValidationRCUE, ApcValidationAnnee + + vals_sem = ScolarFormSemestreValidation.query.filter_by( + etudid=etudid, formsemestre_id=self.id, ue_id=None + ).all() + vals_ues = ( + ScolarFormSemestreValidation.query.filter_by( + etudid=etudid, formsemestre_id=self.id + ) + .join(UniteEns) + .order_by(UniteEns.numero) + .all() + ) + # Validations BUT: + vals_rcues = ( + ApcValidationRCUE.query.filter_by(etudid=etudid, formsemestre_id=self.id) + .join(UniteEns, ApcValidationRCUE.ue1) + .order_by(UniteEns.numero) + .all() + ) + vals_annee = ( + ApcValidationAnnee.query.filter_by( + etudid=etudid, + annee_scolaire=self.annee_scolaire(), + ) + .join(ApcValidationAnnee.formsemestre) + .join(FormSemestre.formation) + .filter(Formation.formation_code == self.formation.formation_code) + .all() + ) + H = [] + for vals in (vals_sem, vals_ues, vals_rcues, vals_annee): + if vals: + H.append( + f"""
Attention: il y a des décisions de jury déjà prises !
' if validations_descr else ""} + {validations_descr} + {('') if validations_descr else ""} +