param checking (exceptions pour utilisateurs)

This commit is contained in:
Emmanuel Viennet 2021-11-27 18:55:47 +01:00
parent 480af81e0d
commit 21fa7112c8
4 changed files with 14 additions and 6 deletions

View File

@ -4,6 +4,7 @@
"""
from app import db, log
from app.scodoc import bonus_sport
from app.scodoc.sco_exceptions import ScoValueError
class ScoPreference(db.Model):
@ -94,7 +95,7 @@ class ScoDocSiteConfig(db.Model):
"""returns bonus func with specified name.
If name not specified, return the configured function.
None if no bonus function configured.
Raises NameError if func_name not found in module bonus_sport.
Raises ScoValueError if func_name not found in module bonus_sport.
"""
if func_name is None:
c = ScoDocSiteConfig.query.filter_by(name=cls.BONUS_SPORT).first()
@ -103,7 +104,13 @@ class ScoDocSiteConfig(db.Model):
func_name = c.value
if func_name == "": # pas de bonus défini
return None
try:
return getattr(bonus_sport, func_name)
except AttributeError:
raise ScoValueError(
f"""Fonction de calcul maison inexistante: {func_name}.
(contacter votre administrateur local)."""
)
@classmethod
def get_bonus_sport_func_names(cls):

View File

@ -288,10 +288,11 @@ def formsemestre_inscr_passage(
footer = html_sco_header.sco_footer()
H = [header]
if isinstance(etuds, str):
etuds = etuds.split(",") # vient du form de confirmation
# list de strings, vient du form de confirmation
etuds = [int(x) for x in etuds.split(",") if x]
elif isinstance(etuds, int):
etuds = [etuds]
etuds = [int(x) for x in etuds]
auth_etuds_by_sem, inscrits, candidats = list_authorized_etuds_by_sem(sem)
etuds_set = set(etuds)
candidats_set = set(candidats)

View File

@ -176,7 +176,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"):
"""Table listant toutes les opérations de saisies de notes, dans toutes
les évaluations du semestre.
"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True)
r = ndb.SimpleDictFetch(
"""SELECT i.nom, code_nip, n.*, mod.titre, e.description, e.jour
FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi,

View File

@ -1565,7 +1565,7 @@ def evaluation_delete(evaluation_id):
"""Form delete evaluation"""
El = sco_evaluations.do_evaluation_list(args={"evaluation_id": evaluation_id})
if not El:
raise ValueError("Evalution inexistante ! (%s)" % evaluation_id)
raise ScoValueError("Evalution inexistante ! (%s)" % evaluation_id)
E = El[0]
M = sco_moduleimpl.moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
Mod = sco_edit_module.module_list(args={"module_id": M["module_id"]})[0]