Skip to content

Commit

Permalink
requests: pass record topic required permission via context
Browse files Browse the repository at this point in the history
  • Loading branch information
zzacharo committed Feb 20, 2025
1 parent cbec07c commit 1ab411b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions invenio_rdm_records/requests/community_inclusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CommunityInclusion(RequestType):
allowed_topic_ref_types = ["record"]
needs_context = {
"community_roles": ["owner", "manager", "curator"],
"record_permission": "preview",
}

available_actions = {
Expand Down
1 change: 1 addition & 0 deletions invenio_rdm_records/requests/community_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class CommunitySubmission(ReviewRequest):
allowed_topic_ref_types = ["record"]
needs_context = {
"community_roles": ["owner", "manager", "curator"],
"record_permission": "preview",
}

available_actions = {
Expand Down
11 changes: 6 additions & 5 deletions invenio_rdm_records/requests/entity_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ def get_needs(self, ctx=None):
A user that can preview a record can also read its requests.
"""
record = self.resolve()
# TODO: we might need different needs for drafts and published records
# e.g community submission request vs community inclusion request
needs = current_rdm_records_service.config.permission_policy_cls(
"preview", record=record
).needs
needs = []
record_permission = ctx.get("record_permission")
if record_permission:
needs = current_rdm_records_service.config.permission_policy_cls(
record_permission, record=record
).needs
return needs


Expand Down

0 comments on commit 1ab411b

Please sign in to comment.