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:
24
mayan/apps/document_states/tasks.py
Normal file
24
mayan/apps/document_states/tasks.py
Normal 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')
|
||||
Reference in New Issue
Block a user