from permissions.models import Permission
from permissions.models import Role
- """Mixin class to make objects workflow aware.
- def get_workflow(self):
- """Returns the current workflow of the object.
- return workflows.utils.get_workflow(self)
- def remove_workflow(self):
- """Removes the workflow from the object. After this function has been
- called the object has no *own* workflow anymore (it might have one via
- return workflows.utils.remove_workflow_from_object(self)
- def set_workflow(self, workflow):
- """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.
- The workflow which should be set to the object. Can be a Workflow
- instance or a string with the workflow name.
- The object which gets the passed workflow.
- return workflows.utils.set_workflow_for_object(workflow)
- """Returns the current workflow state of the object.
- return workflows.utils.get_state(self)
- def set_state(self, state):
- """Sets the workflow state of the object.
- return workflows.utils.set_state(self, state)
- def set_initial_state(self):
- """Sets the initial state of the current workflow to the object.
- return self.set_state(self.get_workflow().initial_state)
- def get_allowed_transitions(self, user):
- """Returns allowed transitions for the current state.
- return workflows.utils.get_allowed_transitions(self, user)
- def do_transition(self, transition, user):
- """Processes the passed transition (if allowed).
- return workflows.utils.do_transition(self, transition, user)
"""A workflow consists of a sequence of connected (through transitions)
states. It can be assigned to a model and / or model instances. If a
"""Returns all objects which have this workflow assigned. Globally
(via the object's content type) or locally (via the object itself).
# Get all objects whose content type has this workflow
The object which gets the workflow.
ctype = ContentType.objects.get_for_model(obj)
wor = WorkflowObjectRelation.objects.get(content_type=ctype, content_id=obj.id)
"""Stores an workflow of an object.
- Provides a way to give any object a workflow without changing the object's
+ Provides a way to give any object a workflow without changing the object's