From 7c250a41feb5f159ef311fa37310044ba5c2f672 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 19 May 2022 20:58:31 +0200 Subject: [PATCH] refactor --- invenio_theme_tugraz/views.py | 42 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/invenio_theme_tugraz/views.py b/invenio_theme_tugraz/views.py index 664b62e..beb1c13 100644 --- a/invenio_theme_tugraz/views.py +++ b/invenio_theme_tugraz/views.py @@ -16,34 +16,36 @@ from invenio_rdm_records.resources.serializers import UIJSONSerializer from .search import FrontpageRecordsSearch +blueprint = Blueprint( + "invenio_theme_tugraz", + __name__, + template_folder="templates", + static_folder="static", +) + + +@blueprint.app_template_filter("make_dict_like") +def make_dict_like(value: str, key: str) -> Dict[str, str]: + """Convert the value to a dict like structure. + + in the form of a key -> value pair. + """ + return {key: value} + + +@blueprint.app_template_filter("cast_to_dict") +def cast_to_dict(attr_dict): + """Return the dict structure of AttrDict variable.""" + return AttrDict.to_dict(attr_dict) + def ui_blueprint(app): """Blueprint for the routes and resources provided by Invenio-theme-tugraz.""" routes = app.config.get("TUG_ROUTES") - blueprint = Blueprint( - "invenio_theme_tugraz", - __name__, - template_folder="templates", - static_folder="static", - ) - blueprint.add_url_rule(routes["index"], view_func=index) blueprint.add_url_rule(routes["comingsoon"], view_func=comingsoon) - @blueprint.app_template_filter("make_dict_like") - def make_dict_like(value: str, key: str) -> Dict[str, str]: - """Convert the value to a dict like structure. - - in the form of a key -> value pair. - """ - return {key: value} - - @blueprint.app_template_filter("cast_to_dict") - def cast_to_dict(attr_dict): - """Return the dict structure of AttrDict variable.""" - return AttrDict.to_dict(attr_dict) - return blueprint