diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index 2bb2471997..c7e2b59bf0 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -53,7 +53,7 @@ import time import PIL from PIL import Image as PILImage -from flask import request, g, has_request_context +from flask import abort, request, g, has_request_context from flask.helpers import make_response, url_for from app import log @@ -188,7 +188,10 @@ def etud_photo_html(etud: dict = None, etudid=None, title=None, size="small"): """ if not etud: if etudid: - etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] + etuds = sco_etud.get_etud_info(filled=True, etudid=etudid) + if not etuds: + return abort(404, "etudiant inconnu") + etud = etuds[0] else: raise ValueError("etud_photo_html: either etud or etudid must be specified") photo_url = etud_photo_url(etud, size=size) @@ -278,7 +281,7 @@ def store_photo(etud: dict, data, filename: str) -> tuple[bool, str]: def suppress_photo(etud: Identite) -> None: """Suppress a photo""" - log("suppress_photo etudid=%s" % etud.id) + log(f"suppress_photo {etud}") rel_path = photo_pathname(etud.photo_filename) # 1- remove ref. from database etud.photo_filename = None @@ -290,7 +293,7 @@ def suppress_photo(etud: Identite) -> None: rel_path = rel_path[: -len(IMAGE_EXT)] filenames = glob.glob(rel_path + "*" + IMAGE_EXT) for filename in filenames: - log("removing file %s" % filename) + log(f"removing file {filename}") os.remove(filename) db.session.commit() # 3- log @@ -351,7 +354,7 @@ def find_new_dir(): if not os.path.exists(PHOTO_DIR): os.mkdir(PHOTO_DIR) # create subdirectory - log("creating directory %s" % path) + log(f"creating directory {path}") os.mkdir(path) return d + "/" diff --git a/sco_version.py b/sco_version.py index 6b2ac7e08a..88cf2c366b 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.32" +SCOVERSION = "9.3.33" SCONAME = "ScoDoc"