From 9afcc981c24b5ff500f079c08fa5acdb15caf73e Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Fri, 28 Apr 2023 14:41:29 +0300 Subject: [PATCH] add {{ flask_form.hidden_tag() }} --- app/__init__.py | 7 +++++++ app/templates/book/add_book_modal.html | 2 +- app/templates/book/add_collection_modal.html | 1 + app/templates/book/add_contributor_modal.html | 2 +- app/templates/book/delete_collection_modal.html | 1 + app/templates/book/edit_collection_modal.html | 1 + app/templates/book/settings.html | 2 ++ app/templates/user/add.html | 1 + 8 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index c02a6d8..463108c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -5,6 +5,7 @@ from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager from werkzeug.exceptions import HTTPException from flask_migrate import Migrate +from flask_wtf import FlaskForm from app.logger import log @@ -60,6 +61,12 @@ def create_app(environment="development"): login_manager.login_message_category = "info" login_manager.anonymous_user = AnonymousUser + # Jinja globals + + # Using: {{ flask_form.hidden_tag() }} + with app.app_context(): + app.jinja_env.globals["flask_form"] = FlaskForm() + # Error handlers. @app.errorhandler(HTTPException) def handle_http_error(exc): diff --git a/app/templates/book/add_book_modal.html b/app/templates/book/add_book_modal.html index 68e2b71..1dfb3aa 100644 --- a/app/templates/book/add_book_modal.html +++ b/app/templates/book/add_book_modal.html @@ -4,7 +4,7 @@
- + {{ flask_form.hidden_tag() }} diff --git a/app/templates/book/add_collection_modal.html b/app/templates/book/add_collection_modal.html index 20b5f61..9046427 100644 --- a/app/templates/book/add_collection_modal.html +++ b/app/templates/book/add_collection_modal.html @@ -10,6 +10,7 @@ action="{{ url_for('book.collection_create', book_id=book.id) }}" {% endif %} method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700"> + {{ flask_form.hidden_tag() }}

Add {% if collection %}Sub {% endif %}Collection

diff --git a/app/templates/book/add_contributor_modal.html b/app/templates/book/add_contributor_modal.html index 7a7b11c..e353e72 100644 --- a/app/templates/book/add_contributor_modal.html +++ b/app/templates/book/add_contributor_modal.html @@ -4,7 +4,7 @@
- + {{ flask_form.hidden_tag() }} diff --git a/app/templates/book/delete_collection_modal.html b/app/templates/book/delete_collection_modal.html index d246c2e..6324569 100644 --- a/app/templates/book/delete_collection_modal.html +++ b/app/templates/book/delete_collection_modal.html @@ -10,6 +10,7 @@ action="{{ url_for('book.collection_delete', book_id=book.id, collection_id=collection.id) }}" {% endif %} method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700"> + {{ flask_form.hidden_tag() }}

Delete Collection

diff --git a/app/templates/book/edit_collection_modal.html b/app/templates/book/edit_collection_modal.html index c934b20..b713d85 100644 --- a/app/templates/book/edit_collection_modal.html +++ b/app/templates/book/edit_collection_modal.html @@ -10,6 +10,7 @@ action="{{ url_for('book.collection_edit', book_id=book.id, collection_id=collection.id) }}" {% endif %} method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700"> + {{ flask_form.hidden_tag() }}

Edit Collection

diff --git a/app/templates/book/settings.html b/app/templates/book/settings.html index 7837b57..709e91c 100644 --- a/app/templates/book/settings.html +++ b/app/templates/book/settings.html @@ -35,6 +35,7 @@ {{ contributor.user.username }} + {{ flask_form.hidden_tag() }} diff --git a/app/templates/user/add.html b/app/templates/user/add.html index 6290010..991fc09 100644 --- a/app/templates/user/add.html +++ b/app/templates/user/add.html @@ -4,6 +4,7 @@
+ {{ flask_form.hidden_tag() }}

Add new user