Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deprecated before_app_first_request #323

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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