diff --git a/app/models/blocs.py b/app/models/blocs.py index 2ee306d..2de2845 100644 --- a/app/models/blocs.py +++ b/app/models/blocs.py @@ -17,7 +17,7 @@ class MyBlocs: mybloc['type'] = str(blocType) return mybloc - def make_form(bloc): + def make_form(): form = FormBloc() return form diff --git a/app/routes.py b/app/routes.py index e1d610c..d27bb5b 100644 --- a/app/routes.py +++ b/app/routes.py @@ -79,7 +79,6 @@ def create_website(): if form.validate(): db = DataSite(login, USERS_FOLDER) - print("Trop cool !") if db.create(theme): db.set_passwd(bcrypt.generate_password_hash(passwd)) session['username'] = login @@ -101,12 +100,13 @@ def edit(page): db.load_file() type_pages = list_type_pages(db.datas['config']['theme']) type_blocs = list_type_blocs(db.datas['config']['theme']) - myblocs = db.get_blocs(page)['blocs'] - + myblocs = db.get_blocs(page) + footer = db.get_footer() return render_template('/edit.html.tpl', blocEdit="", config=db.datas['config'], menu=db.datas['menu'], + footer=footer, type_blocs=type_blocs, type_pages=type_pages, theme=db.datas['config']['theme'], @@ -130,13 +130,13 @@ def edit_img(page, image, bloc): db.load_file() theme = db.datas['config']['theme'] form = ImageForm() - myblocs = db.get_blocs(page)['blocs'] + myblocs = db.get_blocs(page) if form.validate_on_submit(): if request.method == 'POST': myblocs[bloc][image] = db.update_img(image, form) db.save_blocs(page, myblocs) - form = MyBlocs.make_form(myblocs[bloc]) + form = MyBlocs.make_form() if "hx-request" in request.headers: return make_response(('Image modified', 200)) else: @@ -218,7 +218,7 @@ def images_list(page, blocname): db.load_file() theme = db.datas['config']['theme'] - myblocs = db.get_blocs(page)['blocs'] + myblocs = db.get_blocs(page) bloc = myblocs[blocname] return render_template(THEMES_FOLDER+theme+'/blocs/edit/images_list.html',page=page, @@ -234,9 +234,9 @@ def edit_bloc(page, blocname): db.load_file() theme = db.datas['config']['theme'] - myblocs = db.get_blocs(page)['blocs'] + myblocs = db.get_blocs(page) bloc = myblocs[blocname] - form = MyBlocs.make_form(bloc) + form = MyBlocs.make_form() if request.method == 'POST': datas=dict() @@ -262,23 +262,24 @@ def edit_bloc(page, blocname): print(form.errors) if "hx-request" in request.headers: - return render_template(THEMES_FOLDER+theme+'/blocs/_'+bloc['type']+'.html', + resp = render_template(THEMES_FOLDER+theme+'/blocs/'+bloc['type']+'.html', theme=theme, page=page, bloc=myblocs[blocname]) else: - return redirect(url_for('edit', page=page)) + resp = redirect(url_for('edit', page=page)) else: if "hx-request" in request.headers: - return render_template(THEMES_FOLDER+theme+'/blocs/edit/_'+bloc['type']+'.html', + resp = render_template(THEMES_FOLDER+theme+'/blocs/edit/'+bloc['type']+'.html', theme=theme, bloc=bloc, page=page, form=form) + else: - return render_template('/edit.html.tpl', + resp = render_template('/edit.html.tpl', config=db.datas['config'], menu=db.datas['menu'], myblocs=myblocs, @@ -286,6 +287,7 @@ def edit_bloc(page, blocname): theme=theme, blocEdit=bloc['name'], form=form) + return resp @app.route('/view/', methods=['GET'], defaults={'page': ''}) @app.route('//view/', methods=['GET']) @@ -298,10 +300,10 @@ def view_bloc(page, bloc): db.load_file() theme = db.datas['config']['theme'] - myblocs = db.get_blocs(page)['blocs'] + myblocs = db.get_blocs(page) bloc = myblocs[bloc] - return render_template(THEMES_FOLDER+theme+'/blocs/_'+bloc['type']+'.html', + return render_template(THEMES_FOLDER+theme+'/blocs/'+bloc['type']+'.html', bloc=bloc) @app.route('/addBloc', methods=['POST'], defaults={'page': ''}) @@ -513,12 +515,13 @@ def publish(): serverInfos['Port'] = str(request.form['serverPort']) serverInfos['username'] = str(request.form['username']) serverInfos['folder'] = str(request.form['folder']) - + footer = db.get_footer() for page in listPages: - myblocs = db.get_blocs(page)['blocs'] + myblocs = db.get_blocs(page) htmlExport = render_template('/index.html.tpl', config=db.datas['config'], menu=menu, + footer=footer, theme=theme, page=page, myblocs=myblocs) @@ -526,10 +529,11 @@ def publish(): # Export index.html landing page - myblocs = db.get_blocs('')['blocs'] + myblocs = db.get_blocs('') htmlExport = render_template('/index.html.tpl', config=db.datas['config'], menu=menu, + footer=footer, theme=theme, page='/', myblocs=myblocs) diff --git a/app/templates/admin/_bloc-edit.html b/app/templates/admin/_bloc-edit.html index 4ddc0e6..61d2d22 100644 --- a/app/templates/admin/_bloc-edit.html +++ b/app/templates/admin/_bloc-edit.html @@ -16,7 +16,7 @@
-

Créé un nouveau bloc

+

Créer nouveau bloc


diff --git a/app/templates/admin/_publish.html b/app/templates/admin/_publish.html index 3d779f4..d1269d9 100644 --- a/app/templates/admin/_publish.html +++ b/app/templates/admin/_publish.html @@ -80,7 +80,7 @@
-
+

diff --git a/app/templates/edit-tools/_btn-save-cancel.html b/app/templates/edit-tools/_btn-save-cancel.html index a3e531f..2cbee8b 100644 --- a/app/templates/edit-tools/_btn-save-cancel.html +++ b/app/templates/edit-tools/_btn-save-cancel.html @@ -6,16 +6,9 @@ hx-target="#{{ bloc.name }}" > Enregistrer -
+