diff --git a/invenio_app_rdm/communities_ui/views/communities.py b/invenio_app_rdm/communities_ui/views/communities.py index ba501d9ac..0a6d16332 100644 --- a/invenio_app_rdm/communities_ui/views/communities.py +++ b/invenio_app_rdm/communities_ui/views/communities.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2019-2024 CERN. -# Copyright (C) 2019-2022 Northwestern University. +# Copyright (C) 2019-2024 Northwestern University. # Copyright (C) 2022 TU Wien. # # Invenio App RDM is free software; you can redistribute it and/or modify it @@ -9,6 +9,7 @@ """Request views module.""" from flask import abort, g, redirect, request, url_for +from invenio_communities.proxies import current_communities from invenio_communities.views.communities import ( HEADER_PERMISSIONS, render_community_theme_template, @@ -26,17 +27,22 @@ def communities_detail(pid_value, community, community_ui): """Community detail page.""" permissions = community.has_permissions_to(HEADER_PERMISSIONS) endpoint = "/api/communities/{pid_value}/records" + members_service = current_communities.service.members return render_community_theme_template( "invenio_communities/records/index.html", theme=community_ui.get("theme", {}), - community=community, - community_ui=community_ui, + community=community_ui, # Pass permissions so we can disable partially UI components # e.g Settings tab permissions=permissions, active_community_header_menu_item="search", endpoint=endpoint.format(pid_value=community.to_dict()["id"]), + associated_request_id=( + members_service.get_pending_request_id_if_any( + g.identity.id, community.id + ) + ) ) @@ -96,6 +102,9 @@ def communities_home(pid_value, community, community_ui): "hits" ] + members_service = current_communities.service.members + + return render_community_theme_template( "invenio_communities/details/home/index.html", theme=community_ui.get("theme", {}), @@ -103,6 +112,11 @@ def communities_home(pid_value, community, community_ui): permissions=permissions, records=records_ui, metrics=metrics, + associated_request_id=( # in case public + members_service.get_pending_request_id_if_any( + g.identity.id, community.id + ) + ) ) @@ -115,14 +129,19 @@ def community_static_page(pid_value, community, community_ui, **kwargs): try: page = current_pages_service.read_by_url(g.identity, request.path).to_dict() - except PageNotFoundError: abort(404) + members_service = current_communities.service.members + return render_community_theme_template( page["template_name"], theme=community_ui.get("theme", {}), page=page, community=community_ui, permissions=permissions, + associated_request_id=( # in case public + members_service.get_pending_request_id_if_any( + g.identity.id, community.id) + ) ) diff --git a/invenio_app_rdm/config.py b/invenio_app_rdm/config.py index 1e28d6f81..2cf923df1 100644 --- a/invenio_app_rdm/config.py +++ b/invenio_app_rdm/config.py @@ -45,6 +45,11 @@ CommunityInvitationDeclineNotificationBuilder, CommunityInvitationExpireNotificationBuilder, CommunityInvitationSubmittedNotificationBuilder, + CommunityMembershipRequestAcceptNotificationBuilder, + CommunityMembershipRequestCancelNotificationBuilder, + CommunityMembershipRequestDeclineNotificationBuilder, + CommunityMembershipRequestExpireNotificationBuilder, + CommunityMembershipRequestSubmittedNotificationBuilder, ) from invenio_notifications.backends import EmailNotificationBackend from invenio_rdm_records.notifications.builders import ( @@ -1320,6 +1325,12 @@ def github_link_render(record): community_notifications.SubCommunityCreate.type: community_notifications.SubCommunityCreate, community_notifications.SubCommunityAccept.type: community_notifications.SubCommunityAccept, community_notifications.SubCommunityDecline.type: community_notifications.SubCommunityDecline, + # Community membership request + CommunityMembershipRequestAcceptNotificationBuilder.type: CommunityMembershipRequestAcceptNotificationBuilder, + CommunityMembershipRequestCancelNotificationBuilder.type: CommunityMembershipRequestCancelNotificationBuilder, + CommunityMembershipRequestDeclineNotificationBuilder.type: CommunityMembershipRequestDeclineNotificationBuilder, + CommunityMembershipRequestExpireNotificationBuilder.type: CommunityMembershipRequestExpireNotificationBuilder, + CommunityMembershipRequestSubmittedNotificationBuilder.type: CommunityMembershipRequestSubmittedNotificationBuilder, } """Notification builders.""" diff --git a/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/community_dashboard.html b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/community_dashboard.html index a49d96ff8..6b8deb3b2 100644 --- a/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/community_dashboard.html +++ b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/community_dashboard.html @@ -8,7 +8,7 @@ #} {% set title = invenio_request.title %} {% extends "invenio_requests/details/index.html" %} -{% from "invenio_requests/macros/request_header.html" import invitation_request_header %} +{% from "invenio_requests/macros/request_header.html" import member_request_header %} {% set active_community_header_menu_item = 'members' %} {% set active_members_menu_item = 'invitations' %} @@ -16,7 +16,7 @@ {% block request_header %} {% set back_button_url = url_for("invenio_communities.invitations", pid_value=invenio_request.created_by.community) %} {{ - invitation_request_header( + member_request_header( back_button_url=back_button_url, back_button_text=_("Back to invitations"), request=invenio_request diff --git a/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/user_dashboard.html b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/user_dashboard.html index 79d8d70e9..0e56a863c 100644 --- a/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/user_dashboard.html +++ b/invenio_app_rdm/requests_ui/templates/semantic-ui/invenio_requests/community-invitation/user_dashboard.html @@ -8,13 +8,13 @@ #} {% set title = invenio_request.title %} {% extends "invenio_requests/details/index.html" %} -{% from "invenio_requests/macros/request_header.html" import invitation_request_header %} +{% from "invenio_requests/macros/request_header.html" import member_request_header %} {% block request_header %} {% set back_button_url = url_for("invenio_app_rdm_users.requests") %} {{ - invitation_request_header( + member_request_header( back_button_url=back_button_url, back_button_text=_("Back to requests"), request=invenio_request, 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 %} +