Skip to content

Commit

Permalink
fix deprecated before_app_first_request
Browse files Browse the repository at this point in the history
  • Loading branch information
martinobersteiner committed Jun 11, 2024
1 parent 049063f commit 923d4e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
24 changes: 24 additions & 0 deletions invenio_theme_tugraz/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"""invenio module for TUGRAZ theme."""

from invenio_i18n import lazy_gettext as _
from invenio_records_marc21.ui.theme import current_identity_can_view

from . import config
Expand Down Expand Up @@ -42,3 +43,26 @@ def init_config(self, app):
for k in dir(config):
if k.startswith("INVENIO_THEME_TUGRAZ_") or k.startswith("THEME_TUGRAZ_"):
app.config.setdefault(k, getattr(config, k))


def finalize_app(app):
"""Finalize app."""
modify_user_dashboard(app)


def modify_user_dashboard(app):
"""Modify user dashboard."""
root_menu = app.extensions["menu"].root_node

user_dashboard_menu = root_menu.submenu("dashboard")
user_dashboard_menu.submenu("overview").register(
"invenio_theme_tugraz.overview",
text=_("Overview"),
order=0,
)

root_menu.submenu("actions.deposit").register(
"invenio_theme_tugraz.overview",
_("My dashboard"),
order=1,
)
22 changes: 0 additions & 22 deletions invenio_theme_tugraz/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

from flask import Blueprint, g, render_template
from flask_login import current_user, login_required
from flask_menu import current_menu
from invenio_i18n import lazy_gettext as _

# from invenio_rdm_records.resources.serializers import UIJSONSerializer
from invenio_records_global_search.resources.serializers import (
GlobalSearchJSONSerializer,
)
Expand Down Expand Up @@ -60,24 +56,6 @@ def cast_to_dict(attr_dict):
return AttrDict.to_dict(attr_dict)


@blueprint.before_app_first_request
def modify_user_dashboard():
"""Modify user dashboard."""
user_dashboard_menu = current_menu.submenu("dashboard")

user_dashboard_menu.submenu("overview").register(
"invenio_theme_tugraz.overview",
text=_("Overview"),
order=0,
)

current_menu.submenu("actions.deposit").register(
"invenio_theme_tugraz.overview",
_("My dashboard"),
order=1,
)


def ui_blueprint(app):
"""Blueprint for the routes and resources provided by Invenio-theme-tugraz."""
routes = app.config.get("TUG_ROUTES")
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ invenio_assets.webpack =
invenio_theme_tugraz_theme = invenio_theme_tugraz.webpack:theme
invenio_config.module =
invenio_theme_tugraz = invenio_theme_tugraz.config
invenio_base.finalize_app =
invenio_theme_tugraz = invenio_theme_tugraz.ext:finalize_app

[aliases]
test = pytest
Expand Down

0 comments on commit 923d4e8

Please sign in to comment.