Example #1
0
    def _gen_new_task(self):
        last_event = self.last_event

        if not last_event:
            return

        next_operators = last_event.next_operators.distinct()

        need_notify_operators = []
        for operator in next_operators:
            new_task = Task(instance=self.instance,
                            node=self.to_node,
                            user=operator)
            new_task.update_authorization(commit=True)

            # notify next operator(not include current operator and instance.created_by)
            if operator not in [self.operator, self.instance.created_by]:
                need_notify_operators.append(operator)

            agent_user = new_task.agent_user
            if agent_user and agent_user not in [
                    self.operator, self.instance.created_by
            ]:
                need_notify_operators.append(agent_user)

        wf_send_msg(need_notify_operators, 'new_task', last_event)
Example #2
0
    def _auto_agree_next_node(self):
        instance = self.instance

        agree_transition = instance.get_agree_transition()
        all_todo_tasks = instance.get_todo_tasks()

        if not agree_transition:
            return

        # if from router, create a task
        if self.to_node.node_type == 'router':
            task = Task(
                instance=self.instance,
                node=self.instance.cur_node,
                user=self.operator,
            )
            all_todo_tasks = [task]

        for task in all_todo_tasks:
            users = [task.user, task.agent_user]
            users = [e for e in users if e]
            for user in set(users):
                if self.instance.cur_node != task.node:  # has processed
                    return
                if instance.is_user_agreed(user):
                    TransitionExecutor(self.operator, instance, task,
                                       agree_transition).execute()
 def get_task(self, request):
     pk = request.GET.get('pk')
     process_instance = get_or_none(ProcessInstance, pk=pk)
     if not process_instance:
         return None
     return Task(instance=process_instance,
                 node=process_instance.cur_node,
                 user=request.user)
 def get_task_list(self, request):
     instance_pk_list = request.POST.getlist('pi')
     instance_list = ProcessInstance.objects.filter(
         cur_node__status='in progress', pk__in=instance_pk_list)
     task_list = []
     for instance in instance_list:
         task = Task(
             instance=instance,
             node=instance.cur_node,
             user=instance.created_by,
         )
         task_list.append(task)
     return task_list