oarepo_config.workflows.simplified
oarepo_config.workflows.simplified
OARepo application workflow configuration package.
Modules:
| Name | Description |
|---|---|
base |
Base workflow settings and helpers for OARepo workflow configuration. |
community |
Community workflow configuration for OARepo. |
individual |
Individual (non-community) workflow configuration for OARepo. |
workflow_permissions |
Definition of workflow permissions. |
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
add_if_in_state(states: list[str], generators: tuple[Generator, ...] | list[Generator]) -> list[Generator]
Wrap generators in an IfInState constraint when states are provided.
If states is non-empty, returns a single-element list containing an
IfInState generator that
activates generators only when the record is in one of the listed states.
If states is empty the generators are returned unchanged as a plain list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
list[str]
|
Workflow state names that gate the generators. Pass an empty list to apply the generators unconditionally. |
required |
generators
|
tuple[Generator, ...] | list[Generator]
|
Permission generators to conditionally wrap. |
required |
Returns:
| Type | Description |
|---|---|
list[Generator]
|
A list of generators, optionally wrapped in an |
list[Generator]
|
constraint. |
Source code in oarepo_config/workflows/simplified/base.py
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 | |