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( self.validation = ScolarFormSemestreValidation.query.filter_by(
etudid=etud.id, formsemestre_id=formsemestre.id, ue_id=ue.id etudid=etud.id, formsemestre_id=formsemestre.id, ue_id=ue.id
).first() ).first()
super().__init__( super().__init__(
etud=etud, etud=etud,
code_valide=self.validation.code if self.validation is not None else None, code_valide=self.validation.code if self.validation is not None else None,
) )
log(f"built {self}")
self.formsemestre = formsemestre self.formsemestre = formsemestre
self.ue: UniteEns = ue self.ue: UniteEns = ue
self.rcue: RegroupementCoherentUE = None self.rcue: RegroupementCoherentUE = None
@ -951,7 +950,9 @@ class DecisionsProposeesUE(DecisionsProposees):
self.explanation = "notes insuffisantes" self.explanation = "notes insuffisantes"
def record(self, code: str, no_overwrite=False): 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: if code and not code in self.codes:
raise ScoValueError( raise ScoValueError(
f"code UE invalide pour ue_id={self.ue.id}: {html.escape(code)}" 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): if code == self.code_valide or (self.code_valide is not None and no_overwrite):
self.recorded = True self.recorded = True
return # no change return # no change
if self.validation: self.erase()
db.session.delete(self.validation)
db.session.flush()
if code is None: if code is None:
self.validation = None self.validation = None
else: else:
@ -977,6 +976,7 @@ class DecisionsProposeesUE(DecisionsProposees):
etudid=self.etud.id, etudid=self.etud.id,
msg=f"Validation UE {self.ue.id}", msg=f"Validation UE {self.ue.id}",
) )
log(f"DecisionsProposeesUE: recording {self.validation}")
db.session.add(self.validation) db.session.add(self.validation)
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre.id) 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 etudid=self.etud.id, formsemestre_id=self.formsemestre.id, ue_id=self.ue.id
) )
for validation in validations: for validation in validations:
log(f"DecisionsProposeesUE: deleting {validation}")
db.session.delete(validation) db.session.delete(validation)
db.session.flush() db.session.flush()