# oarepo\_config.workflows.simplified.base

## `oarepo_config.workflows.simplified.base`

Base workflow settings and helpers for OARepo workflow configuration.

### `BaseWorkflowSettings`

Shared configuration common to all workflow types.

#### `code: str = 'undefined'`

The code of the workflow type.

#### `label: LazyString = _('Undefined policy')`

The label of the workflow type.

#### `base_permission_policy: type[Any] = DefaultRDMWorkflowPermissions`

The base permission policy class for this workflow that will be configured.

#### `base_request_policy: type[WorkflowRequestPolicy] = WorkflowRequestPolicy`

The base requests policy class for this workflow that will be configured.

#### `review_request_states: list[str] = dataclasses.field(default_factory=lambda: ['draft'])`

Record workflow states in which a review request may be submitted.

#### `record_view_permissions: dict[str, list[Generator]] = dataclasses.field(default_factory=dict)`

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`

Publish immediately after reviewer approves the review request.

#### `extra_permissions: type[BasePermissionPolicy] | Callable[[type[BasePermissionPolicy]], type[BasePermissionPolicy]] | None = None`

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`

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`

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)`

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)`

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.

### `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 `IfInState` |
| `list[Generator]` | constraint. |
