forked from ScoDoc/ScoDoc
param checking (exceptions pour utilisateurs)
This commit is contained in:
parent
480af81e0d
commit
21fa7112c8
@ -4,6 +4,7 @@
|
|||||||
"""
|
"""
|
||||||
from app import db, log
|
from app import db, log
|
||||||
from app.scodoc import bonus_sport
|
from app.scodoc import bonus_sport
|
||||||
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
|
|
||||||
|
|
||||||
class ScoPreference(db.Model):
|
class ScoPreference(db.Model):
|
||||||
@ -94,7 +95,7 @@ class ScoDocSiteConfig(db.Model):
|
|||||||
"""returns bonus func with specified name.
|
"""returns bonus func with specified name.
|
||||||
If name not specified, return the configured function.
|
If name not specified, return the configured function.
|
||||||
None if no bonus function configured.
|
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:
|
if func_name is None:
|
||||||
c = ScoDocSiteConfig.query.filter_by(name=cls.BONUS_SPORT).first()
|
c = ScoDocSiteConfig.query.filter_by(name=cls.BONUS_SPORT).first()
|
||||||
@ -103,7 +104,13 @@ class ScoDocSiteConfig(db.Model):
|
|||||||
func_name = c.value
|
func_name = c.value
|
||||||
if func_name == "": # pas de bonus défini
|
if func_name == "": # pas de bonus défini
|
||||||
return None
|
return None
|
||||||
return getattr(bonus_sport, func_name)
|
try:
|
||||||
|
return getattr(bonus_sport, func_name)
|
||||||
|
except AttributeError:
|
||||||
|
raise ScoValueError(
|
||||||
|
f"""Fonction de calcul maison inexistante: {func_name}.
|
||||||
|
(contacter votre administrateur local)."""
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_bonus_sport_func_names(cls):
|
def get_bonus_sport_func_names(cls):
|
||||||
|
@ -288,10 +288,11 @@ def formsemestre_inscr_passage(
|
|||||||
footer = html_sco_header.sco_footer()
|
footer = html_sco_header.sco_footer()
|
||||||
H = [header]
|
H = [header]
|
||||||
if isinstance(etuds, str):
|
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):
|
elif isinstance(etuds, int):
|
||||||
etuds = [etuds]
|
etuds = [etuds]
|
||||||
etuds = [int(x) for x in etuds]
|
|
||||||
auth_etuds_by_sem, inscrits, candidats = list_authorized_etuds_by_sem(sem)
|
auth_etuds_by_sem, inscrits, candidats = list_authorized_etuds_by_sem(sem)
|
||||||
etuds_set = set(etuds)
|
etuds_set = set(etuds)
|
||||||
candidats_set = set(candidats)
|
candidats_set = set(candidats)
|
||||||
|
@ -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
|
"""Table listant toutes les opérations de saisies de notes, dans toutes
|
||||||
les évaluations du semestre.
|
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(
|
r = ndb.SimpleDictFetch(
|
||||||
"""SELECT i.nom, code_nip, n.*, mod.titre, e.description, e.jour
|
"""SELECT i.nom, code_nip, n.*, mod.titre, e.description, e.jour
|
||||||
FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi,
|
FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi,
|
||||||
|
@ -1565,7 +1565,7 @@ def evaluation_delete(evaluation_id):
|
|||||||
"""Form delete evaluation"""
|
"""Form delete evaluation"""
|
||||||
El = sco_evaluations.do_evaluation_list(args={"evaluation_id": evaluation_id})
|
El = sco_evaluations.do_evaluation_list(args={"evaluation_id": evaluation_id})
|
||||||
if not El:
|
if not El:
|
||||||
raise ValueError("Evalution inexistante ! (%s)" % evaluation_id)
|
raise ScoValueError("Evalution inexistante ! (%s)" % evaluation_id)
|
||||||
E = El[0]
|
E = El[0]
|
||||||
M = sco_moduleimpl.moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[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]
|
Mod = sco_edit_module.module_list(args={"module_id": M["module_id"]})[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user