Skip to content

Commit 9166a2b

Browse files
committed
refactor: move to context_identity
* this change enables migration to marshmallow>=4.0 by fixing deprecation warning about removing context usage
1 parent 4740dd0 commit 9166a2b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

invenio_requests/services/schemas.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from datetime import timezone
1414

15+
from invenio_access.context import context_identity
1516
from invenio_records_resources.services.records.schema import BaseRecordSchema
1617
from marshmallow import (
1718
INCLUDE,
@@ -96,14 +97,15 @@ class RequestEventSchema(BaseRecordSchema):
9697
def get_permissions(self, obj):
9798
"""Return permissions to act on comments or empty dict."""
9899
is_comment = obj.type == CommentEventType
100+
current_identity = context_identity.get()
99101
if is_comment:
100102
service = current_requests.request_events_service
101103
return {
102104
"can_update_comment": service.check_permission(
103-
self.context["identity"], "update_comment", event=obj
105+
current_identity, "update_comment", event=obj
104106
),
105107
"can_delete_comment": service.check_permission(
106-
self.context["identity"], "delete_comment", event=obj
108+
current_identity, "delete_comment", event=obj
107109
),
108110
}
109111
else:

0 commit comments

Comments
 (0)