-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to permissions only #22
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rekt-hard
force-pushed
the
switch-to-permissions-only
branch
from
September 25, 2024 10:22
2b57d75
to
5def4a1
Compare
max-moser
approved these changes
Sep 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, please note that overriding the permission policy for records is significantly more complex than overriding the one for requests! | ||
In fact, it's out of scope for this README. | ||
In fact, it's out of scope for this README - or is it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on lines
+25
to
+71
class CurationRDMRecordPermissionPolicy(RDMRecordPermissionPolicy): | ||
"""RDM record policy for curations.""" | ||
|
||
can_preview = RDMRecordPermissionPolicy.can_preview + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
can_view = RDMRecordPermissionPolicy.can_view + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
can_read = RDMRecordPermissionPolicy.can_read + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
can_read_files = RDMRecordPermissionPolicy.can_read_files + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
|
||
# in order to get all base permissions in, we just add ours instead of adapting the then_ clause of the base permission | ||
can_get_content_files = RDMRecordPermissionPolicy.can_get_content_files + [ | ||
IfFileIsLocal(then_=can_read_files, else_=[SystemProcess()]) | ||
] | ||
|
||
can_read_draft = RDMRecordPermissionPolicy.can_read_draft + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
can_draft_read_files = RDMRecordPermissionPolicy.can_draft_read_files + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
|
||
# in order to get all base permissions in, we just add ours instead of adapting the then_ clause of the base permission | ||
can_draft_get_content_files = ( | ||
RDMRecordPermissionPolicy.can_draft_get_content_files | ||
+ [IfFileIsLocal(then_=can_draft_read_files, else_=[SystemProcess()])] | ||
) | ||
|
||
# in order to get all base permissions in, we just add ours instead of adapting the then_ clause of the base permission | ||
can_draft_media_get_content_files = ( | ||
RDMRecordPermissionPolicy.can_draft_media_get_content_files | ||
+ [IfFileIsLocal(then_=can_preview, else_=[SystemProcess()])] | ||
) | ||
|
||
can_media_read_files = RDMRecordPermissionPolicy.can_media_read_files + [ | ||
IfCurationRequestExists(then_=[CurationModerators()], else_=[]) | ||
] | ||
can_media_get_content_files = ( | ||
RDMRecordPermissionPolicy.can_media_get_content_files | ||
+ [IfFileIsLocal(then_=can_read, else_=[SystemProcess()])] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rekt-hard
force-pushed
the
switch-to-permissions-only
branch
from
October 1, 2024 07:17
5def4a1
to
e7d0416
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove access grants, as they can be deleted by users. This could lead to curators losing the possibility to review a record.
Instead, an example permission policy has been added to show an example of which permissions should be changed for this package to work as expected.