1
0
forked from ScoDoc/ScoDoc

FIX regression / REQUEST+formulaires / + passage étudiants

This commit is contained in:
Emmanuel Viennet 2021-09-27 16:42:14 +02:00
parent d577066911
commit f012fe6fcf
29 changed files with 112 additions and 89 deletions

View File

@ -20,6 +20,7 @@ import flask_login
import app import app
from app.auth.models import User from app.auth.models import User
import app.scodoc.sco_utils as scu
class ZUser(object): class ZUser(object):
@ -141,7 +142,6 @@ def scodoc7func(func):
1. via a Flask route ("top level call") 1. via a Flask route ("top level call")
2. or be called directly from Python. 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") # Détermine si on est appelé via une route ("toplevel")
# ou par un appel de fonction python normal. # ou par un appel de fonction python normal.
@ -154,7 +154,7 @@ def scodoc7func(func):
# REQUEST = ZRequest() # REQUEST = ZRequest()
# g.zrequest = REQUEST # g.zrequest = REQUEST
# args from query string (get) or form (post) # 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 ## --- Add positional arguments
pos_arg_values = [] pos_arg_values = []
argspec = inspect.getfullargspec(func) argspec = inspect.getfullargspec(func)
@ -164,12 +164,10 @@ def scodoc7func(func):
arg_names = argspec.args[:-nb_default_args] arg_names = argspec.args[:-nb_default_args]
else: else:
arg_names = argspec.args arg_names = argspec.args
for arg_name in arg_names: for arg_name in arg_names: # pour chaque arg de la fonction vue
if arg_name == "REQUEST": # special case if arg_name == "REQUEST": # ne devrait plus arriver !
raise ValueError( # debug check, TODO remove after tests
"invalid REQUEST parameter !" raise ValueError("invalid REQUEST parameter !")
) # debug check, TODO remove after tests
# pos_arg_values.append(REQUEST)
else: else:
# peut produire une KeyError s'il manque un argument attendu: # peut produire une KeyError s'il manque un argument attendu:
v = req_args[arg_name] v = req_args[arg_name]

View File

@ -453,7 +453,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="POST", method="POST",

View File

@ -153,7 +153,7 @@ def etud_upload_file_form(etudid):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("etudid", {"default": etudid, "input_type": "hidden"}), ("etudid", {"default": etudid, "input_type": "hidden"}),
("datafile", {"input_type": "file", "title": "Fichier", "size": 30}), ("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() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, 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}), ("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}),
("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}), ("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}),

View File

@ -160,7 +160,7 @@ def formation_edit(formation_id=None, create=False):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("formation_id", {"default": formation_id, "input_type": "hidden"}), ("formation_id", {"default": formation_id, "input_type": "hidden"}),
( (

View File

@ -117,7 +117,7 @@ associé.
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("ue_id", {"input_type": "hidden", "default": ue_id}), ("ue_id", {"input_type": "hidden", "default": ue_id}),
("titre", {"size": 30, "explanation": "nom de la matière."}), ("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"]) dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(UE["formation_id"])
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("matiere_id", {"input_type": "hidden"}),), (("matiere_id", {"input_type": "hidden"}),),
initvalues=M, initvalues=M,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -257,7 +257,7 @@ associé.
</p>""" </p>"""
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("matiere_id", {"input_type": "hidden"}), ("matiere_id", {"input_type": "hidden"}),
( (

View File

@ -145,7 +145,7 @@ def module_create(matiere_id=None):
default_num = 10 default_num = 10
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"code", "code",
@ -297,7 +297,7 @@ def module_delete(module_id=None):
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"]) dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"])
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("module_id", {"input_type": "hidden"}),), (("module_id", {"input_type": "hidden"}),),
initvalues=Mod, initvalues=Mod,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -391,7 +391,7 @@ def module_edit(module_id=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"code", "code",

View File

@ -328,7 +328,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None):
) )
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
fw, fw,
initvalues=initvalues, initvalues=initvalues,
submitlabel=submitlabel, submitlabel=submitlabel,

View File

