From f012fe6fcfd8c40a7baec05715b51bca95b57c85 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 27 Sep 2021 16:42:14 +0200 Subject: [PATCH] =?UTF-8?q?FIX=20regression=20/=20REQUEST+formulaires=20/?= =?UTF-8?q?=20+=20passage=20=C3=A9tudiants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/decorators.py | 14 ++++----- app/scodoc/sco_archives.py | 2 +- app/scodoc/sco_archives_etud.py | 4 +-- app/scodoc/sco_edit_formation.py | 2 +- app/scodoc/sco_edit_matiere.py | 6 ++-- app/scodoc/sco_edit_module.py | 6 ++-- app/scodoc/sco_edit_ue.py | 2 +- app/scodoc/sco_evaluations.py | 4 +-- app/scodoc/sco_find_etud.py | 6 ++-- app/scodoc/sco_formsemestre_custommenu.py | 2 +- app/scodoc/sco_formsemestre_edit.py | 10 +++---- app/scodoc/sco_formsemestre_exterieurs.py | 8 ++--- app/scodoc/sco_formsemestre_inscriptions.py | 4 +-- app/scodoc/sco_formsemestre_validation.py | 2 +- app/scodoc/sco_groups.py | 6 ++-- app/scodoc/sco_inscr_passage.py | 4 ++- app/scodoc/sco_liste_notes.py | 4 +-- app/scodoc/sco_preferences.py | 4 +-- app/scodoc/sco_pvjury.py | 4 +-- app/scodoc/sco_saisie_notes.py | 6 ++-- app/scodoc/sco_trombino.py | 2 +- app/scodoc/sco_ue_external.py | 2 +- app/scodoc/sco_utils.py | 33 ++++++++++++++++++--- app/views/absences.py | 6 ++-- app/views/entreprises.py | 22 +++++++------- app/views/notes.py | 16 +++++----- app/views/scolar.py | 14 ++++----- app/views/users.py | 4 +-- sco_version.py | 2 +- 29 files changed, 112 insertions(+), 89 deletions(-) diff --git a/app/decorators.py b/app/decorators.py index 38224b8b0..65b89905b 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -20,6 +20,7 @@ import flask_login import app from app.auth.models import User +import app.scodoc.sco_utils as scu class ZUser(object): @@ -141,7 +142,6 @@ def scodoc7func(func): 1. via a Flask route ("top level call") 2. or be called directly from Python. - If called via a route, this decorator setups a REQUEST object (emulating Zope2 REQUEST) """ # Détermine si on est appelé via une route ("toplevel") # ou par un appel de fonction python normal. @@ -154,7 +154,7 @@ def scodoc7func(func): # REQUEST = ZRequest() # g.zrequest = REQUEST # args from query string (get) or form (post) - req_args = request.form if request.method == "POST" else request.args + req_args = scu.get_request_args() ## --- Add positional arguments pos_arg_values = [] argspec = inspect.getfullargspec(func) @@ -164,12 +164,10 @@ def scodoc7func(func): arg_names = argspec.args[:-nb_default_args] else: arg_names = argspec.args - for arg_name in arg_names: - if arg_name == "REQUEST": # special case - raise ValueError( - "invalid REQUEST parameter !" - ) # debug check, TODO remove after tests - # pos_arg_values.append(REQUEST) + for arg_name in arg_names: # pour chaque arg de la fonction vue + if arg_name == "REQUEST": # ne devrait plus arriver ! + # debug check, TODO remove after tests + raise ValueError("invalid REQUEST parameter !") else: # peut produire une KeyError s'il manque un argument attendu: v = req_args[arg_name] diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index 578eeb8d5..8ebab00aa 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -453,7 +453,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement. tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cancelbutton="Annuler", method="POST", diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 64172b6db..1805c085f 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -153,7 +153,7 @@ def etud_upload_file_form(etudid): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("etudid", {"default": etudid, "input_type": "hidden"}), ("datafile", {"input_type": "file", "title": "Fichier", "size": 30}), @@ -309,7 +309,7 @@ def etudarchive_import_files_form(group_id): F = html_sco_header.sco_footer() tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}), ("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}), diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 9a163886d..ec97d9081 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -160,7 +160,7 @@ def formation_edit(formation_id=None, create=False): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("formation_id", {"default": formation_id, "input_type": "hidden"}), ( diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index 935563291..d4bdc6d87 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -117,7 +117,7 @@ associé. ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("ue_id", {"input_type": "hidden", "default": ue_id}), ("titre", {"size": 30, "explanation": "nom de la matière."}), @@ -203,7 +203,7 @@ def matiere_delete(matiere_id=None): dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(UE["formation_id"]) tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("matiere_id", {"input_type": "hidden"}),), initvalues=M, submitlabel="Confirmer la suppression", @@ -257,7 +257,7 @@ associé.

""" tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("matiere_id", {"input_type": "hidden"}), ( diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 975696e23..6ec8bce3e 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -145,7 +145,7 @@ def module_create(matiere_id=None): default_num = 10 tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "code", @@ -297,7 +297,7 @@ def module_delete(module_id=None): dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"]) tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("module_id", {"input_type": "hidden"}),), initvalues=Mod, submitlabel="Confirmer la suppression", @@ -391,7 +391,7 @@ def module_edit(module_id=None): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "code", diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index cfc651e99..987a8d1e9 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -328,7 +328,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None): ) tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), fw, initvalues=initvalues, submitlabel=submitlabel, diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index fe91af313..e2faf71b9 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -1227,9 +1227,9 @@ def evaluation_create_form( initvalues["visibulletinlist"] = ["X"] else: initvalues["visibulletinlist"] = [] - vals = (request.form if request.method == "POST" else request.args).copy() + vals = scu.get_request_args() if vals.get("tf_submitted", False) and "visibulletinlist" not in vals: - request.form["visibulletinlist"] = [] + vals["visibulletinlist"] = [] # form = [ ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index 57b240cb3..8ad96b1be 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -136,11 +136,11 @@ def search_etud_in_dept(expnom=""): vals = {} url_args = {"scodoc_dept": g.scodoc_dept} - if "dest_url" in request.form: - endpoint = request.form["dest_url"] + if "dest_url" in vals: + endpoint = vals["dest_url"] else: endpoint = "scolar.ficheEtud" - if "parameters_keys" in request.form: + if "parameters_keys" in vals: for key in vals["parameters_keys"].split(","): url_args[key] = vals[key] diff --git a/app/scodoc/sco_formsemestre_custommenu.py b/app/scodoc/sco_formsemestre_custommenu.py index 421109d6a..9a8192ded 100644 --- a/app/scodoc/sco_formsemestre_custommenu.py +++ b/app/scodoc/sco_formsemestre_custommenu.py @@ -118,7 +118,7 @@ def formsemestre_custommenu_edit(formsemestre_id): initvalues["url_" + str(item["custommenu_id"])] = item["url"] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, initvalues=initvalues, cancelbutton="Annuler", diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 5beb17beb..e8af6247d 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -109,7 +109,7 @@ def formsemestre_editwithmodules(formsemestre_id): H.append(r) else: return r # response redirect - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if not vals.get("tf_submitted", False): H.append( """

Seuls les modules cochés font partie de ce semestre. Pour les retirer, les décocher et appuyer sur le bouton "modifier". @@ -133,7 +133,7 @@ def can_edit_sem(formsemestre_id="", sem=None): def do_formsemestre_createwithmodules(edit=False): "Form choix modules / responsables et creation formsemestre" # Fonction accessible à tous, controle acces à la main: - vals = (request.form if request.method == "POST" else request.args).copy() + vals = scu.get_request_args() if edit: formsemestre_id = int(vals["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(formsemestre_id) @@ -959,7 +959,7 @@ def formsemestre_clone(formsemestre_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, submitlabel="Dupliquer ce semestre", cancelbutton="Annuler", @@ -1264,7 +1264,7 @@ def formsemestre_delete(formsemestre_id): submit_label = "Confirmer la suppression du semestre" tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("formsemestre_id", {"input_type": "hidden"}),), initvalues=F, submitlabel=submit_label, @@ -1553,7 +1553,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, submitlabel="Changer les coefficients", cancelbutton="Annuler", diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index 5c121e49a..23cea7a44 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -182,7 +182,7 @@ def formsemestre_ext_create_form(etudid, formsemestre_id): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cancelbutton="Annuler", method="post", @@ -222,9 +222,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid): sem = sco_formsemestre.get_formsemestre(formsemestre_id) etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] ue_list = _list_ue_with_coef_and_validations(sem, etudid) - descr = _ue_form_description( - ue_list, request.form if request.method == "POST" else request.args - ) + descr = _ue_form_description(ue_list, scu.get_request_args()) if request.method == "GET": initvalues = { "note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "") @@ -234,7 +232,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid): initvalues = {} tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cssclass="tf_ext_edit_ue_validations", submitlabel="Enregistrer ces validations", diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 90c37d911..7d42578d2 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -467,7 +467,7 @@ def formsemestre_inscription_option(etudid, formsemestre_id): modimpls_by_ue_names[ue_id].append( "%s %s" % (mod["module"]["code"], mod["module"]["titre"]) ) - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if not vals.get("tf_submitted", False): # inscrit ? for ins in inscr: @@ -534,7 +534,7 @@ function chkbx_select(field_id, state) { ) tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, initvalues, cancelbutton="Annuler", diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py index 3dbb6258b..99f5b5267 100644 --- a/app/scodoc/sco_formsemestre_validation.py +++ b/app/scodoc/sco_formsemestre_validation.py @@ -1008,7 +1008,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid): ue_ids = [""] + [ue["ue_id"] for ue in ues] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("etudid", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}), diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index d8f4e3a75..6512f1feb 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -1082,7 +1082,7 @@ def partition_rename(partition_id): H = ["

Renommer une partition

"] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("partition_id", {"default": partition_id, "input_type": "hidden"}), ( @@ -1189,7 +1189,7 @@ def group_rename(group_id): H = ["

Renommer un groupe de %s

" % group["partition_name"]] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("group_id", {"default": group_id, "input_type": "hidden"}), ( @@ -1267,7 +1267,7 @@ def groups_auto_repartition(partition_id=None): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, {}, cancelbutton="Annuler", diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 5adcc5939..4536be5d1 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -291,6 +291,8 @@ def formsemestre_inscr_passage( etuds = etuds.split(",") # vient du form de confirmation elif isinstance(etuds, int): etuds = [etuds] + elif isinstance(etuds, list): + 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) @@ -353,7 +355,7 @@ def formsemestre_inscr_passage( OK="Effectuer l'opération", parameters={ "formsemestre_id": formsemestre_id, - "etuds": ",".join(etuds), + "etuds": ",".join([str(x) for x in etuds]), "inscrit_groupes": inscrit_groupes, "submitted": 1, }, diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 4a2324820..b072a0c23 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -64,7 +64,7 @@ def do_evaluation_listenotes(): (si moduleimpl_id, affiche toutes les évaluatons du module) """ mode = None - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if "evaluation_id" in vals: evaluation_id = int(vals["evaluation_id"]) mode = "eval" @@ -179,7 +179,7 @@ def do_evaluation_listenotes(): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cancelbutton=None, submitbutton=None, diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index e0a7aed6c..2935bdb3a 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -2033,7 +2033,7 @@ class BasePreferences(object): form = self.build_tf_form() tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, initvalues=self.prefs[None], submitlabel="Enregistrer les modifications", @@ -2198,7 +2198,7 @@ function set_global_pref(el, pref_name) { form.append(("formsemestre_id", {"input_type": "hidden"})) tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, initvalues=self, cssclass="sco_pref", diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 028bf103d..2f06dbce6 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -656,7 +656,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None): menu_choix_groupe = "" # un seul etudiant à editer tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cancelbutton="Annuler", method="get", @@ -824,7 +824,7 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, cancelbutton="Annuler", method="POST", diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index 07898a622..c309ac0c3 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -169,7 +169,7 @@ def do_evaluation_upload_xls(): Soumission d'un fichier XLS (evaluation_id, notefile) """ authuser = current_user - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() evaluation_id = int(vals["evaluation_id"]) comment = vals["comment"] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] @@ -658,7 +658,7 @@ def saisie_notes_tableur(evaluation_id, group_ids=[]): nf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), ( @@ -1179,7 +1179,7 @@ def _form_saisie_notes(E, M, group_ids, destination=""): tf = TF( destination, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, initvalues=initvalues, submitbutton=False, diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py index a5658b96c..b74149dbb 100644 --- a/app/scodoc/sco_trombino.py +++ b/app/scodoc/sco_trombino.py @@ -514,7 +514,7 @@ def photos_import_files_form(group_ids=[]): % groups_infos.groups_query_args, ] F = html_sco_header.sco_footer() - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() vals["group_ids"] = groups_infos.group_ids tf = TrivialFormulator( request.base_url, diff --git a/app/scodoc/sco_ue_external.py b/app/scodoc/sco_ue_external.py index dfa3a13b7..25ab8aebb 100644 --- a/app/scodoc/sco_ue_external.py +++ b/app/scodoc/sco_ue_external.py @@ -245,7 +245,7 @@ def external_ue_create_form(formsemestre_id, etudid): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("formsemestre_id", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}), diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 1d90748fd..dcdd1d9a5 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -45,16 +45,14 @@ import unicodedata import urllib from urllib.parse import urlparse, parse_qsl, urlunparse, urlencode -from flask import g, current_app - from PIL import Image as PILImage -from flask import g, url_for, request, make_response +from flask import g, request +from flask import url_for, make_response from config import Config from app import log from app.scodoc.sco_vdi import ApoEtapeVDI -from app.scodoc.sco_xml import quote_xml_attr from app.scodoc.sco_codes_parcours import NOTES_TOLERANCE, CODES_EXPL from app.scodoc import sco_exceptions from app.scodoc import sco_xml @@ -622,6 +620,33 @@ def send_file(data, filename="", suffix="", mime=None, attached=None): return response +def get_request_args(): + """returns a dict with request (POST or GET) arguments + converted to suit legacy Zope style (scodoc7) functions. + """ + # copy to get a mutable object (necessary for TrivialFormulator and several methods) + if request.method == "POST": + # request.form is a werkzeug.datastructures.ImmutableMultiDict + # must copy to get a mutable version (needed by TrivialFormulator) + vals = request.form.copy() + if request.files: + # Add files in form: + vals.update(request.files) + for k in request.form: + if k.endswith(":list"): + vals[k[:-5]] = request.form.getlist(k) + elif request.method == "GET": + vals = {} + for k in request.args: + # current_app.logger.debug("%s\t%s" % (k, request.args.getlist(k))) + if k.endswith(":list"): + vals[k[:-5]] = request.args.getlist(k) + else: + values = request.args.getlist(k) + vals[k] = values[0] if len(values) == 1 else values + return vals + + def get_scodoc_version(): "return a string identifying ScoDoc version" return sco_version.SCOVERSION diff --git a/app/views/absences.py b/app/views/absences.py index 11050f5a3..2b1df4975 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -1116,7 +1116,7 @@ def AddBilletAbsenceForm(etudid): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("etudid", {"input_type": "hidden"}), ("begin", {"input_type": "date"}), @@ -1263,7 +1263,7 @@ def listeBillets(): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("billet_id", {"input_type": "text", "title": "Numéro du billet"}),), submitbutton=False, ) @@ -1392,7 +1392,7 @@ def ProcessBilletAbsenceForm(billet_id): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("billet_id", {"input_type": "hidden"}), ( diff --git a/app/views/entreprises.py b/app/views/entreprises.py index 8a8de35d7..e5cda93a2 100644 --- a/app/views/entreprises.py +++ b/app/views/entreprises.py @@ -94,7 +94,7 @@ def sidebar(): ) # --- entreprise selectionnée: - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if "entreprise_id" in vals: entreprise_id = vals["entreprise_id"] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id}) @@ -147,7 +147,7 @@ def index_html(etud_nom=None, limit=50, offset="", format="html"): limit = int(limit) if offset: offset = int(offset or 0) - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if etud_nom: entreprises = sco_entreprises.do_entreprise_list_by_etud( args=vals, sort_on_contact=True @@ -444,7 +444,7 @@ def entreprise_contact_edit(entreprise_contact_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "entreprise_contact_id", @@ -558,7 +558,7 @@ def entreprise_correspondant_edit(entreprise_corresp_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "entreprise_corresp_id", @@ -680,7 +680,7 @@ def entreprise_contact_create(entreprise_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ( @@ -777,7 +777,7 @@ def entreprise_contact_delete(entreprise_contact_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("entreprise_contact_id", {"input_type": "hidden"}),), initvalues=c, submitlabel="Confirmer la suppression", @@ -808,7 +808,7 @@ def entreprise_correspondant_create(entreprise_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ( @@ -912,7 +912,7 @@ def entreprise_correspondant_delete(entreprise_corresp_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("entreprise_corresp_id", {"input_type": "hidden"}),), initvalues=c, submitlabel="Confirmer la suppression", @@ -966,7 +966,7 @@ def entreprise_delete(entreprise_id): H.append("""""") tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("entreprise_id", {"input_type": "hidden"}),), initvalues=E, submitlabel="Confirmer la suppression", @@ -996,7 +996,7 @@ def entreprise_create(): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("nom", {"size": 25, "title": "Nom de l'entreprise"}), ( @@ -1091,7 +1091,7 @@ def entreprise_edit(entreprise_id, start=1): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("entreprise_id", {"default": entreprise_id, "input_type": "hidden"}), ("start", {"default": 1, "input_type": "hidden"}), diff --git a/app/views/notes.py b/app/views/notes.py index 530877af0..3dc519c2e 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -505,7 +505,7 @@ def formation_import_xml_form(): footer = html_sco_header.sco_footer() tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("xmlfile", {"input_type": "file", "title": "Fichier XML", "size": 30}),), submitlabel="Importer", cancelbutton="Annuler", @@ -812,7 +812,7 @@ def edit_enseignants_form(moduleimpl_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), modform, submitlabel="Ajouter enseignant", cancelbutton="Annuler", @@ -908,7 +908,7 @@ def edit_moduleimpl_resp(moduleimpl_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, submitlabel="Changer responsable", cancelbutton="Annuler", @@ -1011,7 +1011,7 @@ def edit_moduleimpl_expr(moduleimpl_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, submitlabel="Modifier formule de calcul", cancelbutton="Annuler", @@ -1169,7 +1169,7 @@ def edit_ue_expr(formsemestre_id, ue_id): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), form, submitlabel="Modifier formule de calcul", cancelbutton="Annuler", @@ -1560,7 +1560,7 @@ def evaluation_delete(evaluation_id): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), (("evaluation_id", {"input_type": "hidden"}),), initvalues=E, submitlabel="Confirmer la suppression", @@ -1892,7 +1892,7 @@ def appreciation_add_form( app = apps[0] formsemestre_id = app["formsemestre_id"] etudid = app["etudid"] - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if "edit" in vals: edit = int(vals["edit"]) elif id: @@ -1943,7 +1943,7 @@ def appreciation_add_form( initvalues = {} tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, initvalues=initvalues, cancelbutton="Annuler", diff --git a/app/views/scolar.py b/app/views/scolar.py index 41a2c6a52..f2ccf4ff7 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -601,7 +601,7 @@ def formChangeCoordonnees(etudid): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("adresse_id", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}), @@ -807,7 +807,7 @@ def formChangePhoto(etudid=None): ] tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ("etudid", {"default": etudid, "input_type": "hidden"}), ( @@ -1134,7 +1134,7 @@ def _etudident_create_or_edit_form(edit): "Le formulaire HTML" H = [html_sco_header.sco_header(init_jquery_ui=True)] F = html_sco_header.sco_footer() - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() etudid = vals.get("etudid", None) cnx = ndb.GetDBConnexion() descr = [] @@ -1177,7 +1177,7 @@ def _etudident_create_or_edit_form(edit): # except ValueError: # infos = None # pass # XXX a terminer - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() nom = vals.get("nom", None) if nom is None: nom = initvalues.get("nom", None) @@ -1470,7 +1470,7 @@ def _etudident_create_or_edit_form(edit): initvalues["dont_check_homonyms"] = False tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), descr, submitlabel=submitlabel, cancelbutton="Re-interroger Apogee", @@ -1829,7 +1829,7 @@ def form_students_import_excel(formsemestre_id=None): F = html_sco_header.sco_footer() tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "csvfile", @@ -1997,7 +1997,7 @@ def form_students_import_infos_admissions(formsemestre_id=None): tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "csvfile", diff --git a/app/views/users.py b/app/views/users.py index 533b8d789..4d3e465d5 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -330,7 +330,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1): }, ), ] - vals = (request.form if request.method == "POST" else request.args).copy() + scu.get_request_args() if "tf_submitted" in vals and not "roles" in vals: vals["roles"] = [] if "tf_submitted" in vals: @@ -527,7 +527,7 @@ def import_users_form(): F = html_sco_header.sco_footer() tf = TrivialFormulator( request.base_url, - request.form if request.method == "POST" else request.args, + scu.get_request_args(), ( ( "xlsfile", diff --git a/sco_version.py b/sco_version.py index 41d1cfd97..b3b059b07 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.40" +SCOVERSION = "9.0.41" SCONAME = "ScoDoc"