Add tool to launch all workflows. Already running workflows are unaffected.

Closes GitLab issue #355.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-02-23 03:02:39 -04:00
parent 77996157f2
commit 5e886d9eaf
8 changed files with 142 additions and 8 deletions

View File

@@ -0,0 +1,24 @@
from __future__ import unicode_literals
import logging
from django.apps import apps
from mayan.celery import app
logger = logging.getLogger(__name__)
@app.task(ignore_result=True)
def task_launch_all_workflows():
Document = apps.get_model(app_label='documents', model_name='Document')
Workflow = apps.get_model(
app_label='document_states', model_name='Workflow'
)
logger.info('Start launching workflows')
for document in Document.objects.all():
print 'document :', document
Workflow.objects.launch_for(document=document)
logger.info('Finished launching workflows')