1
0
forked from ScoDoc/ScoDoc

Edition programmes (APC): verrouiller par indice de semestre #599

This commit is contained in:
Emmanuel Viennet 2023-02-17 22:07:03 +01:00
parent 789449b620
commit 597be47afb
5 changed files with 15 additions and 18 deletions

View File

@ -112,9 +112,14 @@ class Formation(db.Model):
df_cache.ModuleCoefsCache.set(key, modules_coefficients)
return modules_coefficients
def has_locked_sems(self):
"True if there is a locked formsemestre in this formation"
return len(self.formsemestres.filter_by(etat=False).all()) > 0
def has_locked_sems(self, semestre_idx: int = None):
"""True if there is a locked formsemestre in this formation.
If semestre_idx is specified, check only this index.
"""
query = self.formsemestres.filter_by(etat=False)
if semestre_idx is not None:
query = query.filter_by(semestre_id=semestre_idx)
return len(query.all()) > 0
def invalidate_module_coefs(self, semestre_idx: int = None):
"""Invalide le cache des coefficients de modules.

View File

@ -161,11 +161,11 @@ def formation_edit(formation_id=None, create=False):
is_locked = False
else:
# edit an existing formation
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("formation inexistante !")
initvalues = F[0]
is_locked = sco_formations.formation_has_locked_sems(formation_id)
formation: Formation = Formation.query.get_or_404(formation_id)
form_dict = formation.to_dict()
form_dict["commentaire"] = form_dict["commentaire"] or ""
initvalues = form_dict[0]
is_locked = formation.has_locked_sems(formation_id)
submitlabel = "Modifier les valeurs"
H = [
html_sco_header.sco_header(page_title="Modification d'une formation"),

View File

@ -643,11 +643,11 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
raise ScoValueError("invalid formation_id")
parcours = formation.get_cursus()
is_apc = parcours.APC_SAE
locked = formation.has_locked_sems()
if semestre_idx == "all" or semestre_idx == "":
semestre_idx = None
else:
semestre_idx = int(semestre_idx)
locked = formation.has_locked_sems(semestre_idx)
semestre_ids = range(1, parcours.NB_SEM + 1)
# transition: on requete ici via l'ORM mais on utilise les fonctions ScoDoc7
# basées sur des dicts

View File

@ -97,14 +97,6 @@ def formation_list(formation_id=None, args={}):
return r
def formation_has_locked_sems(formation_id): # XXX to remove
"backward compat: True if there is a locked formsemestre in this formation"
formation = Formation.query.get(formation_id)
if formation is None:
return False
return formation.has_locked_sems()
def formation_export(
formation_id,
export_ids=False,

View File

@ -197,7 +197,7 @@ def edit_modules_ue_coefs():
formation = models.Formation.query.filter_by(
formation_id=formation_id
).first_or_404()
locked = sco_formations.formation_has_locked_sems(formation_id)
locked = formation.has_locked_sems(semestre_idx)
if locked:
lockicon = scu.icontag("lock32_img", title="verrouillé")
else: