From 4a13f22de438a9bce7eb8ee8172a32e212377de8 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Tue, 7 May 2024 10:10:38 +0200 Subject: [PATCH] overview: view publications only if permission --- invenio_theme_tugraz/ext.py | 6 ++++++ .../templates/invenio_theme_tugraz/overview.html | 2 ++ setup.cfg | 2 ++ 3 files changed, 10 insertions(+) diff --git a/invenio_theme_tugraz/ext.py b/invenio_theme_tugraz/ext.py index 74b1296b..3485ca1b 100644 --- a/invenio_theme_tugraz/ext.py +++ b/invenio_theme_tugraz/ext.py @@ -8,6 +8,8 @@ """invenio module for TUGRAZ theme.""" +from invenio_records_marc21.ui.theme import current_identity_can_view + from . import config from .views import index, locked @@ -29,6 +31,10 @@ def init_app(self, app): app.register_error_handler(423, locked) + @app.context_processor + def inject_visibility(): + return {"can_view_marc21": current_identity_can_view()} + app.extensions["invenio-theme-tugraz"] = self def init_config(self, app): diff --git a/invenio_theme_tugraz/templates/invenio_theme_tugraz/overview.html b/invenio_theme_tugraz/templates/invenio_theme_tugraz/overview.html index 29675d4f..02db9d4e 100644 --- a/invenio_theme_tugraz/templates/invenio_theme_tugraz/overview.html +++ b/invenio_theme_tugraz/templates/invenio_theme_tugraz/overview.html @@ -54,6 +54,7 @@

{{ _("Requests") }}

+ {% if can_view_marc21 %}

{{ _("Publications") }}

@@ -65,6 +66,7 @@

{{ _("Publications") }}

+ {% endif %}

{{ _("Educational Resources") }}

diff --git a/setup.cfg b/setup.cfg index a4942e81..2ed96d2d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,10 +40,12 @@ install_requires = invenio-i18n>=1.3.1 invenio_config_tugraz>=0.11.0 invenio_records_global_search>=0.0.1 + invenio_records_marc21>=0.21.0 [options.extras_require] tests = invenio-app>=1.3.4,<1.4.0 + invenio-previewer>=2.2.0 invenio-search[opensearch2]>=2.1.0,<3.0.0 pytest-black-ng>=0.4.0 pytest-invenio>=2.1.0,<3.0.0