Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into table

This commit is contained in:
Emmanuel Viennet 2023-02-06 13:08:30 +01:00
commit 4993ce955f
3 changed files with 11 additions and 5 deletions

View File

@ -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.models.but_refcomp import ApcParcours, app_critiques_modules, parcours_modules
from app.scodoc import sco_utils as scu from app.scodoc import sco_utils as scu
from app.scodoc.sco_codes_parcours import UE_SPORT from app.scodoc.sco_codes_parcours import UE_SPORT
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_utils import ModuleType from app.scodoc.sco_utils import ModuleType
@ -175,6 +176,8 @@ class Module(db.Model):
ue_coef_dict = { ue_id : coef } ue_coef_dict = { ue_id : coef }
Les coefs nuls (zéro) ne sont pas stockés: la relation est supprimée. 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 changed = False
for ue_id, coef in ue_coef_dict.items(): for ue_id, coef in ue_coef_dict.items():
# Existant ? # Existant ?
@ -201,6 +204,8 @@ class Module(db.Model):
def update_ue_coef_dict(self, ue_coef_dict: dict): def update_ue_coef_dict(self, ue_coef_dict: dict):
"""update coefs vers UE (ajoute aux existants)""" """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 = self.get_ue_coef_dict()
current.update(ue_coef_dict) current.update(ue_coef_dict)
self.set_ue_coef_dict(current) self.set_ue_coef_dict(current)
@ -211,6 +216,8 @@ class Module(db.Model):
def delete_ue_coef(self, ue): def delete_ue_coef(self, ue):
"""delete coef""" """delete coef"""
if self.formation.has_locked_sems():
raise ScoValueError("Formation verrouillée")
ue_coef = ModuleUECoef.query.get((self.id, ue.id)) ue_coef = ModuleUECoef.query.get((self.id, ue.id))
if ue_coef: if ue_coef:
db.session.delete(ue_coef) db.session.delete(ue_coef)

View File

@ -47,7 +47,6 @@ from app.models import (
) )
from app.models import ApcValidationRCUE, ScolarFormSemestreValidation, ScolarEvent from app.models import ApcValidationRCUE, ScolarFormSemestreValidation, ScolarEvent
from app.models import ScolarNews from app.models import ScolarNews
from app.models.formations import Matiere
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import ModuleType from app.scodoc.sco_utils import ModuleType
@ -64,7 +63,6 @@ from app.scodoc import sco_codes_parcours
from app.scodoc import sco_edit_apc from app.scodoc import sco_edit_apc
from app.scodoc import sco_edit_matiere from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module from app.scodoc import sco_edit_module
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl from app.scodoc import sco_moduleimpl
from app.scodoc import sco_tag_module from app.scodoc import sco_tag_module
@ -815,7 +813,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
<li> <a class="stdlink" href="{ <li> <a class="stdlink" href="{
url_for('notes.edit_modules_ue_coefs', url_for('notes.edit_modules_ue_coefs',
scodoc_dept=g.scodoc_dept, formation_id=formation_id, semestre_idx=semestre_idx) 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> </li>
</ul> </ul>
""" """

View File

@ -165,7 +165,7 @@ def set_module_ue_coef():
coef = float(request.form["coef"].replace(",", ".")) coef = float(request.form["coef"].replace(",", "."))
except ValueError: except ValueError:
return scu.json_error(404, "invalid coef") 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: if module is None:
return scu.json_error(404, f"module not found ({module_id})") return scu.json_error(404, f"module not found ({module_id})")
ue = models.UniteEns.query.get(ue_id) ue = models.UniteEns.query.get(ue_id)
@ -229,7 +229,8 @@ def edit_modules_ue_coefs():
"notes.set_module_ue_coef", "notes.set_module_ue_coef",
scodoc_dept=g.scodoc_dept, 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_idx=semestre_idx,
semestre_ids=range(1, formation.get_parcours().NB_SEM + 1), semestre_ids=range(1, formation.get_parcours().NB_SEM + 1),
parcours_id=parcours_id, parcours_id=parcours_id,