def test_split_token_source_generator(self): prev_token = Token('start/1_2/3_4') source = Token.split_token_source(prev_token, task_pk=5) tokens = list(islice(source, 5)) self.assertEqual(set([token.get_common_split_prefix('start/1_2/3_4', 0) for token in tokens]), set(['start/1_2/3_4/5_']))
def activate_next(self): if self._split_count: token_source = Token.split_token_source(self.task.token, self.task.pk) for _ in range(self._split_count): self.flow_task._next.activate(prev_activation=self, token=next(token_source))
def test_split_token_source_generator(self): prev_token = Token('start/1_2/3_4') source = Token.split_token_source(prev_token, task_pk=5) tokens = list(islice(source, 5)) self.assertEqual( set([Token(token).get_common_split_prefix() for token in tokens]), set(['start/1_2/3_4/5_']))
def activate_next(self): if self._split_count: token_source = Token.split_token_source(self.task.token, self.task.pk) for _ in range(self._split_count): self.flow_task._next.activate(prev_activation=self, token=next(token_source)) elif self.flow_task._ifnone_next_node is not None: self.flow_task._ifnone_next_node.activate(prev_activation=self, token=self.task.token) else: raise FlowRuntimeError("{} activated with zero and no IfNone nodes specified".format(self.flow_task.name))
def activate_next(self): if self._approvers: token_source = Token.split_token_source(self.task.token, self.task.pk) for user in self._approvers: next_task = self.flow_task._next.activate( prev_activation=self, token=next(token_source)) next_task.assign(user) self.update_approve_task(next_task.task) else: raise FlowRuntimeError( "{} activated with zero nodes specified".format( self.flow_task.name))
def activate_next(self): if self._split_count: token_source = Token.split_token_source(self.task.token, self.task.pk) for _ in range(self._split_count): self.flow_task._next.activate(prev_activation=self, token=next(token_source)) elif self.flow_task._ifnone_next_node is not None: self.flow_task._ifnone_next_node.activate(prev_activation=self, token=self.task.token) else: raise FlowRuntimeError( "{} activated with zero and no IfNone nodes specified".format( self.flow_task.name))
def assign_tasks(self): with self.exception_guard(): self._owner_list = self.flow_task.owner_list(self) if self._owner_list: token_source = Token.split_token_source( self.task.token, self.task.pk) for owner in self._owner_list: task = self.flow_class.task_class(process=self.process, flow_task=self.flow_task, token=next(token_source), owner=owner, status=STATUS.ASSIGNED, started=timezone.now()) task.save() task.previous.add(self.task) elif self.flow_task._ifnone_next_node is not None: self.flow_task._ifnone_next_node.activate( prev_activation=self, token=self.task.token) else: raise FlowRuntimeError( "{} activated with zero and no IfNone nodes specified". format(self.flow_task.name))
def activate_next(self): token_source = Token.split_token_source(self.task.token, self.task.pk) for n, next_task in enumerate(self.next_tasks, 1): next_task.activate(prev_activation=self, token=next(token_source))