From 4b0a92a834253e2f33b692c96a870cb74fefc8ff Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 25 Aug 2022 12:47:57 +0200 Subject: [PATCH] Minor enhancements: error messages --- app/scodoc/sco_evaluation_edit.py | 2 ++ app/scodoc/sco_permissions_check.py | 5 ++--- app/views/notes.py | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 4375ad72..c7d3402c 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -61,6 +61,8 @@ def evaluation_create_form( "Formulaire création/édition d'une évaluation (pas de ses notes)" if evaluation_id is not None: evaluation = models.Evaluation.query.get(evaluation_id) + if evaluation is None: + raise ScoValueError("Cette évaluation n'existe pas ou plus !") moduleimpl_id = evaluation.moduleimpl_id # modimpl_o = sco_moduleimpl.moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[ diff --git a/app/scodoc/sco_permissions_check.py b/app/scodoc/sco_permissions_check.py index 9ad457d9..2bd637d7 100644 --- a/app/scodoc/sco_permissions_check.py +++ b/app/scodoc/sco_permissions_check.py @@ -178,7 +178,7 @@ def can_change_groups(formsemestre_id): return False -def can_handle_passwd(user, allow_admindepts=False): +def can_handle_passwd(user: User, allow_admindepts=False) -> bool: """True if the current user can see or change passwd info of user. If allow_admindepts, allow Admin from all depts (so they can view users from other depts and add roles to them). @@ -199,5 +199,4 @@ def can_handle_passwd(user, allow_admindepts=False): return True # if no dept, can access users from all depts ! if (current_user.dept == user.dept) or allow_admindepts: return True - else: - return False + return False diff --git a/app/views/notes.py b/app/views/notes.py index 11bde73c..0625db60 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1657,7 +1657,7 @@ def evaluation_delete(evaluation_id): """Form delete evaluation""" El = sco_evaluation_db.do_evaluation_list(args={"evaluation_id": evaluation_id}) if not El: - raise ScoValueError("Evalution inexistante ! (%s)" % evaluation_id) + raise ScoValueError("Evaluation 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] @@ -1750,6 +1750,9 @@ def evaluation_edit(evaluation_id): @scodoc7func def evaluation_create(moduleimpl_id): "form create evaluation" + modimpl = ModuleImpl.query.get(moduleimpl_id) + if modimpl is None: + raise ScoValueError("Ce module n'existe pas ou plus !") return sco_evaluation_edit.evaluation_create_form( moduleimpl_id=moduleimpl_id, edit=False )