41 lines
998 B
Python
41 lines
998 B
Python
import json
|
|
import os
|
|
from werkzeug.utils import secure_filename
|
|
from app.forms import *
|
|
from PIL import Image
|
|
from os import remove, path
|
|
from pathlib import Path, PurePath, PurePosixPath
|
|
|
|
|
|
|
|
class MyBlocs:
|
|
|
|
def new(blocName, blocType, theme):
|
|
mybloc = None
|
|
if blocType in MyBlocs.listTypeBlocs(theme):
|
|
mybloc=dict()
|
|
mybloc['name'] = str(blocName)
|
|
mybloc['type'] = str(blocType)
|
|
return mybloc
|
|
|
|
def make_form(bloc):
|
|
form = FormBloc()
|
|
return form
|
|
|
|
def img_form():
|
|
return ImageForm()
|
|
|
|
def new_img_form():
|
|
return ImageUpload()
|
|
|
|
def list_type_blocs(theme):
|
|
typeBlocs = list()
|
|
folders = Path(PurePosixPath('./app').joinpath('templates', theme, 'blocs'))
|
|
for folder in folders.iterdir():
|
|
if not(folder.is_dir()):
|
|
typeBloc=folder.name.split('.')[0]
|
|
typeBlocs.append(typeBloc[1:])
|
|
|
|
return typeBlocs
|
|
|