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() 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 ?