Django-viewflow query all assigned to user tasks

143 views Asked by At

How to query django-viewflow for all tasks assigned to user?

Probably viewflow.managers.TaskQuerySet inbox() is right place. But how to invoke it?

Alternatively how to query users task from viewflow.models.Process object?

2

There are 2 answers

1
surge_ On

Heve done it like below finaly

class CoopOnboardingProcess(Process):
    user = models.ForeignKey(CustomUser, on_delete=models.RESTRICT, blank=True, null=True)
    text = models.CharField(max_length=150)
    approved = models.BooleanField(default=False)

on_boarding_process = bpmn_models.CoopOnboardingProcess.objects.filter(artifact_content_type = ContentType.objects.get(model='cooperation'),
                                                                       artifact_object_id = cooperation.pk,
                                                                      )
                
for i in on_boarding_process:
   i.active_tasks().inbox(flow_classes=[i.flow_class],
                          user=self.request.user)
0
kmmbvnr On

You could just use

Task.objects.filter(process=..., owner=self.request.user, status=STATUS.ASSIGNED)