mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 17:58:24 -04:00
Add extension initialisation in app init
This commit is contained in:
@@ -7,6 +7,7 @@ from numbers import Number
|
|||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
|
||||||
import ago
|
import ago
|
||||||
|
import jinja2
|
||||||
from flask import (
|
from flask import (
|
||||||
current_app,
|
current_app,
|
||||||
flash,
|
flash,
|
||||||
@@ -22,6 +23,7 @@ from flask.globals import _lookup_req_object, _request_ctx_stack
|
|||||||
from flask_login import LoginManager, current_user
|
from flask_login import LoginManager, current_user
|
||||||
from flask_wtf import CSRFProtect
|
from flask_wtf import CSRFProtect
|
||||||
from flask_wtf.csrf import CSRFError
|
from flask_wtf.csrf import CSRFError
|
||||||
|
from govuk_frontend_jinja.flask_ext import init_govuk_frontend
|
||||||
from itsdangerous import BadSignature
|
from itsdangerous import BadSignature
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
from notifications_utils import formatters, logging, request_helper
|
from notifications_utils import formatters, logging, request_helper
|
||||||
@@ -116,6 +118,9 @@ def create_app(application):
|
|||||||
|
|
||||||
init_app(application)
|
init_app(application)
|
||||||
|
|
||||||
|
init_govuk_frontend(application)
|
||||||
|
init_jinja(application)
|
||||||
|
|
||||||
for client in (
|
for client in (
|
||||||
|
|
||||||
# Gubbins
|
# Gubbins
|
||||||
@@ -701,3 +706,13 @@ def add_template_filters(application):
|
|||||||
id_safe,
|
id_safe,
|
||||||
]:
|
]:
|
||||||
application.add_template_filter(fn)
|
application.add_template_filter(fn)
|
||||||
|
|
||||||
|
|
||||||
|
def init_jinja(application):
|
||||||
|
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
template_folders = [
|
||||||
|
os.path.join(repo_root, 'app/templates'),
|
||||||
|
os.path.join(repo_root, 'node_modules/govuk-frontend'),
|
||||||
|
]
|
||||||
|
jinja_loader = jinja2.FileSystemLoader(template_folders)
|
||||||
|
application.jinja_loader = jinja_loader
|
||||||
|
|||||||
Reference in New Issue
Block a user