diff --git a/app/but/jury_but_validation_auto.py b/app/but/jury_but_validation_auto.py
index 99512168..5c54c7b3 100644
--- a/app/but/jury_but_validation_auto.py
+++ b/app/but/jury_but_validation_auto.py
@@ -4,15 +4,14 @@
# See LICENSE
##############################################################################
-"""Jury BUT: clacul des décisions de jury annuelles "automatiques"
+"""Jury BUT: calcul des décisions de jury annuelles "automatiques"
"""
-from flask import g, url_for
-
from app import db
from app.but import jury_but
from app.models.etudiants import Identite
from app.models.formsemestre import FormSemestre
+from app.scodoc import sco_cache
from app.scodoc.sco_exceptions import ScoValueError
@@ -23,12 +22,13 @@ def formsemestre_validation_auto_but(formsemestre: FormSemestre) -> int:
if not formsemestre.formation.is_apc():
raise ScoValueError("fonction réservée aux formations BUT")
nb_admis = 0
- for etudid in formsemestre.etuds_inscriptions:
- etud: Identite = Identite.query.get(etudid)
- deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
- if deca.admis: # année réussie
- deca.record_all()
- nb_admis += 1
+ with sco_cache.DeferredSemCacheManager():
+ for etudid in formsemestre.etuds_inscriptions:
+ etud: Identite = Identite.query.get(etudid)
+ deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
+ if deca.admis: # année réussie
+ deca.record_all()
+ nb_admis += 1
db.session.commit()
return nb_admis
diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py
index 2effc138..cd1fc359 100644
--- a/app/scodoc/sco_formsemestre_validation.py
+++ b/app/scodoc/sco_formsemestre_validation.py
@@ -871,10 +871,9 @@ def form_decision_manuelle(Se, formsemestre_id, etudid, desturl="", sortcol=None
# -----------
def formsemestre_validation_auto(formsemestre_id):
"Formulaire saisie automatisee des decisions d'un semestre"
- sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header("Saisie automatique des décisions du semestre"),
- """
+ f"""
- """
- % formsemestre_id,
+ """,
html_sco_header.sco_footer(),
]
return "\n".join(H)
@@ -906,53 +904,56 @@ def do_formsemestre_validation_auto(formsemestre_id):
etudids = nt.get_etudids()
nb_valid = 0
conflicts = [] # liste des etudiants avec decision differente déjà saisie
- for etudid in etudids:
- etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
- Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
- ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
- {"etudid": etudid, "formsemestre_id": formsemestre_id}
- )[0]
+ with sco_cache.DeferredSemCacheManager():
+ for etudid in etudids:
+ etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
+ Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
+ ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
+ {"etudid": etudid, "formsemestre_id": formsemestre_id}
+ )[0]
- # Conditions pour validation automatique:
- if ins["etat"] == "I" and (
- (
- (not Se.prev)
- or (Se.prev_decision and Se.prev_decision["code"] in (ADM, ADC, ADJ))
- )
- and Se.barre_moy_ok
- and Se.barres_ue_ok
- and not etud_has_notes_attente(etudid, formsemestre_id)
- ):
- # check: s'il existe une decision ou autorisation et qu'elles sont differentes,
- # warning (et ne fait rien)
- decision_sem = nt.get_etud_decision_sem(etudid)
- ok = True
- if decision_sem and decision_sem["code"] != ADM:
- ok = False
- conflicts.append(etud)
- autorisations = ScolarAutorisationInscription.query.filter_by(
- etudid=etudid, origin_formsemestre_id=formsemestre_id
- ).all()
- if len(autorisations) != 0:
- if (
- len(autorisations) > 1
- or autorisations[0].semestre_id != next_semestre_id
- ):
- if ok:
- conflicts.append(etud)
- ok = False
-
- # ok, valide !
- if ok:
- formsemestre_validation_etud_manu(
- formsemestre_id,
- etudid,
- code_etat=ADM,
- devenir="NEXT",
- assidu=True,
- redirect=False,
+ # Conditions pour validation automatique:
+ if ins["etat"] == "I" and (
+ (
+ (not Se.prev)
+ or (
+ Se.prev_decision and Se.prev_decision["code"] in (ADM, ADC, ADJ)
+ )
)
- nb_valid += 1
+ and Se.barre_moy_ok
+ and Se.barres_ue_ok
+ and not etud_has_notes_attente(etudid, formsemestre_id)
+ ):
+ # check: s'il existe une decision ou autorisation et qu'elles sont differentes,
+ # warning (et ne fait rien)
+ decision_sem = nt.get_etud_decision_sem(etudid)
+ ok = True
+ if decision_sem and decision_sem["code"] != ADM:
+ ok = False
+ conflicts.append(etud)
+ autorisations = ScolarAutorisationInscription.query.filter_by(
+ etudid=etudid, origin_formsemestre_id=formsemestre_id
+ ).all()
+ if len(autorisations) != 0:
+ if (
+ len(autorisations) > 1
+ or autorisations[0].semestre_id != next_semestre_id
+ ):
+ if ok:
+ conflicts.append(etud)
+ ok = False
+
+ # ok, valide !
+ if ok:
+ formsemestre_validation_etud_manu(
+ formsemestre_id,
+ etudid,
+ code_etat=ADM,
+ devenir="NEXT",
+ assidu=True,
+ redirect=False,
+ )
+ nb_valid += 1
log(
"do_formsemestre_validation_auto: %d validations, %d conflicts"
% (nb_valid, len(conflicts))