From 1d1513f782d6bb87792b73e722c36ba95f6c28a7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 15 Aug 2021 21:33:47 +0200 Subject: [PATCH] =?UTF-8?q?petits=20bugs=20vari=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/decorators.py | 7 ------ app/scodoc/sco_bulletins.py | 23 ++++++++++++------- app/scodoc/sco_excel.py | 2 +- app/scodoc/sco_find_etud.py | 2 +- app/scodoc/sco_groups.py | 22 +++++++++--------- app/scodoc/sco_import_etuds.py | 41 +++++++++++++++++++++++----------- app/scodoc/sco_page_etud.py | 2 +- app/views/scolar.py | 3 ++- 8 files changed, 59 insertions(+), 43 deletions(-) diff --git a/app/decorators.py b/app/decorators.py index 38bc9a6b14..0f23be895f 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -129,12 +129,6 @@ def permission_required(permission): @wraps(f) def decorated_function(*args, **kwargs): # current_app.logger.info("PERMISSION; kwargs=%s" % str(kwargs)) - if "scodoc_dept" in kwargs: - g.scodoc_dept = kwargs["scodoc_dept"] - del kwargs["scodoc_dept"] - # current_app.logger.info( - # "permission_required: %s in %s" % (permission, g.scodoc_dept) - # ) scodoc_dept = getattr(g, "scodoc_dept", None) if not current_user.has_permission(permission, scodoc_dept): abort(403) @@ -153,7 +147,6 @@ def admin_required(f): def scodoc7func(context): """Décorateur pour intégrer les fonctions Zope 2 de ScoDoc 7. - Si on a un kwarg `scodoc_dept`(venant de la route), le stocke dans `g.scodoc_dept`. Ajoute l'argument REQUEST s'il est dans la signature de la fonction. Les paramètres de la query string deviennent des (keywords) paramètres de la fonction. """ diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index e40eda9bc1..438bcdbc18 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -161,10 +161,11 @@ def formsemestre_bulletinetud_dict( if I["etud"]["inscription_formsemestre_id"]: I[ "descr_situation_html" - ] = """%s""" % ( - I["etud"]["inscription_formsemestre_id"], - I["descr_situation"], - ) + ] = f"""{I["descr_situation"]}""" else: I["descr_situation_html"] = I["descr_situation"] # Groupes: @@ -811,8 +812,11 @@ def formsemestre_bulletinetud( H.append("""

Situation actuelle: """) if etud["inscription_formsemestre_id"]: H.append( - """""" - % etud["inscription_formsemestre_id"] + f"""""" ) H.append(etud["inscriptionstr"]) if etud["inscription_formsemestre_id"]: @@ -1054,8 +1058,11 @@ def _formsemestre_bulletinetud_header_html( """

""" % REQUEST.URL0, - """Bulletin - %(titremois)s + f"""Bulletin {sem["titremois"]}
""" % sem, """""", diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 8326580305..4d895744d3 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -573,7 +573,7 @@ def _excel_to_list(filelike): # we may need 'encoding' argument ? wb = load_workbook(filename=filelike, read_only=True, data_only=True) except: log("Excel_to_list: failure to import document") - open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "w").write(filelike) + open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb").write(filelike) raise ScoValueError( "Fichier illisible: assurez-vous qu'il s'agit bien d'un document Excel !" ) diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index ba08ff8e3d..61c97fa85d 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -106,7 +106,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None): Args: expnom: string, regexp sur le nom ou un code_nip ou un etudid """ - if len(expnom) > 1: + if isinstance(expnom, int) or len(expnom) > 1: try: etudid = int(expnom) except ValueError: diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index cfb8b58aeb..0cd8ce48f0 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -221,7 +221,9 @@ def get_default_group(formsemestre_id, fix_if_missing=False): ] except ScoException: log("creating default partition for %s" % formsemestre_id) - partition_id = partition_create(context, formsemestre_id, default=True) + partition_id = partition_create( + context, formsemestre_id, default=True, redirect=False + ) group_id = createGroup(context, partition_id, default=True) return group_id # debug check @@ -623,17 +625,15 @@ def change_etud_group_in_partition( partition = get_partition(context, group["partition_id"]) # 1- Supprime membership dans cette partition ndb.SimpleQuery( - """DELETE FROM group_membership - WHERE id IN - (SELECT gm.id - FROM group_membership gm, group_descr gd - WHERE gm.etudid = %(etudid)s - AND gm.group_id = gd.id - AND gd.partition_id = %(partition_id)s) - """, + """DELETE FROM group_membership gm + WHERE EXISTS + (SELECT 1 FROM group_descr gd + WHERE gm.etudid = %(etudid)s + AND gm.group_id = gd.id + AND gd.partition_id = %(partition_id)s) + """, {"etudid": etudid, "partition_id": partition["partition_id"]}, ) - # 2- associe au nouveau groupe set_group(context, etudid, group_id) @@ -810,7 +810,7 @@ def partition_create( partition_name="", default=False, numero=None, - redirect=1, + redirect=True, ): """Create a new partition""" if not sco_permissions_check.can_change_groups(formsemestre_id): diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py index d31e13bf3c..55a9550074 100644 --- a/app/scodoc/sco_import_etuds.py +++ b/app/scodoc/sco_import_etuds.py @@ -35,6 +35,7 @@ import time from datetime import date import flask +from flask import g, url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb @@ -101,8 +102,6 @@ ADMISSION_MODIFIABLE_FIELDS = ( "paysdomicile", "telephone", "telephonemobile", - # Debouche - "debouche", # Groupes "groupes", ) @@ -242,9 +241,13 @@ def students_import_excel( ) if REQUEST: if formsemestre_id: - dest = "Notes/formsemestre_status?formsemestre_id=%s" % formsemestre_id + dest = url_for( + "notes.formsemestre_status", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) else: - dest = scu.NotesURL() + dest = url_for("notes.index_html", scodoc_dept=g.scodoc_dept) H = [html_sco_header.sco_header(page_title="Import etudiants")] H.append("