Skip to content

Commit

Permalink
membership-requests [#855]: add discussion page in community dashboar…
Browse files Browse the repository at this point in the history
…d [+]

- also fix top menu to display "Members"
  • Loading branch information
fenekku committed Jul 30, 2024
1 parent ce94069 commit 77aa1b7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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 %}
<div class="sixteen wide mobile sixteen wide tablet thirteen wide computer column right floated">
{% block request_body %}
{{ super() }}
{% endblock request_body %}
</div>
{% endblock %}

{% block page_body %}
{{ super.super() }}
{% endblock page_body %}
30 changes: 25 additions & 5 deletions invenio_app_rdm/requests_ui/views/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.subcommunities.services.request import SubCommunityRequest
from invenio_communities.utils import identity_cache_key
Expand Down Expand Up @@ -240,8 +243,11 @@ 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
is_subcommunity_request = request_type == SubCommunityRequest.type_id
types_of_member_requests = [
CommunityInvitation.type_id,
MembershipRequestRequestType.type_id,
]
request_is_accepted = request["status"] == AcceptAction.status_to

permissions = community.has_permissions_to(
Expand Down Expand Up @@ -277,9 +283,23 @@ def community_dashboard_request_view(request, community, community_ui, **kwargs)
include_deleted=False,
)

elif is_member_invitation:
if not permissions["can_search_invites"]:
raise PermissionDeniedError()
elif request_type in types_of_member_requests:
permissions = community.has_permissions_to(
[
"update",
"read",
"search_requests",
"members_search_public",
"search_invites",
"search_membership_requests",
]
)
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",
Expand Down

0 comments on commit 77aa1b7

Please sign in to comment.