Package: django-process
Django ProcessIts a reusable app for execute scrits in workflows with dependecies
NEW VERSION 4.6 it allows you to use the complete app from the admin site with the graphics and custom actionsTable of Contentsusagetipsexecution of the processesfrequency of the processrender job/process workflowtask placement in diagramstart job on demandreopen task for execution in cascadeaccess to django builtinsUsage:pip install django-processadd 'process' to installed appsmakemigrations and migrate themcreate a Process and Tasks which belong to the process.
(The Job is an instance executed of the process, JobTask is an instance executed of the Task you must not create manually any of them !)(optional) you can create dependencies of the tasks for they to run sequentially, if you don't create dependencies the tasks will start all at onceexecute python manage.py run_jobsTIPS:execution of the processesjust as simple as>>>pythonmanage.pyrun_jobsfrequency of the processThe process have a crontab-like configuration for set the frequency.
Lets take the attribute minute for example. You can:use * for all minutesspecify a list of minutes 1,3,5,8,25,59specify a range of minutes 1-30combine list and ranges example 1,3,5,8,4-9 will be expanded to: 1,3,4,5,6,7,8,9for the moment it doesnt accept fractions using the / charyou can use any of those above for the five attributes just like a crontab.the start job process runs each minute while the tasks manager its always online.render process or job object as an workflow diagramin your html code you can render a Process as an image workflow{% load process_diagram %} in your html for use the diagram templatetag{% include "process/dj-process.html" %} in your html for include the CSS and JS{{ object|diagram }} to render the object{% load process_diagram %}<!DOCTYPE html><htmllang="en"><head>{% include "process/dj-process.html" %}<metacharset="UTF-8"><title>Title</title></head><body>{{ object|diagram }}</body></html>this will return an output like this:placing a task in an workflow diagramTask objects have two attributes: level & offset you can place a task in a workflow diagram using those attributes
levels are vertical placement while offset are horizontal placementslevel: the value for level starts on 0 you can create as many levels as you want in workflow diagramoffset: its a percentaje 0% will place your task in the middle 25% places to the right while -25% place the task to the leftstarting a Job and its tasks on demandThe job needs a Process parent to be instanced:>>>process=Process.objects.all()[0]>>>job,tasks=Job.create(process)this will create the job for the process and also the tasks if the runner is online it will execute immediate
all the tasks created sequentially if you have defined dependencies for them or all at once if you have notreopen task for execution in cascasdeyou can reopen a task that has been executed already:>>>task=JobTask.objects.all()[0]>>>task.reopen(main=True)this will reopen the job task for execution again and it will set status awaiting for the childs in CASCADEaccess to django builtinsIf you want to use django functions or access models and their methods in a task-scriptyou need first import process.env example:import process.envfrom yourapp.models import CustomModelobjects = CustomModel.objects.all()for obj in objects:print(obj)if you do not import process.env you will get an error trying to access djangothis short tutorial does not covers all the power for the app. I will be adding more examplesif you got doubts or questions don't hesitate send me a mail or create an issue im always onlinemail the author