From 53a00d1d8deb3caecd4c6c2569b0fdc0ecc4ed89 Mon Sep 17 00:00:00 2001 From: Guillaume Viger Date: Mon, 29 Jul 2024 15:30:56 -0400 Subject: [PATCH] membership-requests [#855]: add discussion page in community dashboard [+] - also fix top menu to display "Members" --- .../community_dashboard.html | 38 +++++++++++++++++++ invenio_app_rdm/requests_ui/views/requests.py | 29 +++++++++++--- 2 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-membership-request/community_dashboard.html diff --git a/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-membership-request/community_dashboard.html b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-membership-request/community_dashboard.html new file mode 100644 index 000000000..b4e3e4bed --- /dev/null +++ b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-membership-request/community_dashboard.html @@ -0,0 +1,38 @@ +{# -*- coding: utf-8 -*- + + This file is part of Invenio. + Copyright (C) 2022 CERN. + Copyright (C) 2024 Northwestern University + + 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. +#} +{% set title = invenio_request.title %} +{% extends "invenio_requests/details/index.html" %} +{% from "invenio_requests/macros/request_header.html" import member_request_header %} + +{% set active_community_header_menu_item = 'members' %} +{% set active_members_menu_item = 'membership_requests' %} + +{% block request_header %} + {{ + member_request_header( + back_button_url=url_for("invenio_communities.membership_requests", pid_value=invenio_request.receiver.community), + back_button_text=_("Back to membership requests"), + request=invenio_request + ) + }} +{% endblock %} + + +{% block settings_body %} +
+ {% block request_body %} + {{ super() }} + {% endblock request_body %} +
+{% endblock %} + +{% block page_body %} + {{ super.super() }} +{% endblock page_body %} diff --git a/invenio_app_rdm/requests_ui/views/requests.py b/invenio_app_rdm/requests_ui/views/requests.py index ab0144fb4..151a71485 100644 --- a/invenio_app_rdm/requests_ui/views/requests.py +++ b/invenio_app_rdm/requests_ui/views/requests.py @@ -12,7 +12,10 @@ from flask import g, render_template from flask_login import current_user, login_required from invenio_communities.config import COMMUNITIES_ROLES -from invenio_communities.members.services.request import CommunityInvitation +from invenio_communities.members.services.request import ( + CommunityInvitation, + MembershipRequestRequestType, +) from invenio_communities.proxies import current_identities_cache from invenio_communities.utils import identity_cache_key from invenio_communities.views.communities import render_community_theme_template @@ -238,7 +241,10 @@ def community_dashboard_request_view(request, community, community_ui, **kwargs) is_draft_submission = request_type == CommunitySubmission.type_id is_record_inclusion = request_type == CommunityInclusion.type_id - is_member_invitation = request_type == CommunityInvitation.type_id + types_of_member_requests = [ + CommunityInvitation.type_id, + MembershipRequestRequestType.type_id, + ] request_is_accepted = request["status"] == AcceptAction.status_to if is_draft_submission or is_record_inclusion: @@ -273,12 +279,23 @@ def community_dashboard_request_view(request, community, community_ui, **kwargs) include_deleted=False, ) - elif is_member_invitation: + elif request_type in types_of_member_requests: permissions = community.has_permissions_to( - ["update", "read", "search_requests", "search_invites"] + [ + "update", + "read", + "search_requests", + "members_search_public", + "search_invites", + "search_membership_requests", + ] ) - if not permissions["can_search_invites"]: - raise PermissionDeniedError() + if request_type == CommunityInvitation.type_id: + if not permissions["can_search_invites"]: + raise PermissionDeniedError() + else: # is a membership request + if not permissions["can_search_membership_requests"]: + raise PermissionDeniedError() return render_community_theme_template( f"invenio_requests/{request_type}/community_dashboard.html",