forked from ScoDoc/DocScoDoc
Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc
This commit is contained in:
commit
0bf636814d
@ -108,6 +108,8 @@ def dept_key_to_id(dept_key):
|
|||||||
def logo_name_validator(message=None):
|
def logo_name_validator(message=None):
|
||||||
def validate_logo_name(form, field):
|
def validate_logo_name(form, field):
|
||||||
name = field.data if field.data else ""
|
name = field.data if field.data else ""
|
||||||
|
if "." in name:
|
||||||
|
raise ValidationError(message)
|
||||||
if not scu.is_valid_filename(name):
|
if not scu.is_valid_filename(name):
|
||||||
raise ValidationError(message)
|
raise ValidationError(message)
|
||||||
|
|
||||||
|
@ -121,7 +121,8 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX):
|
|||||||
:return: le résultat de la recherche ou None si aucune image trouvée
|
:return: le résultat de la recherche ou None si aucune image trouvée
|
||||||
"""
|
"""
|
||||||
allowed_ext = "|".join(scu.LOGOS_IMAGES_ALLOWED_TYPES)
|
allowed_ext = "|".join(scu.LOGOS_IMAGES_ALLOWED_TYPES)
|
||||||
filename_parser = re.compile(f"{prefix}([^.]*).({allowed_ext})")
|
# parse filename 'logo_<logoname>.<ext> . be carefull: logoname may include '.'
|
||||||
|
filename_parser = re.compile(f"{prefix}(([^.]*.)+)({allowed_ext})")
|
||||||
logos = {}
|
logos = {}
|
||||||
path_dir = Path(scu.SCODOC_LOGOS_DIR)
|
path_dir = Path(scu.SCODOC_LOGOS_DIR)
|
||||||
if dept_id:
|
if dept_id:
|
||||||
@ -135,7 +136,7 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX):
|
|||||||
if os.access(path_dir.joinpath(entry).absolute(), os.R_OK):
|
if os.access(path_dir.joinpath(entry).absolute(), os.R_OK):
|
||||||
result = filename_parser.match(entry.name)
|
result = filename_parser.match(entry.name)
|
||||||
if result:
|
if result:
|
||||||
logoname = result.group(1)
|
logoname = result.group(1)[:-1] # retreive logoname from filename (less final dot)
|
||||||
logos[logoname] = Logo(logoname=logoname, dept_id=dept_id).select()
|
logos[logoname] = Logo(logoname=logoname, dept_id=dept_id).select()
|
||||||
return logos if len(logos.keys()) > 0 else None
|
return logos if len(logos.keys()) > 0 else None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user