Deplace list blocs and list page functions
This commit is contained in:
30
app/utils.py
30
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
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user