forked from ScoDoc/ScoDoc
msg erreur si photo eduiant inexistant
This commit is contained in:
parent
c0d02d7e3b
commit
6130d522bf
@ -53,7 +53,7 @@ import time
|
|||||||
import PIL
|
import PIL
|
||||||
from PIL import Image as PILImage
|
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 flask.helpers import make_response, url_for
|
||||||
|
|
||||||
from app import log
|
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 not etud:
|
||||||
if etudid:
|
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:
|
else:
|
||||||
raise ValueError("etud_photo_html: either etud or etudid must be specified")
|
raise ValueError("etud_photo_html: either etud or etudid must be specified")
|
||||||
photo_url = etud_photo_url(etud, size=size)
|
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:
|
def suppress_photo(etud: Identite) -> None:
|
||||||
"""Suppress a photo"""
|
"""Suppress a photo"""
|
||||||
log("suppress_photo etudid=%s" % etud.id)
|
log(f"suppress_photo {etud}")
|
||||||
rel_path = photo_pathname(etud.photo_filename)
|
rel_path = photo_pathname(etud.photo_filename)
|
||||||
# 1- remove ref. from database
|
# 1- remove ref. from database
|
||||||
etud.photo_filename = None
|
etud.photo_filename = None
|
||||||
@ -290,7 +293,7 @@ def suppress_photo(etud: Identite) -> None:
|
|||||||
rel_path = rel_path[: -len(IMAGE_EXT)]
|
rel_path = rel_path[: -len(IMAGE_EXT)]
|
||||||
filenames = glob.glob(rel_path + "*" + IMAGE_EXT)
|
filenames = glob.glob(rel_path + "*" + IMAGE_EXT)
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
log("removing file %s" % filename)
|
log(f"removing file {filename}")
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# 3- log
|
# 3- log
|
||||||
@ -351,7 +354,7 @@ def find_new_dir():
|
|||||||
if not os.path.exists(PHOTO_DIR):
|
if not os.path.exists(PHOTO_DIR):
|
||||||
os.mkdir(PHOTO_DIR)
|
os.mkdir(PHOTO_DIR)
|
||||||
# create subdirectory
|
# create subdirectory
|
||||||
log("creating directory %s" % path)
|
log(f"creating directory {path}")
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
return d + "/"
|
return d + "/"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.3.32"
|
SCOVERSION = "9.3.33"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user