Interdit modification coefs APC si sems verrouillés
This commit is contained in:
parent
35a917bd7a
commit
a4f24b81a8
@ -6,6 +6,7 @@ from app.models import APO_CODE_STR_LEN
|
||||
from app.models.but_refcomp import ApcParcours, app_critiques_modules, parcours_modules
|
||||
from app.scodoc import sco_utils as scu
|
||||
from app.scodoc.sco_codes_parcours import UE_SPORT
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
|
||||
|
||||
@ -175,6 +176,8 @@ class Module(db.Model):
|
||||
ue_coef_dict = { ue_id : coef }
|
||||
Les coefs nuls (zéro) ne sont pas stockés: la relation est supprimée.
|
||||
"""
|
||||
if self.formation.has_locked_sems():
|
||||
raise ScoValueError("Formation verrouillée")
|
||||
changed = False
|
||||
for ue_id, coef in ue_coef_dict.items():
|
||||
# Existant ?
|
||||
@ -201,6 +204,8 @@ class Module(db.Model):
|
||||
|
||||
def update_ue_coef_dict(self, ue_coef_dict: dict):
|
||||
"""update coefs vers UE (ajoute aux existants)"""
|
||||
if self.formation.has_locked_sems():
|
||||
raise ScoValueError("Formation verrouillée")
|
||||
current = self.get_ue_coef_dict()
|
||||
current.update(ue_coef_dict)
|
||||
self.set_ue_coef_dict(current)
|
||||
@ -211,6 +216,8 @@ class Module(db.Model):
|
||||
|
||||
def delete_ue_coef(self, ue):
|
||||
"""delete coef"""
|
||||
if self.formation.has_locked_sems():
|
||||
raise ScoValueError("Formation verrouillée")
|
||||
ue_coef = ModuleUECoef.query.get((self.id, ue.id))
|
||||
if ue_coef:
|
||||
db.session.delete(ue_coef)
|
||||
|
@ -811,7 +811,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
|
||||
f"""</li>
|
||||
<li> <a class="stdlink" href="{
|
||||
url_for('notes.edit_modules_ue_coefs', scodoc_dept=g.scodoc_dept, formation_id=formation_id, semestre_idx=semestre_idx)
|
||||
}">Éditer les coefficients des ressources et SAÉs</a>
|
||||
}">{'Visualiser' if locked else 'Éditer'} les coefficients des ressources et SAÉs</a>
|
||||
</li>
|
||||
</ul>
|
||||
"""
|
||||
|
@ -165,7 +165,7 @@ def set_module_ue_coef():
|
||||
coef = float(request.form["coef"].replace(",", "."))
|
||||
except ValueError:
|
||||
return scu.json_error(404, "invalid coef")
|
||||
module = models.Module.query.get(module_id)
|
||||
module: Module = models.Module.query.get(module_id)
|
||||
if module is None:
|
||||
return scu.json_error(404, f"module not found ({module_id})")
|
||||
ue = models.UniteEns.query.get(ue_id)
|
||||
@ -229,7 +229,8 @@ def edit_modules_ue_coefs():
|
||||
"notes.set_module_ue_coef",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
),
|
||||
read_only=not current_user.has_permission(Permission.ScoChangeFormation),
|
||||
read_only=locked
|
||||
or not current_user.has_permission(Permission.ScoChangeFormation),
|
||||
semestre_idx=semestre_idx,
|
||||
semestre_ids=range(1, formation.get_parcours().NB_SEM + 1),
|
||||
parcours_id=parcours_id,
|
||||
|
Loading…
Reference in New Issue
Block a user