- workflows.utils.set_workflow(ctype_or_obj, workflow)¶
Sets the workflow for passed content type or object. See the specific methods for more information.
Parameters:
- workflow
- The workflow which should be set to the object or model.
- ctype_or_obj
- The content type or the object to which the passed workflow should be set. Can be either a ContentType instance or any Django model instance.
- workflows.utils.set_workflow_for_object(obj, workflow)¶
Sets the passed workflow to the passed object.
If the object has already the given workflow nothing happens. Otherwise the object gets the passed workflow and the state is set to the workflow’s initial state.
Parameters:
- workflow
- The workflow which should be set to the object. Can be a Workflow instance or a string with the workflow name.
- obj
- The object which gets the passed workflow.
- workflows.utils.set_workflow_for_model(ctype, workflow)¶
Sets the passed workflow to the passed content type. If the content type has already an assigned workflow the workflow is overwritten.
The objects which had the old workflow must updated explicitely.
Parameters:
- workflow
- The workflow which should be set to passend content type. Must be a Workflow instance.
- ctype
- The content type to which the passed workflow should be assigned. Can be any Django model instance
- workflows.utils.remove_workflow(ctype_or_obj)¶
Removes the workflow from the passed content type or object. After this function has been called the content type or object has no workflow anymore.
If ctype_or_obj is an object the workflow is removed from the object not from the belonging content type.
If ctype_or_obj is an content type the workflow is removed from the content type not from instances of the content type (if they have an own workflow)
- ctype_or_obj
- The content type or the object to which the passed workflow should be set. Can be either a ContentType instance or any LFC Django model instance.
- workflows.utils.remove_workflow_from_object(obj)¶
Removes the workflow from the passed object. After this function has been called the object has no own workflow anymore (it might have one via its content type).
- obj
- The object from which the passed workflow should be set. Must be a Django Model instance.
- workflows.utils.remove_workflow_from_model(ctype)¶
Removes the workflow from passed content type. After this function has been called the content type has no workflow anymore (the instances might have own ones).
- ctype
- The content type from which the passed workflow should be removed. Must be a ContentType instance.
- workflows.utils.get_workflow(obj)¶
Returns the workflow for the passed object. It takes it either from the passed object or - if the object doesn’t have a workflow - from the passed object’s ContentType.
Parameters:
- object
- The object for which the workflow should be returend. Can be any Django model instance.
- workflows.utils.get_workflow_for_object(obj)¶
Returns the workflow for the passed object.
Parameters:
- obj
- The object for which the workflow should be returned. Can be any Django model instance.
- workflows.utils.get_workflow_for_model(ctype)¶
Returns the workflow for the passed model.
Parameters:
- ctype
- The content type for which the workflow should be returned. Must be a Django ContentType instance.
- workflows.utils.get_objects_for_workflow(workflow)¶
Returns all objects which have passed workflow.
Parameters:
- workflow
- The workflow for which the objects are returned. Can be a Workflow instance or a string with the workflow name.
- workflows.utils.get_state(obj)¶
Returns the current workflow state for the passed object.
Parameters:
- obj
- The object for which the workflow state should be returned. Can be any Django model instance.
- workflows.utils.set_state(obj, state)¶
Sets the state for the passed object to the passed state and updates the permissions for the object.
Parameters:
- obj
- The object for which the workflow state should be set. Can be any Django model instance.
- state
- The state which should be set to the passed object.
- workflows.utils.set_initial_state(obj)¶
- Sets the initial state to the passed object.
- workflows.utils.get_allowed_transitions(obj, user)¶
Returns all allowed transitions for passed object and user. Takes the current state of the object into account.
Parameters:
- obj
- The object for which the transitions should be returned.
- user
- The user for which the transitions are allowed.
- workflows.utils.do_transition(obj, transition, user)¶
- Processes the passed transition to the passed object (if allowed).
Mixin class to make objects workflow aware.
Sets the passed workflow to the object. This will set the local workflow for the object.
If the object has already the given workflow nothing happens. Otherwise the object gets the passed workflow and the state is set to the workflow’s initial state.
Parameters:
A workflow consists of a sequence of connected (through transitions) states. It can be assigned to a model and / or model instances. If a model instance has a workflow it takes precendence over the model’s workflow.
Attributes:
Sets the workflow to passed content type or object. See the specific methods for more information.
Parameters:
Sets the workflow to the passed content type. If the content type has already an assigned workflow the workflow is overwritten.
Parameters:
Sets the workflow to the passed object.
If the object has already the given workflow nothing happens. Otherwise the workflow is set to the objectthe state is set to the workflow’s initial state.
Parameters:
A certain state within workflow.
Attributes:
A transition from a source to a destination state. The transition can be used from several source states.
Attributes:
Stores the workflow state of an object.
Provides a way to give any object a workflow state without changing the object’s model.
Attributes:
Stores the permissions for which a workflow is responsible.
Attributes:
Stores granted permission for state and role.
Attributes: