From ade56c6bb6021258cb6fb64d0e523dcb534a614f Mon Sep 17 00:00:00 2001 From: kitoy Date: Thu, 23 Jul 2026 04:27:55 +0200 Subject: [PATCH] Deplace list blocs and list page functions --- app/utils.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index 2584ed8..e92dd44 100644 --- a/app/utils.py +++ b/app/utils.py @@ -1,7 +1,7 @@ from flask import Flask, render_template, url_for, request, flash, redirect, session from functools import wraps import os - +from pathlib import Path, PurePath, PurePosixPath def login_required(f): @wraps(f) @@ -33,3 +33,31 @@ def init_app(config): print("Le dossier {} a été créé".format(public_folder)) return True + + +def list_type_blocs(theme): + + type_blocs = list() + + blocs_list = Path(PurePosixPath('app').joinpath('templates','themes', theme, 'blocs')) + for bloc_type in blocs_list.iterdir(): + if not(bloc_type.is_dir()): + name_bloc=bloc_type.name.split('.')[0] + type_blocs.append(name_bloc[1:]) + + return type_blocs + +def list_type_pages(theme): + + type_pages = list() + + pages_list = Path(PurePosixPath('app').joinpath('templates','themes', theme, 'pages')) + for page_type in pages_list.iterdir(): + if not(page_type.is_dir()): + name_page=page_type.name.split('.')[0] + type_pages.append(name_page) + + return type_pages + + +