From 2720fe0b968dd3e4dc8a24801a22853942645f19 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 8 Jul 2024 23:14:42 +0200 Subject: [PATCH] =?UTF-8?q?Efface=20aussi=20d=C3=A9cisions=20DUT120=20quan?= =?UTF-8?q?d=20on=20efface=20toutes=20les=20d=C3=A9cisions=20du=20semestre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/jury_but.py | 22 +++++++++++++++++----- app/but/jury_dut120.py | 13 ++++++++----- app/models/validations.py | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/but/jury_but.py b/app/but/jury_but.py index 14b496003..957873f2e 100644 --- a/app/but/jury_but.py +++ b/app/but/jury_but.py @@ -82,6 +82,7 @@ from app.models import Evaluation, ModuleImpl, Scolog, ScolarAutorisationInscrip from app.models.but_validations import ( ApcValidationAnnee, ApcValidationRCUE, + ValidationDUT120, ) from app.models.etudiants import Identite from app.models.formations import Formation @@ -760,13 +761,13 @@ class DecisionsProposeesAnnee(DecisionsProposees): self.validation.date = datetime.now() db.session.add(self.validation) - db.session.commit() log(f"Recording {self}: {code}") Scolog.logdb( method="jury_but", etudid=self.etud.id, msg=f"Validation année BUT{self.annee_but}: {code}", ) + db.session.commit() if mark_recorded: self.recorded = True self.invalidate_formsemestre_cache() @@ -903,6 +904,8 @@ class DecisionsProposeesAnnee(DecisionsProposees): Si only_one_sem, n'efface que les décisions UE et les autorisations de passage du semestre d'origine du deca. + Efface les validations de DUT120 issues du semestre d'origine du deca. + Dans tous les cas, efface les validations de l'année en cours. (commite la session.) """ @@ -952,6 +955,17 @@ class DecisionsProposeesAnnee(DecisionsProposees): msg=f"Validation année BUT{self.annee_but}: effacée", ) + # Efface les validations de DUT120 issues du semestre d'origine du deca. + for validation in ValidationDUT120.query.filter_by( + etudid=self.etud.id, formsemestre_id=self.formsemestre.id + ): + db.session.delete(validation) + Scolog.logdb( + "jury_but", + etudid=self.etud.id, + msg="Validation DUT120 effacée", + ) + # Efface éventuelles validations de semestre # (en principe inutilisées en BUT) # et autres UEs (en cas de changement d'architecture de formation depuis le jury ?) @@ -1214,13 +1228,12 @@ class DecisionsProposeesRCUE(DecisionsProposees): code=code, ) db.session.add(self.validation) - db.session.commit() Scolog.logdb( method="jury_but", etudid=self.etud.id, msg=f"Validation {self.rcue}: {code}", - commit=True, ) + db.session.commit() log(f"rcue.record {self}: {code}") # Modifie au besoin les codes d'UE @@ -1633,13 +1646,12 @@ class DecisionsProposeesUE(DecisionsProposees): moy_ue=self.moy_ue, ) db.session.add(self.validation) - db.session.commit() Scolog.logdb( method="jury_but", etudid=self.etud.id, msg=f"Validation UE {self.ue.id} {self.ue.acronyme}({self.moy_ue}): {code}", - commit=True, ) + db.session.commit() log(f"DecisionsProposeesUE: recording {self.validation}") sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre.id) diff --git a/app/but/jury_dut120.py b/app/but/jury_dut120.py index 000314e80..de272d8c0 100644 --- a/app/but/jury_dut120.py +++ b/app/but/jury_dut120.py @@ -18,9 +18,7 @@ from wtforms import SubmitField from app import db, log from app.but import cursus_but from app.decorators import scodoc, permission_required -from app.models.but_validations import ValidationDUT120 -from app.models.etudiants import Identite -from app.models.formsemestre import FormSemestre +from app.models import FormSemestre, Identite, Scolog, ValidationDUT120 from app.scodoc.sco_exceptions import ScoPermissionDenied, ScoValueError from app.scodoc.sco_permissions import Permission from app.views import notes_bp as bp @@ -71,7 +69,7 @@ def validate_dut120_etud(etudid: int, formsemestre_id: int): form = ValidationDUT120Form() # Check if ValidationDUT120 instance already exists existing_validation = ValidationDUT120.query.filter_by( - etudid=etudid, referentiel_competence_id=refcomp.id + etudid=etud.id, referentiel_competence_id=refcomp.id ).first() if existing_validation: flash("DUT120 déjà validé", "info") @@ -85,11 +83,16 @@ def validate_dut120_etud(etudid: int, formsemestre_id: int): if etud_can_validate_dut and request.method == "POST" and form.validate_on_submit(): new_validation = ValidationDUT120( - etudid=etudid, + etudid=etud.id, referentiel_competence_id=refcomp.id, formsemestre_id=formsemestre.id, # Replace with appropriate value ) db.session.add(new_validation) + Scolog.logdb( + "jury_but", + etudid=etud.id, + msg=f"Validation DUT120 enregistrée depuis S{formsemestre.semestre_id}", + ) db.session.commit() log(f"ValidationDUT120 enregistrée pour {etud} depuis {formsemestre}") flash("Validation DUT120 enregistrée", "success") diff --git a/app/models/validations.py b/app/models/validations.py index 1e19092eb..8595b3d2f 100644 --- a/app/models/validations.py +++ b/app/models/validations.py @@ -186,7 +186,7 @@ class ScolarAutorisationInscription(db.Model): origin_formsemestre_id: int, semestre_id: int, ): - """Ajoute une autorisation""" + """Ajoute une autorisation (don't commit)""" autorisation = cls( etudid=etudid, formation_code=formation_code,