From 4aa4ab316cb5207c9d3b835fa42b9eceeba86860 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 12 Dec 2021 22:11:11 +0100 Subject: [PATCH] =?UTF-8?q?petits=20d=C3=A9tails=20(messages)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_config_actions.py | 6 ++---- app/scodoc/sco_config_form.py | 6 +++--- app/scodoc/sco_logos.py | 34 ++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/app/scodoc/sco_config_actions.py b/app/scodoc/sco_config_actions.py index bf633a26..b9157489 100644 --- a/app/scodoc/sco_config_actions.py +++ b/app/scodoc/sco_config_actions.py @@ -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, ) diff --git a/app/scodoc/sco_config_form.py b/app/scodoc/sco_config_form.py index f7ff47d7..993382de 100644 --- a/app/scodoc/sco_config_form.py +++ b/app/scodoc/sco_config_form.py @@ -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 diff --git a/app/scodoc/sco_logos.py b/app/scodoc/sco_logos.py index 8aa88c53..0d73e301 100644 --- a/app/scodoc/sco_logos.py +++ b/app/scodoc/sco_logos.py @@ -25,7 +25,7 @@ # ############################################################################## -"""Gestion des images logos (nouveau ScoDoc 9) +"""Gestion des images logos (nouveau ScoDoc 9.1) Les logos sont `logo_header.` et `logo_footer.` 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: /. : 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: