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_etud
|
||||||
from app.scodoc import sco_portal_apogee
|
from app.scodoc import sco_portal_apogee
|
||||||
from app.scodoc import sco_preferences
|
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
|
from app.scodoc.scolog import logdb
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
import app.scodoc.sco_utils as scu
|
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})"
|
return False, f"Fichier image '{filename}' de taille invalide ! ({filesize})"
|
||||||
try:
|
try:
|
||||||
saved_filename = save_image(etud["etudid"], data)
|
saved_filename = save_image(etud["etudid"], data)
|
||||||
except PIL.UnidentifiedImageError as exc:
|
except (OSError, PIL.UnidentifiedImageError) as exc:
|
||||||
raise ScoGenError(
|
raise ScoValueError(
|
||||||
msg="Fichier d'image '{filename}' invalide ou format non supporté"
|
msg="Fichier d'image '{filename}' invalide ou format non supporté"
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
# update database:
|
# update database:
|
||||||
etud["photo_filename"] = saved_filename
|
etud["photo_filename"] = saved_filename
|
||||||
etud["foto"] = None
|
etud["foto"] = None
|
||||||
|
Loading…
Reference in New Issue
Block a user