Skip to content

Commit

Permalink
docs: add info for permission of additional states
Browse files Browse the repository at this point in the history
  • Loading branch information
rekt-hard committed Jul 23, 2024
1 parent 770abad commit 1372017
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,26 @@ In order to require an accepted curation request before publishing a record, the
Set requests permission policy
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Setting the requests permission is done due to the following reasons:

Additional actions have to be specified.

Reading a request and creating comments depends on the state. Since new states are added, these states have to be included for these two permissions.

In the default InvenioRDM implementation, a user can submit an unpublished record to a community. Doing so will result in a `CommunitySubmission` request.
If this request is accepted, the record would also get published. Our `CurationComponent` would already stop the publish action. However, in the UI, the button to accept and publish is still visible and pushing it will present the user with a generic error.
In order to prevent this, the request permissions can be adapted such that the button is not shown in the first place.
Since we only want to change the behaviour of these community submission requests, we first check the type and then check the associated record. If the record has been accepted, the general request permissions will be applied. Otherwise, no one can accept the community submission.

.. code-block:: python
from invenio_rdm_records.requests import CommunityInclusion, CommunitySubmission
from invenio_rdm_records.services.permissions import RDMRequestsPermissionPolicy
from invenio_curations.services.generators import (
IfCurationRequestAccepted,
IfRequestTypes,
)
from invenio_rdm_records.requests import CommunityInclusion, CommunitySubmission
from invenio_rdm_records.services.permissions import RDMRequestsPermissionPolicy
from invenio_requests.services.generators import Creator, Receiver, Status
class CurationRDMRequestsPermissionPolicy(RDMRequestsPermissionPolicy):
"""."""
Expand All @@ -119,6 +125,19 @@ Since we only want to change the behaviour of these community submission request
)
]
# Update can read and can comment with new states
can_read = RDMRequestsPermissionPolicy.can_read + [
Status(
["review", "critiqued", "resubmitted"],
[Creator(), Receiver()],
),
]
can_create_comment = can_read
# Add new actions
can_action_review = RDMRequestsPermissionPolicy.can_action_accept
can_action_critique = RDMRequestsPermissionPolicy.can_action_accept
can_action_resubmit = RDMRequestsPermissionPolicy.can_action_submit
REQUESTS_PERMISSION_POLICY = CurationRDMRequestsPermissionPolicy
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers =
[options]
include_package_data = True
packages = find:
python_requires = >=3.9
python_requires = >=3.12
zip_safe = False
install_requires =
invenio-drafts-resources>=3.0.0,<4.0.0
Expand Down

0 comments on commit 1372017

Please sign in to comment.