1
0
forked from ScoDoc/ScoDoc

Fix: modification décisions UE jury BUT

This commit is contained in:
Emmanuel Viennet 2022-09-07 13:07:11 +02:00
parent 59649b713d
commit 9b54980b31

View File

@ -895,12 +895,11 @@ class DecisionsProposeesUE(DecisionsProposees):
self.validation = ScolarFormSemestreValidation.query.filter_by(
etudid=etud.id, formsemestre_id=formsemestre.id, ue_id=ue.id
).first()
super().__init__(
etud=etud,
code_valide=self.validation.code if self.validation is not None else None,
)
log(f"built {self}")
self.formsemestre = formsemestre
self.ue: UniteEns = ue
self.rcue: RegroupementCoherentUE = None
@ -951,7 +950,9 @@ class DecisionsProposeesUE(DecisionsProposees):
self.explanation = "notes insuffisantes"
def record(self, code: str, no_overwrite=False):
"""Enregistre le code"""
"""Enregistre le code jury pour cette UE.
Si no_overwrite, n'enregistre pas s'il y a déjà un code.
"""
if code and not code in self.codes:
raise ScoValueError(
f"code UE invalide pour ue_id={self.ue.id}: {html.escape(code)}"
@ -959,9 +960,7 @@ class DecisionsProposeesUE(DecisionsProposees):
if code == self.code_valide or (self.code_valide is not None and no_overwrite):
self.recorded = True
return # no change
if self.validation:
db.session.delete(self.validation)
db.session.flush()
self.erase()
if code is None:
self.validation = None
else:
@ -977,6 +976,7 @@ class DecisionsProposeesUE(DecisionsProposees):
etudid=self.etud.id,
msg=f"Validation UE {self.ue.id}",
)
log(f"DecisionsProposeesUE: recording {self.validation}")
db.session.add(self.validation)
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre.id)
@ -989,6 +989,7 @@ class DecisionsProposeesUE(DecisionsProposees):
etudid=self.etud.id, formsemestre_id=self.formsemestre.id, ue_id=self.ue.id
)
for validation in validations:
log(f"DecisionsProposeesUE: deleting {validation}")
db.session.delete(validation)
db.session.flush()