forked from ScoDoc/ScoDoc
Jury BUT: invalidation cache semestre
This commit is contained in:
parent
2bfbaa3a2a
commit
a1f772b22e
@ -89,6 +89,7 @@ from app.models.formations import Formation
|
||||
from app.models.formsemestre import FormSemestre, FormSemestreInscription
|
||||
from app.models.ues import UniteEns
|
||||
from app.models.validations import ScolarFormSemestreValidation
|
||||
from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_codes_parcours as sco_codes
|
||||
from app.scodoc.sco_codes_parcours import RED, UE_STANDARD
|
||||
from app.scodoc import sco_utils as scu
|
||||
@ -573,31 +574,33 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
Si les code_rcue et le code_annee ne sont pas fournis,
|
||||
et qu'il n'y en a pas déjà, enregistre ceux par défaut.
|
||||
"""
|
||||
for key in form:
|
||||
code = form[key]
|
||||
# Codes d'UE
|
||||
m = re.match(r"^code_ue_(\d+)$", key)
|
||||
if m:
|
||||
ue_id = int(m.group(1))
|
||||
dec_ue = self.decisions_ues.get(ue_id)
|
||||
if not dec_ue:
|
||||
raise ScoValueError(f"UE invalide ue_id={ue_id}")
|
||||
dec_ue.record(code)
|
||||
else:
|
||||
# Codes de RCUE
|
||||
m = re.match(r"^code_rcue_(\d+)$", key)
|
||||
log("jury_but.DecisionsProposeesAnnee.record_form")
|
||||
with sco_cache.DeferredSemCacheManager():
|
||||
for key in form:
|
||||
code = form[key]
|
||||
# Codes d'UE
|
||||
m = re.match(r"^code_ue_(\d+)$", key)
|
||||
if m:
|
||||
niveau_id = int(m.group(1))
|
||||
dec_rcue = self.decisions_rcue_by_niveau.get(niveau_id)
|
||||
if not dec_rcue:
|
||||
raise ScoValueError(f"RCUE invalide niveau_id={niveau_id}")
|
||||
dec_rcue.record(code)
|
||||
elif key == "code_annee":
|
||||
# Code annuel
|
||||
self.record(code)
|
||||
ue_id = int(m.group(1))
|
||||
dec_ue = self.decisions_ues.get(ue_id)
|
||||
if not dec_ue:
|
||||
raise ScoValueError(f"UE invalide ue_id={ue_id}")
|
||||
dec_ue.record(code)
|
||||
else:
|
||||
# Codes de RCUE
|
||||
m = re.match(r"^code_rcue_(\d+)$", key)
|
||||
if m:
|
||||
niveau_id = int(m.group(1))
|
||||
dec_rcue = self.decisions_rcue_by_niveau.get(niveau_id)
|
||||
if not dec_rcue:
|
||||
raise ScoValueError(f"RCUE invalide niveau_id={niveau_id}")
|
||||
dec_rcue.record(code)
|
||||
elif key == "code_annee":
|
||||
# Code annuel
|
||||
self.record(code)
|
||||
|
||||
self.record_all()
|
||||
db.session.commit()
|
||||
self.record_all()
|
||||
db.session.commit()
|
||||
|
||||
def record(self, code: str, no_overwrite=False):
|
||||
"""Enregistre le code de l'année, et au besoin l'autorisation d'inscription.
|
||||
@ -647,6 +650,16 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
)
|
||||
|
||||
self.recorded = True
|
||||
self.invalidate_formsemestre_cache()
|
||||
|
||||
def invalidate_formsemestre_cache(self):
|
||||
"invalide le résultats des deux formsemestres"
|
||||
if self.formsemestre_impair is not None:
|
||||
sco_cache.invalidate_formsemestre(
|
||||
formsemestre_id=self.formsemestre_impair.id
|
||||
)
|
||||
if self.formsemestre_pair is not None:
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre_pair.id)
|
||||
|
||||
def record_all(self):
|
||||
"""Enregistre les codes qui n'ont pas été spécifiés par le formulaire, et sont donc en mode "automatique" """
|
||||
@ -687,6 +700,7 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
for validation in validations:
|
||||
db.session.delete(validation)
|
||||
db.session.flush()
|
||||
self.invalidate_formsemestre_cache()
|
||||
|
||||
def get_autorisations_passage(self) -> list[int]:
|
||||
"""Les liste des indices de semestres auxquels on est autorisé à
|
||||
@ -805,6 +819,14 @@ class DecisionsProposeesRCUE(DecisionsProposees):
|
||||
msg=f"Validation RCUE {repr(self.rcue)}",
|
||||
)
|
||||
db.session.add(self.validation)
|
||||
if self.rcue.formsemestre_1 is not None:
|
||||
sco_cache.invalidate_formsemestre(
|
||||
formsemestre_id=self.rcue.formsemestre_1.id
|
||||
)
|
||||
if self.rcue.formsemestre_2 is not None:
|
||||
sco_cache.invalidate_formsemestre(
|
||||
formsemestre_id=self.rcue.formsemestre_2.id
|
||||
)
|
||||
self.recorded = True
|
||||
|
||||
def erase(self):
|
||||
@ -948,6 +970,8 @@ class DecisionsProposeesUE(DecisionsProposees):
|
||||
msg=f"Validation UE {self.ue.id}",
|
||||
)
|
||||
db.session.add(self.validation)
|
||||
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre.id)
|
||||
self.recorded = True
|
||||
|
||||
def erase(self):
|
||||
|
Loading…
Reference in New Issue
Block a user