oarepo_config.requests
oarepo_config.requests
Requests permission policy for oarepo-config.
By default oarepo-workflows replaces invenio's request-create permission with a
workflow-driven one (CreatorsFromWorkflowRequestsPermissionPolicy -> the
FromRecordWorkflow generator), which resolves the governing workflow from the
request topic's parent.workflow. That works for record-topic requests (publish,
new version, secondary-community submission, ...), but a handful of core
invenio/RDM request types have a community as their topic:
community-membership-request(a user asks to join a community)community-invitation(a community invites a user)subcommunity(a community asks to become a sub-community of another)subcommunity-invitation(a community invites another as its sub-community)
A community has no parent.workflow (its workflow lives in
custom_fields.workflow), so FromRecordWorkflow can never resolve a workflow
for these and their creation is always denied. These request types already gate
themselves in their own services (e.g. the members service's request_membership
/ members_invite checks), so for them we fall back to invenio's default
behaviour -- any authenticated user may create the request -- while every other
(record-topic) request type keeps the workflow-driven check unchanged.
IfRequestType
Bases: ConditionalGenerator
Choose generators based on the type_id of the request being created.
Source code in oarepo_config/requests.py
__init__(type_ids: frozenset[str], then_: list, else_: list) -> None
Store the matching type ids and the two generator branches.
RequestsPermissionPolicy
Bases: CreatorsFromWorkflowRequestsPermissionPolicy
Requests permission policy that also allows community-topic requests.
Extends the workflow-based policy so the four community-topic request types (which have no resolvable workflow) can still be created.