简体   繁体   English

自动为用户分配任务(Viewflow,Django)

[英]Assign user to tasks automatically (Viewflow, Django)

I'm using Viewflow /Django and trying to assign tasks created by dynamic nodes. 我正在使用Viewflow / Django,并尝试分配由动态节点创建的任务。

I'm using the same nodes.py in customnode . 我在nodes.py中使用相同的nodes.py

However, I need to automatically assign each new task based on information in the MOCTask model (the assignee). 但是,我需要根据MOCTask model (受让人)中的信息自动分配每个新任务。

But tasks don't allow an Assign with anything other than a specific user object and I don't have access to the MOCTask objects (they are related by foreign key to MOC, which is related by foreign key to MOCProcess , the flow itself). 但是任务不允许除特定用户对象之外的任何对象进行赋值,并且我无权访问MOCTask对象(它们通过与MOC的外键关联,而通过与MOCProcess的外键MOCProcess (流程本身)) 。

My code I was trying (flows.py): 我正在尝试的代码(flows.py):

...
split_on_task_assignment = (
  DynamicSplit(lambda p: MOCTask.objects.filter(MOC=p.MOC).count())
  .IfNone(this.end)
  .Next(this.task_completion)
)

task_completion = (
  flow.View(views.TaskCompletion)
  .Permission('MOC.is_MOC_actor')
  .Assign(this.assign_actors)
  .Next(this.join_on_task_completion)
)
...
def assign_actors(self, activation):
  task = MOCTask.objects.filter(MOC=activation.process.MOC, assigned=False).first()
  task.assigned = True
  task.save()
  return User.objects.filter(email=task.assignee).first()

However, I can't put a this reference in the assign block, so I'm not sure how to proceed. 但是,我无法this引用放在assign块中,因此我不确定如何继续。

Any ideas? 有任何想法吗?

创建后续任务时,可以在DynamicSplitActivation内部分配用户

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): activation = self.flow_task._next.activate( prev_activation=self, token=next(token_source)) activation.activate(..a user..)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM