Skip to content

Commit

Permalink
membership-requests [inveniosoftware#855]: add discussion page in com…
Browse files Browse the repository at this point in the history
…munity dashboard [+]

- also fix top menu to display "Members"
  • Loading branch information
fenekku committed Jul 29, 2024
1 parent e214755 commit 53a00d1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 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 %}
29 changes: 23 additions & 6 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.utils import identity_cache_key
from invenio_communities.views.communities import render_community_theme_template
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 53a00d1

Please sign in to comment.