Package: viewflow-rest
viewflow-restprovide restful viewflowmany of code in the project looks like django-viewflow. I want to keep the interface as same as thedjango viewflow.Thanks you for all thecontributors of viewflow.The project is underONLY USE NO PRIVATE CHANGE LICENSE, any one who change the source code (even if you just use it in intranet of just at home) should publish his code to publicExamplethe flow graph can been cloned the changed fromthis link.exam flowthis graph like above picture can be written like the below code:# example_project/exam/flows.py
class ExamFlow(flows.Flow):

    process_class = models.ExamProcess
    task_class = models.ExamTask

    register = nodes.Start(
        viewclass=rest_extensions.AutoCreateAPIView,
        serializer_class=serializers.RegisterExamSerializer,
    ).Next(
        this.select_term
    )

    select_term = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        fields=["term"],
    ).Next(this.take_exam)

    take_exam = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        fields=["grade"],
    ).Next(this.check_grade)

    check_grade = nodes.If(
        cond=lambda activation: activation.process.passed
    ).Then(this.end).Else(this.select_term)
    end = nodes.End()quite simple and intuitive, right?hire flowsource codeclass HireFlow(flows.Flow):

    process_class = models.HireProcess
    task_class = models.HireTask

    start = nodes.Start(
        viewclass=rest_extensions.AutoCreateAPIView,
        serializer_class=serializers.AddCandidateSerializer,
    ).Permission(
        group=Group.objects.get_or_create(name="hr")[0]
    ).Next(
        this.split_to_3rd_and_direct_leader
    )

    split_to_3rd_and_direct_leader = nodes.Split(
    ).Always(
        this.approve
    ).Always(
        this.background_research
    )

    background_research = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        fields=["background_ok"],
    ).Next(
        this.check_background
    )

    check_background = nodes.If(
        cond=lambda activation: activation.process.background_ok
    ).Then(
        this.join_on_both_approve
    ).Else(
        this.end
            )

    join_on_both_approve = nodes.Join().Next(
        this.notify
    )

    notify = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        fields=["notified"],
    ).Next(
        this.end
    )

    approve = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        serializer_class = serializers.ApproveSerializer,
        # fields=["approved"],
    ).Permission(
        group=Group.objects.get_or_create(name="leader")[0]
    ).Next(
        this.check_if_approve
    )

    check_if_approve = nodes.If(
        cond=lambda activation: activation.process.approved
    ).Then(
        this.set_salary
    ).Else(
        this.notify
    )

    set_salary = nodes.View(
        viewclass=rest_extensions.AutoUpdateAPIView,
        fields=["salary"],
    ).Permission(
        group=Group.objects.get_or_create(name="hr")[0]
    ).Next(
        this.join_on_both_approve
    )

    end = nodes.End()中文版EnglishQuick Startuse theexample_projectas a examplegit clone git@github.com:ramwin/viewflow-rest.git
cd vieflow-rest/example_project/
sudo pip3 install -r ./requirements.txt
python3 manage.py migrate
python3 manage.py runserver
# visit http://localhost:8000/exam/ or http://localhost:8000/hire/ to get the apiChange Log3.0.0 warning: break change abount the signalsThepost_finishandpost_startsignal not use theflow_taskinstead of aflow_processas a sender. You should change your code fromtask_started.connect(function, ProcessClass)totask_started.connect(function, ProcessClass.one_of_its_flow_task)FAQHow To Update the Task manuallytask = models.FlowTaskModel.objects.get(id=4)
task.auto_finish(operator=User) or operator=NoneThe develop vedio can been seen herecreate projectcreate FlowCreate Start & End NodeCreate ViewActivationCreate If NodeCreate Split NodeCreate Join NodeCreate Permission0.3.0one task for everyflow_taskaddserializer_classparameters forrest_extentions.viewsaddoperatorfor every tasktermworkflowA flow contains many flow_tasks/nodes# here exam_flow is a workflow
# it contains three flow_tasks, which were register, do, end
class ExamFlow(flows.Flow):
    register = nodes.Start(
        ...
    ).Next(this.do)
    do.nodes.View(
        ...
    ).Next(this.end)
    end = nodes.End()
exam_flow = ExamFlow()every flow_task is a instance of Node
every flow_task have aactivation_classeveryaction_classinstance willactivate_nextbyself.flow_task._next  // the next node instance
self.flow_task._next.activate //flow_taskEdgesrc: source Node instancedst: target Node instanceactivationsAttributeflow_classflow_task: Node Instance defined in theflows.pytask: Current TaskNodesFunction_incoming: Edge Instance list_outgoing: Edge Instance listmodelsViewsFlowrest_extensions