def do_transition(self, cleaned_data): comment = cleaned_data.get('comment') attachments = cleaned_data.get('attachments') user = self.request.user instance = self.process_instance transition = self.get_transition_before_execute(cleaned_data) TransitionExecutor(user, instance, self.task, transition, comment, attachments).execute()
def submit_process(self, user=None): from lbworkflow.core.transition import TransitionExecutor instance = self.pinstance if instance.cur_node.is_submitted(): return user = user or self.created_by task = instance.create_task(user) transition = instance.get_transitions()[0] TransitionExecutor(user, instance, task, transition).execute()
def form_valid(self, form): user = self.request.user cleaned_data = form.cleaned_data for task in self.task_list: if task.user != user: # TODO message for ignore continue instance = task.instance transition = self.get_transition(task.instance) comment = cleaned_data.get('comment') attachments = cleaned_data.get('attachments') TransitionExecutor(user, instance, task, transition, comment, attachments).execute() self.add_processed_message(instance) return HttpResponseRedirect(self.get_success_url())
def submit_process(self, user=None): """ Submit this process. :param user: Which user submit the process. The user is self.created_by if user is None. """ from lbworkflow.core.transition import TransitionExecutor instance = self.pinstance if instance.cur_node.is_submitted(): return user = user or self.created_by task = instance.create_task(user) transition = instance.get_transitions()[0] TransitionExecutor(user, instance, task, transition).execute()
def test_submit(self): leave = self.leave instance = self.leave.pinstance leave.submit_process() # A1 will auto agree self.assertEqual(leave.pinstance.cur_node.name, 'A2') self.assertEqual(leave.pinstance.get_operators_display(), 'tom') # A3 not auto agree task = instance.get_todo_task() transition = instance.get_agree_transition() TransitionExecutor(self.users['tom'], instance, task, transition).execute() self.assertEqual(leave.pinstance.cur_node.name, 'A3')
def form_valid(self, form): user = self.request.user cleaned_data = form.cleaned_data for task in self.task_list: if task.user != user: # TODO message for ignore continue instance = task.instance transition = self.get_transition(task.instance) comment = cleaned_data.get("comment") attachments = cleaned_data.get("attachments") TransitionExecutor( user, instance, task, transition, comment, attachments ).execute() self.add_processed_message(instance) return super().form_valid(form)
def form_valid(self, form): user = self.request.user cleaned_data = form.cleaned_data for task in self.task_list: if task.user != user: # TODO message for ignore continue instance = task.instance # 获取lbworkflow_processinstance的summary字段内容 # print(instance.content_object) # 定期策划01 # print(task.instance) # print(222222222222222222) # 52 transition = self.get_transition(task.instance) comment = cleaned_data.get('comment') attachments = cleaned_data.get('attachments') # print('11',transition) # 11 Regularworkplan - Agree # print(transition.output_node) # 二级审批 TransitionExecutor( user, instance, task, transition, comment, attachments ).execute() # res_a = ProcessInstance.objects.filter(cur_node=task.node_id) res_e = Event.objects.filter(task=task.id) # res.instance_id res_task = Task.objects.filter(id=task.id) res_pi = ProcessInstance.objects.filter(id=res_task[0].instance.id) # print(res_e[0].instance) # print(task.user) for res in res_e: # print(res_e[0].instance,res_e[0].user,res_e[0].old_node,res_e[0].task,res_e[0].comment) # print("611111111111") # print(comment) # res = TaskHistory.objects.all() # print(res) # print(111111111111111111111111) TaskHistory.objects.create(node_name=task.node,approve_name=user,created_name=res_pi[0].id,approve_type=res.act_type,content=res.comment,process_id=int(res.instance_id),created_time=task.created_on) self.add_processed_message(instance) return HttpResponseRedirect(self.get_success_url())