@ -1227,9 +1227,9 @@ def evaluation_create_form(
initvalues["visibulletinlist"] = ["X"] initvalues["visibulletinlist"] = ["X"]
else: else:
initvalues["visibulletinlist"] = [] 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: if vals.get("tf_submitted", False) and "visibulletinlist" not in vals:
request.form["visibulletinlist"] = [] vals["visibulletinlist"] = []
# #
form = [ form = [
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),

View File

@ -136,11 +136,11 @@ def search_etud_in_dept(expnom=""):
vals = {} vals = {}
url_args = {"scodoc_dept": g.scodoc_dept} url_args = {"scodoc_dept": g.scodoc_dept}
if "dest_url" in request.form: if "dest_url" in vals:
endpoint = request.form["dest_url"] endpoint = vals["dest_url"]
else: else:
endpoint = "scolar.ficheEtud" endpoint = "scolar.ficheEtud"
if "parameters_keys" in request.form: if "parameters_keys" in vals:
for key in vals["parameters_keys"].split(","): for key in vals["parameters_keys"].split(","):
url_args[key] = vals[key] url_args[key] = vals[key]

View File

@ -118,7 +118,7 @@ def formsemestre_custommenu_edit(formsemestre_id):
initvalues["url_" + str(item["custommenu_id"])] = item["url"] initvalues["url_" + str(item["custommenu_id"])] = item["url"]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
initvalues=initvalues, initvalues=initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -109,7 +109,7 @@ def formsemestre_editwithmodules(formsemestre_id):
H.append(r) H.append(r)
else: else:
return r # response redirect 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): if not vals.get("tf_submitted", False):
H.append( H.append(
"""<p class="help">Seuls les modules cochés font partie de ce semestre. Pour les retirer, les décocher et appuyer sur le bouton "modifier". """<p class="help">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): def do_formsemestre_createwithmodules(edit=False):
"Form choix modules / responsables et creation formsemestre" "Form choix modules / responsables et creation formsemestre"
# Fonction accessible à tous, controle acces à la main: # 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: if edit:
formsemestre_id = int(vals["formsemestre_id"]) formsemestre_id = int(vals["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
@ -959,7 +959,7 @@ def formsemestre_clone(formsemestre_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
submitlabel="Dupliquer ce semestre", submitlabel="Dupliquer ce semestre",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1264,7 +1264,7 @@ def formsemestre_delete(formsemestre_id):
submit_label = "Confirmer la suppression du semestre" submit_label = "Confirmer la suppression du semestre"
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("formsemestre_id", {"input_type": "hidden"}),), (("formsemestre_id", {"input_type": "hidden"}),),
initvalues=F, initvalues=F,
submitlabel=submit_label, submitlabel=submit_label,
@ -1553,7 +1553,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
submitlabel="Changer les coefficients", submitlabel="Changer les coefficients",
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -182,7 +182,7 @@ def formsemestre_ext_create_form(etudid, formsemestre_id):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="post", method="post",
@ -222,9 +222,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid):
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
ue_list = _list_ue_with_coef_and_validations(sem, etudid) ue_list = _list_ue_with_coef_and_validations(sem, etudid)
descr = _ue_form_description( descr = _ue_form_description(ue_list, scu.get_request_args())
ue_list, request.form if request.method == "POST" else request.args
)
if request.method == "GET": if request.method == "GET":
initvalues = { initvalues = {
"note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "") "note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "")
@ -234,7 +232,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid):
initvalues = {} initvalues = {}
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cssclass="tf_ext_edit_ue_validations", cssclass="tf_ext_edit_ue_validations",
submitlabel="Enregistrer ces validations", submitlabel="Enregistrer ces validations",

View File

@ -467,7 +467,7 @@ def formsemestre_inscription_option(etudid, formsemestre_id):
modimpls_by_ue_names[ue_id].append( modimpls_by_ue_names[ue_id].append(
"%s %s" % (mod["module"]["code"], mod["module"]["titre"]) "%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): if not vals.get("tf_submitted", False):
# inscrit ? # inscrit ?
for ins in inscr: for ins in inscr:
@ -534,7 +534,7 @@ function chkbx_select(field_id, state) {
) )
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
initvalues, initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -1008,7 +1008,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid):
ue_ids = [""] + [ue["ue_id"] for ue in ues] ue_ids = [""] + [ue["ue_id"] for ue in ues]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
("formsemestre_id", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}),

View File

@ -1082,7 +1082,7 @@ def partition_rename(partition_id):
H = ["<h2>Renommer une partition</h2>"] H = ["<h2>Renommer une partition</h2>"]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("partition_id", {"default": partition_id, "input_type": "hidden"}), ("partition_id", {"default": partition_id, "input_type": "hidden"}),
( (
@ -1189,7 +1189,7 @@ def group_rename(group_id):
H = ["<h2>Renommer un groupe de %s</h2>" % group["partition_name"]] H = ["<h2>Renommer un groupe de %s</h2>" % group["partition_name"]]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("group_id", {"default": group_id, "input_type": "hidden"}), ("group_id", {"default": group_id, "input_type": "hidden"}),
( (
@ -1267,7 +1267,7 @@ def groups_auto_repartition(partition_id=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
{}, {},
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -291,6 +291,8 @@ def formsemestre_inscr_passage(
etuds = etuds.split(",") # vient du form de confirmation etuds = etuds.split(",") # vient du form de confirmation
elif isinstance(etuds, int): elif isinstance(etuds, int):
etuds = [etuds] 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) 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)
@ -353,7 +355,7 @@ def formsemestre_inscr_passage(
OK="Effectuer l'opération", OK="Effectuer l'opération",
parameters={ parameters={
"formsemestre_id": formsemestre_id, "formsemestre_id": formsemestre_id,
"etuds": ",".join(etuds), "etuds": ",".join([str(x) for x in etuds]),
"inscrit_groupes": inscrit_groupes, "inscrit_groupes": inscrit_groupes,
"submitted": 1, "submitted": 1,
}, },

View File

@ -64,7 +64,7 @@ def do_evaluation_listenotes():
(si moduleimpl_id, affiche toutes les évaluatons du module) (si moduleimpl_id, affiche toutes les évaluatons du module)
""" """
mode = None mode = None
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
if "evaluation_id" in vals: if "evaluation_id" in vals:
evaluation_id = int(vals["evaluation_id"]) evaluation_id = int(vals["evaluation_id"])
mode = "eval" mode = "eval"
@ -179,7 +179,7 @@ def do_evaluation_listenotes():
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cancelbutton=None, cancelbutton=None,
submitbutton=None, submitbutton=None,

View File

@ -2033,7 +2033,7 @@ class BasePreferences(object):
form = self.build_tf_form() form = self.build_tf_form()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
initvalues=self.prefs[None], initvalues=self.prefs[None],
submitlabel="Enregistrer les modifications", submitlabel="Enregistrer les modifications",
@ -2198,7 +2198,7 @@ function set_global_pref(el, pref_name) {
form.append(("formsemestre_id", {"input_type": "hidden"})) form.append(("formsemestre_id", {"input_type": "hidden"}))
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
initvalues=self, initvalues=self,
cssclass="sco_pref", cssclass="sco_pref",

View File

@ -656,7 +656,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None):
menu_choix_groupe = "" # un seul etudiant à editer menu_choix_groupe = "" # un seul etudiant à editer
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="get", method="get",
@ -824,7 +824,7 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="POST", method="POST",

View File

@ -169,7 +169,7 @@ def do_evaluation_upload_xls():
Soumission d'un fichier XLS (evaluation_id, notefile) Soumission d'un fichier XLS (evaluation_id, notefile)
""" """
authuser = current_user authuser = current_user
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
evaluation_id = int(vals["evaluation_id"]) evaluation_id = int(vals["evaluation_id"])
comment = vals["comment"] comment = vals["comment"]
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] 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( nf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),
( (
@ -1179,7 +1179,7 @@ def _form_saisie_notes(E, M, group_ids, destination=""):
tf = TF( tf = TF(
destination, destination,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
initvalues=initvalues, initvalues=initvalues,
submitbutton=False, submitbutton=False,

View File

@ -514,7 +514,7 @@ def photos_import_files_form(group_ids=[]):
% groups_infos.groups_query_args, % groups_infos.groups_query_args,
] ]
F = html_sco_header.sco_footer() 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 vals["group_ids"] = groups_infos.group_ids
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,

View File

@ -245,7 +245,7 @@ def external_ue_create_form(formsemestre_id, etudid):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("formsemestre_id", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}),
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),

View File

@ -45,16 +45,14 @@ import unicodedata
import urllib import urllib
from urllib.parse import urlparse, parse_qsl, urlunparse, urlencode from urllib.parse import urlparse, parse_qsl, urlunparse, urlencode
from flask import g, current_app
from PIL import Image as PILImage 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 config import Config
from app import log from app import log
from app.scodoc.sco_vdi import ApoEtapeVDI 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.sco_codes_parcours import NOTES_TOLERANCE, CODES_EXPL
from app.scodoc import sco_exceptions from app.scodoc import sco_exceptions
from app.scodoc import sco_xml from app.scodoc import sco_xml
@ -622,6 +620,33 @@ def send_file(data, filename="", suffix="", mime=None, attached=None):
return response 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(): def get_scodoc_version():
"return a string identifying ScoDoc version" "return a string identifying ScoDoc version"
return sco_version.SCOVERSION return sco_version.SCOVERSION

View File

@ -1116,7 +1116,7 @@ def AddBilletAbsenceForm(etudid):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
("begin", {"input_type": "date"}), ("begin", {"input_type": "date"}),
@ -1263,7 +1263,7 @@ def listeBillets():
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, 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"}),), (("billet_id", {"input_type": "text", "title": "Numéro du billet"}),),
submitbutton=False, submitbutton=False,
) )
@ -1392,7 +1392,7 @@ def ProcessBilletAbsenceForm(billet_id):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("billet_id", {"input_type": "hidden"}), ("billet_id", {"input_type": "hidden"}),
( (

View File

@ -94,7 +94,7 @@ def sidebar():
) )
# --- entreprise selectionnée: # --- entreprise selectionnée:
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
if "entreprise_id" in vals: if "entreprise_id" in vals:
entreprise_id = vals["entreprise_id"] entreprise_id = vals["entreprise_id"]
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": 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) limit = int(limit)
if offset: if offset:
offset = int(offset or 0) offset = int(offset or 0)
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
if etud_nom: if etud_nom:
entreprises = sco_entreprises.do_entreprise_list_by_etud( entreprises = sco_entreprises.do_entreprise_list_by_etud(
args=vals, sort_on_contact=True args=vals, sort_on_contact=True
@ -444,7 +444,7 @@ def entreprise_contact_edit(entreprise_contact_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"entreprise_contact_id", "entreprise_contact_id",
@ -558,7 +558,7 @@ def entreprise_correspondant_edit(entreprise_corresp_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"entreprise_corresp_id", "entreprise_corresp_id",
@ -680,7 +680,7 @@ def entreprise_contact_create(entreprise_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
( (
@ -777,7 +777,7 @@ def entreprise_contact_delete(entreprise_contact_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("entreprise_contact_id", {"input_type": "hidden"}),), (("entreprise_contact_id", {"input_type": "hidden"}),),
initvalues=c, initvalues=c,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -808,7 +808,7 @@ def entreprise_correspondant_create(entreprise_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
( (
@ -912,7 +912,7 @@ def entreprise_correspondant_delete(entreprise_corresp_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("entreprise_corresp_id", {"input_type": "hidden"}),), (("entreprise_corresp_id", {"input_type": "hidden"}),),
initvalues=c, initvalues=c,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -966,7 +966,7 @@ def entreprise_delete(entreprise_id):
H.append("""</ul>""") H.append("""</ul>""")
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("entreprise_id", {"input_type": "hidden"}),), (("entreprise_id", {"input_type": "hidden"}),),
initvalues=E, initvalues=E,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -996,7 +996,7 @@ def entreprise_create():
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("nom", {"size": 25, "title": "Nom de l'entreprise"}), ("nom", {"size": 25, "title": "Nom de l'entreprise"}),
( (
@ -1091,7 +1091,7 @@ def entreprise_edit(entreprise_id, start=1):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("entreprise_id", {"default": entreprise_id, "input_type": "hidden"}), ("entreprise_id", {"default": entreprise_id, "input_type": "hidden"}),
("start", {"default": 1, "input_type": "hidden"}), ("start", {"default": 1, "input_type": "hidden"}),

View File

@ -505,7 +505,7 @@ def formation_import_xml_form():
footer = html_sco_header.sco_footer() footer = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, 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}),), (("xmlfile", {"input_type": "file", "title": "Fichier XML", "size": 30}),),
submitlabel="Importer", submitlabel="Importer",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -812,7 +812,7 @@ def edit_enseignants_form(moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
modform, modform,
submitlabel="Ajouter enseignant", submitlabel="Ajouter enseignant",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -908,7 +908,7 @@ def edit_moduleimpl_resp(moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
submitlabel="Changer responsable", submitlabel="Changer responsable",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1011,7 +1011,7 @@ def edit_moduleimpl_expr(moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
submitlabel="Modifier formule de calcul", submitlabel="Modifier formule de calcul",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1169,7 +1169,7 @@ def edit_ue_expr(formsemestre_id, ue_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
form, form,
submitlabel="Modifier formule de calcul", submitlabel="Modifier formule de calcul",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1560,7 +1560,7 @@ def evaluation_delete(evaluation_id):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
(("evaluation_id", {"input_type": "hidden"}),), (("evaluation_id", {"input_type": "hidden"}),),
initvalues=E, initvalues=E,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -1892,7 +1892,7 @@ def appreciation_add_form(
app = apps[0] app = apps[0]
formsemestre_id = app["formsemestre_id"] formsemestre_id = app["formsemestre_id"]
etudid = app["etudid"] etudid = app["etudid"]
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
if "edit" in vals: if "edit" in vals:
edit = int(vals["edit"]) edit = int(vals["edit"])
elif id: elif id:
@ -1943,7 +1943,7 @@ def appreciation_add_form(
initvalues = {} initvalues = {}
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
initvalues=initvalues, initvalues=initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -601,7 +601,7 @@ def formChangeCoordonnees(etudid):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("adresse_id", {"input_type": "hidden"}), ("adresse_id", {"input_type": "hidden"}),
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
@ -807,7 +807,7 @@ def formChangePhoto(etudid=None):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
("etudid", {"default": etudid, "input_type": "hidden"}), ("etudid", {"default": etudid, "input_type": "hidden"}),
( (
@ -1134,7 +1134,7 @@ def _etudident_create_or_edit_form(edit):
"Le formulaire HTML" "Le formulaire HTML"
H = [html_sco_header.sco_header(init_jquery_ui=True)] H = [html_sco_header.sco_header(init_jquery_ui=True)]
F = html_sco_header.sco_footer() 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) etudid = vals.get("etudid", None)
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
descr = [] descr = []
@ -1177,7 +1177,7 @@ def _etudident_create_or_edit_form(edit):
# except ValueError: # except ValueError:
# infos = None # infos = None
# pass # XXX a terminer # pass # XXX a terminer
vals = (request.form if request.method == "POST" else request.args).copy() scu.get_request_args()
nom = vals.get("nom", None) nom = vals.get("nom", None)
if nom is None: if nom is None:
nom = initvalues.get("nom", None) nom = initvalues.get("nom", None)
@ -1470,7 +1470,7 @@ def _etudident_create_or_edit_form(edit):
initvalues["dont_check_homonyms"] = False initvalues["dont_check_homonyms"] = False
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
descr, descr,
submitlabel=submitlabel, submitlabel=submitlabel,
cancelbutton="Re-interroger Apogee", cancelbutton="Re-interroger Apogee",
@ -1829,7 +1829,7 @@ def form_students_import_excel(formsemestre_id=None):
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"csvfile", "csvfile",
@ -1997,7 +1997,7 @@ def form_students_import_infos_admissions(formsemestre_id=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"csvfile", "csvfile",

View File

@ -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: if "tf_submitted" in vals and not "roles" in vals:
vals["roles"] = [] vals["roles"] = []
if "tf_submitted" in vals: if "tf_submitted" in vals:
@ -527,7 +527,7 @@ def import_users_form():
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
request.form if request.method == "POST" else request.args, scu.get_request_args(),
( (
( (
"xlsfile", "xlsfile",

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.0.40" SCOVERSION = "9.0.41"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"