From 533ed0de94a8678696cea009fa44c2b5fca324e8 Mon Sep 17 00:00:00 2001 From: David Eckhard Date: Wed, 17 Jul 2024 12:29:42 +0200 Subject: [PATCH] ui: do not show view record button and set link and active item --- .../semantic-ui/invenio_curations/overview.html | 11 ++--------- .../invenio_requests/rdm-curation/index.html | 16 ++++++++-------- invenio_curations/views/ui.py | 6 ++++-- setup.cfg | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/invenio_curations/templates/semantic-ui/invenio_curations/overview.html b/invenio_curations/templates/semantic-ui/invenio_curations/overview.html index ec3a79e..bb75c33 100644 --- a/invenio_curations/templates/semantic-ui/invenio_curations/overview.html +++ b/invenio_curations/templates/semantic-ui/invenio_curations/overview.html @@ -1,8 +1,7 @@ {# -Copyright (C) 2020 CERN. -Copyright (C) 2020 Northwestern University. +Copyright (C) 2024 Graz University of Technology. -Invenio App RDM is free software; you can redistribute it and/or modify it +Invenio-Curations is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. #} {%- set title = _("Requests") %} @@ -16,15 +15,9 @@ {%- endblock javascript %} {%- block user_dashboard_body %} -{% if has_permission %}
-{% else %} -
- 403 -
-{% endif %} {%- endblock user_dashboard_body %} diff --git a/invenio_curations/templates/semantic-ui/invenio_requests/rdm-curation/index.html b/invenio_curations/templates/semantic-ui/invenio_requests/rdm-curation/index.html index 184cb5f..c77b143 100644 --- a/invenio_curations/templates/semantic-ui/invenio_requests/rdm-curation/index.html +++ b/invenio_curations/templates/semantic-ui/invenio_requests/rdm-curation/index.html @@ -1,27 +1,27 @@ {# -*- coding: utf-8 -*- - This file is part of Invenio. - Copyright (C) 2016-2023 CERN. + Copyright (C) 2024 Graz University of Technology. - Invenio is free software; you can redistribute it and/or modify it + Invenio-Curations is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. #} {# - Renders the request details page when publishing a draft and including it in a community. + Renders the rdm-curation request details page. #} {% extends "invenio_requests/details/index.html" %} - -{% set active_dashboard_menu_item = 'curation-overview' %} +{% set is_curator = current_user.has_role(config["CURATIONS_MODERATION_ROLE"]) %} +{% set active_dashboard_menu_item = "curation-overview" if is_curator else "requests" %} {%- block request_header %} - {% set back_button_url = url_for("invenio_curations.curation_requests_overview") %} + + {% set back_button_url = url_for("invenio_curations.curation_requests_overview" if is_curator else "invenio_app_rdm_users.requests") %} {% from "invenio_requests/macros/request_header.html" import inclusion_request_header %} {{ inclusion_request_header( request=invenio_request, record=record, - accepted=request_is_accepted, + accepted=False, back_button_url=back_button_url, back_button_text=_("Back to requests") ) }} diff --git a/invenio_curations/views/ui.py b/invenio_curations/views/ui.py index f2922bc..a30483b 100644 --- a/invenio_curations/views/ui.py +++ b/invenio_curations/views/ui.py @@ -7,7 +7,7 @@ """Curations ui views module.""" -from flask import Blueprint, g, render_template +from flask import Blueprint, abort, g, render_template from flask_login import current_user from invenio_users_resources.proxies import current_user_resources @@ -26,6 +26,9 @@ def user_has_curations_management_role(identity): def curation_requests_overview(): """Display user dashboard page.""" + if not user_has_curations_management_role(g.identity): + abort(403) + url = current_user_resources.users_service.links_item_tpl.expand( g.identity, current_user )["avatar"] @@ -34,7 +37,6 @@ def curation_requests_overview(): "invenio_curations/overview.html", searchbar_config=dict(searchUrl="/"), user_avatar=url, - has_permission=user_has_curations_management_role(g.identity), ) diff --git a/setup.cfg b/setup.cfg index 11e5857..61673e6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,8 +25,8 @@ packages = find: python_requires = >=3.9 zip_safe = False install_requires = - invenio-requests>=4.1.0,<5.0.0 invenio-drafts-resources>=3.0.0,<4.0.0 + invenio-requests>=4.1.0,<5.0.0 [options.extras_require] tests = pytest-black-ng>=0.4.0