From 13d0e462cccfa890437691b8b729e20ce3f3764c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 12 Dec 2021 22:27:06 +0100 Subject: [PATCH] msg erreur si upload fichier invalide --- app/scodoc/sco_logos.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_logos.py b/app/scodoc/sco_logos.py index 0d73e301..d66646d4 100644 --- a/app/scodoc/sco_logos.py +++ b/app/scodoc/sco_logos.py @@ -44,6 +44,7 @@ from werkzeug.utils import secure_filename from app import Departement, ScoValueError from app.scodoc import sco_utils as scu +from app.scodoc.sco_exceptions import ScoValueError from PIL import Image as PILImage GLOBAL = "_" # category for server level logos @@ -136,7 +137,7 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX): class Logo: """Responsable des opérations (select, create), du calcul des chemins et url - ainsi que de la récupération des informations sur un logp. + ainsi que de la récupération des informations sur un logo. Usage: logo existant: Logo(, , ...).select() (retourne None si fichier non trouvé) logo en création: Logo(, , ...).create(stream) @@ -197,7 +198,7 @@ class Logo: def create(self, stream): img_type = guess_image_type(stream) if img_type not in scu.LOGOS_IMAGES_ALLOWED_TYPES: - abort(400, "type d'image invalide") + raise ScoValueError("type d'image invalide") self._set_format(img_type) self._ensure_directory_exists() filename = self.basepath + "." + self.suffix