petits détails (messages)

This commit is contained in:
Emmanuel Viennet 2021-12-12 22:11:11 +01:00
parent 10941b6ef4
commit 4aa4ab316c
3 changed files with 26 additions and 20 deletions

View File

@ -26,9 +26,7 @@
##############################################################################
"""
Module main: page d'accueil, avec liste des départements
Emmanuel Viennet, 2021
"""
from app.models import ScoDocSiteConfig
from app.scodoc.sco_logos import write_logo, find_logo, delete_logo
@ -101,7 +99,7 @@ class LogoDelete(Action):
def __init__(self, parameters):
super().__init__(
f"Suppression du logo {parameters['logo_id']} pour le département {parameters['dept_id']}.",
f"Suppression du logo {parameters['logo_id']} pour le département {parameters['dept_id'] or 'tous'}.",
parameters,
)
@ -128,7 +126,7 @@ class LogoInsert(Action):
def __init__(self, parameters):
super().__init__(
f"Ajout du logo {parameters['name']} pour le département {parameters['dept_key']} ({parameters['upload']}).",
f"Ajout du logo {parameters['name']} pour le département {parameters['dept_key']} ({parameters['upload'].filename}).",
parameters,
)

View File

@ -26,9 +26,9 @@
##############################################################################
"""
Module main: page d'accueil, avec liste des départements
Formulaires configuration logos
Emmanuel Viennet, 2021
Contrib @jmp, dec 21
"""
import re
@ -36,7 +36,7 @@ from flask import flash, url_for, redirect, render_template
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import SelectField, SubmitField, FormField, validators, FieldList
from wtforms.fields.simple import BooleanField, StringField, HiddenField
from wtforms.fields.simple import StringField, HiddenField
from app import AccessDenied
from app.models import Departement

View File

@ -25,7 +25,7 @@
#
##############################################################################
"""Gestion des images logos (nouveau ScoDoc 9)
"""Gestion des images logos (nouveau ScoDoc 9.1)
Les logos sont `logo_header.<ext>` et `logo_footer.<ext>`
avec `ext` membre de LOGOS_IMAGES_ALLOWED_TYPES (= jpg, png)
@ -104,7 +104,7 @@ def list_logos():
def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX):
"""nventorie toutes les images existantes pour un niveau (GLOBAL ou un département).
"""Inventorie toutes les images existantes pour un niveau (GLOBAL ou un département).
retourne un dictionnaire de Logo [logoname] -> Logo
les noms des fichiers concernés doivent être de la forme: <rep>/<prefix><name>.<suffixe>
<rep> : répertoire de recherche (déduit du dept_id)
@ -164,16 +164,24 @@ class Logo:
self.basepath = os.path.sep.join(
[self.dirpath, self.prefix + secure_filename(self.logoname)]
)
# next attributes are computer by the select function
self.suffix = "Not inited: call the select or create function before access"
self.filepath = "Not inited: call the select or create function before access"
self.filename = "Not inited: call the select or create function before access"
self.size = "Not inited: call the select or create function before access"
self.aspect_ratio = (
"Not inited: call the select or create function before access"
# next attributes are computed by the select function
self.suffix = (
"Not initialized: call the select or create function before access"
)
self.density = "Not inited: call the select or create function before access"
self.mm = "Not inited: call the select or create function before access"
self.filepath = (
"Not initialized: call the select or create function before access"
)
self.filename = (
"Not initialized: call the select or create function before access"
)
self.size = "Not initialized: call the select or create function before access"
self.aspect_ratio = (
"Not initialized: call the select or create function before access"
)
self.density = (
"Not initialized: call the select or create function before access"
)
self.mm = "Not initialized: call the select or create function before access"
def _set_format(self, fmt):
self.suffix = fmt
@ -183,7 +191,7 @@ class Logo:
def _ensure_directory_exists(self):
"create enclosing directory if necessary"
if not Path(self.dirpath).exists():
current_app.logger.info(f"sco_logos creating directory %s", self.dirpath)
current_app.logger.info("sco_logos creating directory %s", self.dirpath)
os.mkdir(self.dirpath)
def create(self, stream):
@ -195,7 +203,7 @@ class Logo:
filename = self.basepath + "." + self.suffix
with open(filename, "wb") as f:
f.write(stream.read())
current_app.logger.info(f"sco_logos.store_image %s", self.filename)
current_app.logger.info("sco_logos.store_image %s", self.filename)
# erase other formats if they exists
for suffix in set(scu.LOGOS_IMAGES_ALLOWED_TYPES) - set([img_type]):
try: