oarepo_config.workflows
oarepo_config.workflows
Configuration for workflows.
Modules:
| Name | Description |
|---|---|
low_level |
Configuration for workflows. |
simplified |
OARepo application workflow configuration package. |
BaseWorkflowSettings
dataclass
Shared configuration common to all workflow types.
Source code in oarepo_config/workflows/simplified/base.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
code: str = 'undefined'
class-attribute
instance-attribute
The code of the workflow type.
label: LazyString = _('Undefined policy')
class-attribute
instance-attribute
The label of the workflow type.
base_permission_policy: type[Any] = DefaultRDMWorkflowPermissions
class-attribute
instance-attribute
The base permission policy class for this workflow that will be configured.
base_request_policy: type[WorkflowRequestPolicy] = WorkflowRequestPolicy
class-attribute
instance-attribute
The base requests policy class for this workflow that will be configured.
review_request_states: list[str] = dataclasses.field(default_factory=lambda: ['draft'])
class-attribute
instance-attribute
Record workflow states in which a review request may be submitted.
record_view_permissions: dict[str, list[Generator]] = dataclasses.field(default_factory=dict)
class-attribute
instance-attribute
View permissions for records in this workflow.
It is a dictionary, the key is record state and the value is a list of generators.
publish_after_review: bool = True
class-attribute
instance-attribute
Publish immediately after reviewer approves the review request.
extra_permissions: type[BasePermissionPolicy] | Callable[[type[BasePermissionPolicy]], type[BasePermissionPolicy]] | None = None
class-attribute
instance-attribute
Extra permissions to apply to the record permission policy.
If a callable is provided, it will be called with the generated permission policy as an argument and should return a modified permission policy. If a class is provided, it will be used as a mixin for the generated permission policy.
extra_requests: type[WorkflowRequestPolicy] | Callable[[type[WorkflowRequestPolicy]], type[WorkflowRequestPolicy]] | None = None
class-attribute
instance-attribute
Extra requests to apply to the workflow request policy.
If a callable is provided, it will be called with the generated request policy as an argument and should return a modified request policy. If a class is provided, it will be used as a mixin for the generated request policy.
authenticated_draft_creation: bool = False
class-attribute
instance-attribute
Allow authenticated users to create draft records.
When enabled and no role- or need-based restrictions are configured, any
authenticated user may create a draft. Subclasses may override this
default (e.g. IndividualWorkflow sets it to True).
draft_creation_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Restrict draft creation to users who hold at least one of these site-wide roles.
When non-empty, takes priority over authenticated_draft_creation.
draft_creation_needs: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Restrict draft creation to users who hold at least one of these permission needs.
When non-empty, takes priority over authenticated_draft_creation.
build_workflow() -> Workflow
Build and return the workflow instance.
Source code in oarepo_config/workflows/simplified/base.py
CommunityWorkflow
dataclass
Bases: BaseWorkflowSettings
Workflow configuration for deposits inside communities.
Source code in oarepo_config/workflows/simplified/community.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
draft_creation_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['submitter', 'curator', 'owner'])
class-attribute
instance-attribute
Restrict draft creation to community members with at least one of these roles.
If not specified (empty list), any member of the community can create a
draft. Used in addition to the site-wide
draft_creation_roles /
draft_creation_needs restrictions.
read_restricted_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator', 'owner'])
class-attribute
instance-attribute
Community roles that may read restricted (published) records without requesting access.
If empty, only the record owner can read the content after publishing. By default allowing curators and community owners to access restricted records.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
read_draft_community_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Community roles that may read draft records without requesting access.
If empty, only the record owner can read the content of a draft. Curators can always read draft records when the record is submitted for review.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
record_manage_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator', 'owner'])
class-attribute
instance-attribute
Community roles that may manage (edit, delete, publish) records.
If empty, only the record owner can manage the record. By default allowing curators and community owners to manage all records.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
community_curator_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator'])
class-attribute
instance-attribute
Community roles that allow users to review and curate records.
IndividualWorkflow
dataclass
Bases: BaseWorkflowSettings
Workflow configuration for deposits outside of communities.
Source code in oarepo_config/workflows/simplified/individual.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
code: str = 'individual'
class-attribute
instance-attribute
Unique code identifier for this workflow.
label: LazyString = _('Individual Submission Workflow')
class-attribute
instance-attribute
Human-readable label for this workflow.
authenticated_draft_creation: bool = True
class-attribute
instance-attribute
Allow authenticated users to create drafts in this workflow.
Overrides the base-class default of False; any authenticated user can
create a draft unless more-specific role or need restrictions are configured
via draft_creation_roles or
draft_creation_needs.
publish_without_review: bool = False
class-attribute
instance-attribute
Allow draft owners to publish without submitting a review request.
When enabled, draft owners can publish directly, subject to
publish_without_review_states.
publish_without_review_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Roles that allow a draft owner to publish without a review request.
Users must still be owners of the draft record. If the list is non-empty,
publish_without_review is ignored.
publish_without_review_needs: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Permission needs that allow a draft owner to publish without a review request.
Users must still be owners of the draft record. If the list is non-empty,
publish_without_review is ignored.
publish_without_review_states: list[str] = dataclasses.field(default_factory=lambda: ['draft'])
class-attribute
instance-attribute
Record workflow states in which publication without review is allowed.
review_required: bool = False
class-attribute
instance-attribute
Require a review request before publication.
If publish_without_review is False and review_required
is False, records can only be published through a community workflow.
reviewer_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Roles that allow users to review and curate records.
Users with these roles are also granted read access to draft records.
reviewer_needs: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Permission needs that allow users to review and curate records.
Users with these needs are also granted read access to draft records.
self_review_enabled: bool = False
class-attribute
instance-attribute
Allow the record owner to approve their own review request.
Normally, submitting a record for review prevents the owner from approving it
themselves. When set to True, the review request is still created on
submission, but the owner is permitted to accept it.
This is primarily useful when invenio-checks is active: checks are tied
to an open request, so the request must exist even when no external reviewer
is needed. With this option the owner can see and act on the check results
without waiting for a curator.
Has no effect when publish_without_review is True, because in
that case user can bypass the review request and publish the record directly.
record_owners_with_correct_roles(record_owner_generator: RecordOwners) -> list[Generator]
Return the record owner generator with the correct roles/needs.
Source code in oarepo_config/workflows/simplified/individual.py
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 | |
configure_workflows(*workflow_definitions: BaseWorkflowSettings, default_individual_workflow: str = 'individual', default_community_workflow: str = 'community', context: dict | None = None) -> list[Workflow]
Set up workflows based on the provided workflow definitions.
This function is intended to be called from within invenio.cfg and will create a "WORKFLOWS" entry in the invenio.cfg context (in the caller's globals).
Example
# invenio.cfg
from oarepo_app.config import (
configure_workflows,
IndividualWorkflow,
CommunityWorkflow,
)
configure_workflows(
IndividualWorkflow(
authenticated_draft_creation=False,
review_required=True,
publish_without_review=False,
),
CommunityWorkflow(),
)
# no need to assign the result to WORKFLOWS, that is done automatically
If the workflow definitions are empty, a permissive IndividualWorkflow will be created (authenticated draft creation, publish without review allowed).
If there is no IndividualWorkflow definition in the workflow definitions (but there are other workflow types), a restricted IndividualWorkflow (no deposition allowed) will be created with default settings.
The default_individual_workflow parameter should be the code of the workflow to use as the default one for individual deposits, where no community is involved and the workflow code is not provided by the caller.
If the context is provided, the "WORKFLOWS" entry will be added to it instead of the caller's globals.
See https://nrp-cz.github.io/docs/customize/workflows for more information on how to customize the workflows.
Source code in oarepo_config/workflows/simplified/__init__.py
21 22 23 24 25 26 27 28 29 30 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 | |