From d86a2dfc651f99483c28fb658fefc662e383d3d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 13 Sep 2021 17:10:38 +0200 Subject: [PATCH] fixes --- app/auth/routes.py | 2 +- app/scodoc/sco_bulletins.py | 5 ++++- app/scodoc/sco_etud.py | 2 +- app/scodoc/sco_formsemestre.py | 5 +++++ app/scodoc/sco_permissions.py | 7 +++++++ app/scodoc/sco_utils.py | 5 ++--- sco_version.py | 2 +- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/auth/routes.py b/app/auth/routes.py index b4d107c2ae..8f01a0c196 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -95,7 +95,7 @@ def reset_password_request(): current_app.logger.info( "reset_password_request: for unkown user '{}'".format(form.email.data) ) - flash(_("Voir les instructions enoyez par mail")) + flash(_("Voir les instructions envoyées par mail")) return redirect(url_for("auth.login")) return render_template( "auth/reset_password_request.html", title=_("Reset Password"), form=form diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index ab50b6bee9..54e1d67526 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -444,7 +444,10 @@ def _ue_mod_bulletin(etudid, formsemestre_id, ue_id, modimpls, nt, version): if mod["mod_moy_txt"][:2] == "NA": mod["mod_moy_txt"] = "-" if is_malus: - if mod_moy > 0: + if isinstance(mod_moy, str): + mod["mod_moy_txt"] = "-" + mod["mod_coef_txt"] = "-" + elif mod_moy > 0: mod["mod_moy_txt"] = scu.fmt_note(mod_moy) mod["mod_coef_txt"] = "Malus" elif mod_moy < 0: diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index c653c007d0..15fa188f1e 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -440,7 +440,7 @@ def notify_etud_change(email_addr, etud, before, after, subject): "Civilité: " + etud["civilite_str"], "Nom: " + etud["nom"], "Prénom: " + etud["prenom"], - "Etudid: " + etud["etudid"], + "Etudid: " + str(etud["etudid"]), "\n", "Changements effectués:", ] diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 3360b847b7..3bda684a51 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -27,6 +27,7 @@ """Operations de base sur les formsemestres """ +from app.scodoc.sco_exceptions import ScoValueError import time from operator import itemgetter @@ -93,6 +94,10 @@ _formsemestreEditor = ndb.EditableTable( def get_formsemestre(formsemestre_id): "list ONE formsemestre" + if not isinstance(formsemestre_id, int): + raise ScoValueError( + """Semestre invalide, reprenez l'opération au départ ou si le problème persiste signalez l'erreur sur scodoc-devel@listes.univ-paris13.fr""" + ) try: sem = do_formsemestre_list(args={"formsemestre_id": formsemestre_id})[0] return sem diff --git a/app/scodoc/sco_permissions.py b/app/scodoc/sco_permissions.py index 4eee09daba..4529e7672f 100644 --- a/app/scodoc/sco_permissions.py +++ b/app/scodoc/sco_permissions.py @@ -45,13 +45,20 @@ class Permission(object): NBITS = 1 # maximum bits used (for formatting) ALL_PERMISSIONS = [-1] description = {} # { symbol : blah blah } + permission_by_name = {} # { symbol : int } @staticmethod def init_permissions(): for (perm, symbol, description) in _SCO_PERMISSIONS: setattr(Permission, symbol, perm) Permission.description[symbol] = description + Permission.permission_by_name[symbol] = perm Permission.NBITS = len(_SCO_PERMISSIONS) + @staticmethod + def get_by_name(permission_name: str) -> int: + """Return permission mode (integer bit field). May raise keyError.""" + return Permission.permission_by_name[permission_name] + Permission.init_permissions() diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index b897110fd4..fc5138cfce 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -537,10 +537,9 @@ def sendXML(REQUEST, data, tagname=None, force_outer_xml_tag=True): if type(data) != list: data = [data] # always list-of-dicts if force_outer_xml_tag: - root_tagname = tagname + "_list" - data = [{root_tagname: data}] + data = [{tagname: data}] + tagname += "_list" doc = sco_xml.simple_dictlist2xml(data, tagname=tagname) - if REQUEST: REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE) return doc diff --git a/sco_version.py b/sco_version.py index f1bee487b8..2f23bcd517 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.19" +SCOVERSION = "9.0.21" SCONAME = "ScoDoc"