msg erreur si upload fichier invalide
This commit is contained in:
parent
4aa4ab316c
commit
13d0e462cc
@ -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(<name>, <dept_id>, ...).select() (retourne None si fichier non trouvé)
|
||||
logo en création: Logo(<name>, <dept_id>, ...).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
|
||||
|
Loading…
Reference in New Issue
Block a user