mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2026-04-04 22:08:01 +01:00
fix deprecated before_app_first_request
This commit is contained in:
committed by
martinobersteiner
parent
99705d7a25
commit
20bdff0b79
@@ -7,6 +7,7 @@
|
||||
# details.
|
||||
|
||||
"""invenio module that adds tugraz configs."""
|
||||
|
||||
from . import config
|
||||
|
||||
|
||||
@@ -28,3 +29,23 @@ class InvenioConfigTugraz(object):
|
||||
for k in dir(config):
|
||||
if k.startswith("INVENIO_CONFIG_TUGRAZ_"):
|
||||
app.config.setdefault(k, getattr(config, k))
|
||||
|
||||
|
||||
def finalize_app(app):
|
||||
"""Finalize app."""
|
||||
rank_blueprint_higher(app)
|
||||
|
||||
|
||||
def rank_blueprint_higher(app):
|
||||
"""Rank this module's blueprint higher than blueprint of security module.
|
||||
|
||||
Needed in order to overwrite email templates.
|
||||
|
||||
Since the blueprints are in a dict and the order of insertion is
|
||||
retained, popping and reinserting all items (except ours), ensures
|
||||
our blueprint will be in front.
|
||||
"""
|
||||
bps = app.blueprints
|
||||
for blueprint_name in list(bps.keys()):
|
||||
if blueprint_name != "invenio_config_tugraz":
|
||||
bps.update({blueprint_name: bps.pop(blueprint_name)})
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
"""invenio module for TUGRAZ config."""
|
||||
|
||||
from flask import Blueprint, current_app, redirect, url_for
|
||||
from flask import Blueprint, redirect, url_for
|
||||
from invenio_i18n import get_locale
|
||||
|
||||
|
||||
@@ -27,21 +27,6 @@ def ui_blueprint(app):
|
||||
blueprint.add_url_rule(routes["terms"], view_func=terms)
|
||||
blueprint.add_url_rule(routes["gdpr"], view_func=gdpr)
|
||||
|
||||
@blueprint.before_app_first_request
|
||||
def rank_higher():
|
||||
"""Rank this modules blueprint higher than blueprint of security module.
|
||||
|
||||
Needed in order to overwrite email templates.
|
||||
|
||||
Since the blueprints are in a dict and the order of insertion is
|
||||
retained, popping and reinserting all items (except ours), ensures
|
||||
our blueprint will be in front.
|
||||
"""
|
||||
bps = current_app.blueprints
|
||||
for blueprint_name in list(bps.keys()):
|
||||
if blueprint_name != "invenio_config_tugraz":
|
||||
bps.update({blueprint_name: bps.pop(blueprint_name)})
|
||||
|
||||
return blueprint
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user