From 9dd8198c7b26d417fe6c4420471401fe18471973 Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Tue, 21 Sep 2021 06:48:54 +0200 Subject: [PATCH 1/2] transmit multiple occurence of an argument into a list --- app/decorators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/decorators.py b/app/decorators.py index 87f2fd998..9f30bead2 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -74,7 +74,8 @@ class ZRequest(object): if k.endswith(":list"): self.form[k[:-5]] = request.args.getlist(k) else: - self.form[k] = request.args[k] + values = request.args.getlist(k) + self.form[k] = values[0] if len(values) == 1 else values # current_app.logger.info("ZRequest.form=%s" % str(self.form)) self.RESPONSE = ZResponse() From 4297d36dadefd79b9d1edda816849e0463bf1dd8 Mon Sep 17 00:00:00 2001 From: Jean-Marie Place Date: Tue, 21 Sep 2021 16:28:26 +0200 Subject: [PATCH 2/2] gentil message sur erreur d import esxcel --- app/scodoc/sco_excel.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index eb1eb3a0d..9a9faf6ec 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -563,12 +563,24 @@ def excel_feuille_saisie(e, titreannee, description, lines): def excel_bytes_to_list(bytes_content): - filelike = io.BytesIO(bytes_content) - return _excel_to_list(filelike) + try: + filelike = io.BytesIO(bytes_content) + return _excel_to_list(filelike) + except: + raise ScoValueError(""" + scolars_import_excel_file: un contenu xlsx semble corrompu! + peut-ĂȘtre avez vous fourni un fichier au mauvais format (txt, xls, ..) + """) def excel_file_to_list(filename): - return _excel_to_list(filename) + try: + return _excel_to_list(filename) + except: + raise ScoValueError(""" + scolars_import_excel_file: un contenu xlsx semble corrompu! + peut-ĂȘtre avez vous fourni un fichier au mauvais format (txt, xls, ..) + """) def _excel_to_list(filelike): # we may need 'encoding' argument ?