oarepo_config.workflows.low_level
oarepo_config.workflows.low_level
Configuration for workflows.
register_workflow(workflow_code: str, workflow_name: str | LazyString, permissions_policy: str | type, requests_policy: str | type, use_low_level_workflows: bool = False) -> None
Register a submission/review workflow that records can go through.
A workflow defines the path a record takes from being created to being published - for example, who may create it, whether it needs review/approval before publishing, and who may perform each of those steps. This adds one such workflow to the repository, so that it can be selected when configuring where records may be submitted (e.g. a community).
This is a low-level, single-workflow building block. Repositories
that use the community-based workflow shape provided by the
oarepo_app package typically use its higher-level
configure_workflows(IndividualWorkflow(...), CommunityWorkflow(...))
helper instead - see this package's README for the difference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_code
|
str
|
A short, unique identifier for the workflow, e.g.
|
required |
workflow_name
|
str | LazyString
|
The human-readable name of the workflow, shown to
users, e.g. |
required |
permissions_policy
|
str | type
|
Who is allowed to do what with records that use this workflow (create, edit, delete, publish, ...). Pass either a permissions policy class or its import path as a string. |
required |
requests_policy
|
str | type
|
What review/approval requests are available for records using this workflow (e.g. a publish request that needs a curator's approval). Pass either a request policy class or its import path as a string. |
required |
use_low_level_workflows
|
bool
|
Set to |
False
|
Requires the optional oarepo_workflows (and, for its defaults,
oarepo_requests) package to be installed.
Invenio configuration variables set:
WORKFLOWS- the new workflow is appended; workflows already registered (by earlier calls) are kept.REQUESTS_PERMISSION_POLICY- only if not already set by an earlier call; defaults tooarepo_config.requests.RequestsPermissionPolicy(workflow-based, plus creation of community-topic request types).
Example
from oarepo_workflows.services.permissions import (
DefaultWorkflowPermissions,
)
from oarepo_requests.services.permissions.workflow_policies import (
CreatorsFromWorkflowRequestsPermissionPolicy,
)
config.register_workflow(
workflow_code="default",
workflow_name=_("Default workflow"),
permissions_policy=DefaultWorkflowPermissions,
requests_policy=CreatorsFromWorkflowRequestsPermissionPolicy,
)
Source code in oarepo_config/workflows/low_level.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |