forked from ScoDoc/ScoDoc
Améliore traitement erreur upload photo
This commit is contained in:
parent
65d00d4754
commit
bbdf79191a
@ -62,7 +62,7 @@ from app.models import Identite
|
||||
from app.scodoc import sco_etud
|
||||
from app.scodoc import sco_portal_apogee
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc.sco_exceptions import ScoGenError
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc.scolog import logdb
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
@ -262,10 +262,11 @@ def store_photo(etud: dict, data, filename: str) -> tuple[bool, str]:
|
||||
return False, f"Fichier image '{filename}' de taille invalide ! ({filesize})"
|
||||
try:
|
||||
saved_filename = save_image(etud["etudid"], data)
|
||||
except PIL.UnidentifiedImageError as exc:
|
||||
raise ScoGenError(
|
||||
except (OSError, PIL.UnidentifiedImageError) as exc:
|
||||
raise ScoValueError(
|
||||
msg="Fichier d'image '{filename}' invalide ou format non supporté"
|
||||
) from exc
|
||||
|
||||
# update database:
|
||||
etud["photo_filename"] = saved_filename
|
||||
etud["foto"] = None
|
||||
|
Loading…
Reference in New Issue
Block a user