Inbox

In a multi user workflow it can become handy to assign and reassign tasks and to have some kind of inbox to keep track of incomplete tasks.

Automatic assignment

To implement a default assignee you need to override implement your own create_task() method.

from joeflow import tasks


class UpdateWithPrevUserView(tasks.UpdateView):

    def create_task(self, workflow, prev_task):
        """Assign a new task to the user who completed the previous task."""
        new_task = workflow.task_set.create(
            workflow=workflow,
            name=self.name,
            type=self.type,
        )
        if prev_task.completed_by_user:
            # If the previous tasks was a machine task, no user is set.
            new_task.assignees.add(prev_task.completed_by_user)
        return new_task

In this implementation the new task is assigned to the user who completed the previous task. The current workflow and the previous task are always given create_task() method. Note, that a request is not available, since this method might not be called within a view but in a machine task. The parent task relation must not be created as a part of the create_task() method.

API

TaskViewMixin.create_task(workflow, prev_task)[source]

Return a new database instance of this task.

The factory method should be overridden, to create custom database instances based on the task node’s class, the workflow or the previous task.

Note

This is not a view method, a request via self.request is not available.

Parameters:
Returns:

New task instance.

Return type:

joeflow.models.Task