diff --git a/invenio_userprofiles/ext.py b/invenio_userprofiles/ext.py index 809193a..d0114e9 100644 --- a/invenio_userprofiles/ext.py +++ b/invenio_userprofiles/ext.py @@ -9,6 +9,11 @@ """User profiles module for Invenio.""" +from flask_menu import current_menu +from invenio_i18n import LazyString +from invenio_i18n import lazy_gettext as _ +from invenio_theme.proxies import current_theme_icons + from . import config from .api import current_userprofile from .forms import confirm_register_form_factory, register_form_factory @@ -75,6 +80,7 @@ def finalize_app(app): NOTE: replace former @record_once decorator """ init_common(app) + init_menu(app) def api_finalize_app(app): @@ -93,3 +99,15 @@ def init_common(app): security_ext.confirm_register_form ) security_ext.register_form = register_form_factory(security_ext.register_form) + + +def init_menu(app): + """Init menu.""" + current_menu.submenu("settings.profile").register( + endpoint="invenio_userprofiles.profile", + text=_( + "%(icon)s Profile", + icon=LazyString(lambda: f''), + ), + order=0, + ) diff --git a/invenio_userprofiles/views.py b/invenio_userprofiles/views.py index b7da167..b2adf65 100644 --- a/invenio_userprofiles/views.py +++ b/invenio_userprofiles/views.py @@ -3,7 +3,7 @@ # This file is part of Invenio. # Copyright (C) 2015-2018 CERN. # Copyright (C) 2022 Northwestern University. -# Copyright (C) 2023 Graz University of Technology. +# Copyright (C) 2023-2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -24,9 +24,7 @@ from flask_login import current_user, login_required from flask_security.confirmable import send_confirmation_instructions from invenio_db import db -from invenio_i18n import LazyString from invenio_i18n import lazy_gettext as _ -from invenio_theme import menu from .forms import EmailProfileForm, PreferencesForm, ProfileForm, VerificationForm from .models import UserProfileProxy @@ -38,6 +36,7 @@ def create_blueprint(app): "invenio_userprofiles", __name__, template_folder="templates", + url_prefix="/account/settings", ) @blueprint.app_template_filter() @@ -48,17 +47,6 @@ def userprofile(value): blueprint.add_url_rule("/", "profile", view_func=profile, methods=["GET", "POST"]) - icons = app.extensions["invenio-theme"].icons - - menu.submenu("settings.profile").register( - endpoint="invenio_userprofiles.profile", - text=_( - "%(icon)s Profile", - icon=LazyString(lambda: f''), - ), - order=0, - ) - return blueprint