1

To create a process validation, I'm implementing a workflow using the "Django-Viewflow" library(http://viewflow.io/).

All works fine when i assign each task to a specific validator(user) with a fixed number of validation levels.

My problem is:

how to use this library when the number of validator change dinamically(n validation levels)?

1- choose the validators (1,2,3 or n validators).

2- use a for loop in "flows.py" to execute the n validation tasks.

How can i include the for loop in the file "flows.py"?

My flows.py: (with one validation level)

from viewflow import flow, lock
from viewflow.base import this, Flow
from viewflow.contrib import celery

from viewflow.views import  ProcessView, StartProcessView
from viewflow.lock import select_for_update_lock
from django.contrib.auth import get_user_model

from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from . import models, tasks, views

class CongeFlow(Flow):  
    process_cls = models.CongeProcess
    lock_impl = select_for_update_lock       

    start = flow.Start(views.startProcess) \
        .Next(this.assign) \

    assign = flow.View(views.approve_conge) \
        .Assign(lambda p: get_user_model().objects.get(id=p.validator1)) \
        .Next(this.check_refuse)

    check_refuse = flow.If(cond=lambda p: p.refuser) \
        .OnTrue(this.end) \
        .OnFalse(this.check_approve)   

    check_approve = flow.If(cond=lambda p: p.valider) \
        .OnTrue(this.end) \
        .OnFalse(this.assign)

    end = flow.End()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Sam
  • 523
  • 2
  • 5
  • 14

1 Answers1

0

In case if you need sequential validation by one validators, then another, you can point flow.If back to validation step if number of validations is not enougth.

If you would like to have validators works in parallel, you can see dynamic split example

https://github.com/viewflow/viewflow/tree/master/examples/customnode

kmmbvnr
  • 5,863
  • 4
  • 35
  • 44