Update the OCR app to apply auto OCR queueing to new document version not only to the initial document upload
This commit is contained in:
@@ -10,7 +10,7 @@ from django.dispatch import receiver
|
|||||||
|
|
||||||
from navigation.api import register_links, register_top_menu, register_multi_item_links
|
from navigation.api import register_links, register_top_menu, register_multi_item_links
|
||||||
from permissions.models import Permission, PermissionNamespace
|
from permissions.models import Permission, PermissionNamespace
|
||||||
from documents.models import Document
|
from documents.models import Document, DocumentVersion
|
||||||
from main.api import register_maintenance_links
|
from main.api import register_maintenance_links
|
||||||
from project_tools.api import register_tool
|
from project_tools.api import register_tool
|
||||||
from acls.api import class_permissions
|
from acls.api import class_permissions
|
||||||
@@ -70,24 +70,25 @@ def create_default_queue():
|
|||||||
default_queue.label = ugettext(u'Default')
|
default_queue.label = ugettext(u'Default')
|
||||||
default_queue.save()
|
default_queue.save()
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, dispatch_uid='document_post_save', sender=DocumentVersion)
|
||||||
def document_post_save(sender, instance, **kwargs):
|
def document_post_save(sender, instance, **kwargs):
|
||||||
|
logger.debug('received post save signal')
|
||||||
|
logger.debug('instance: %s' % instance)
|
||||||
if kwargs.get('created', False):
|
if kwargs.get('created', False):
|
||||||
if AUTOMATIC_OCR:
|
if AUTOMATIC_OCR:
|
||||||
DocumentQueue.objects.queue_document(instance)
|
DocumentQueue.objects.queue_document(instance.document)
|
||||||
|
|
||||||
post_save.connect(document_post_save, sender=Document)
|
|
||||||
|
|
||||||
|
|
||||||
# Disabled because it appears Django execute signals using the same
|
# Disabled because it appears Django execute signals using the same
|
||||||
# process effectively blocking the view until the OCR process completes
|
# process of the signal emiter effectively blocking the view until
|
||||||
# which could take several minutes :/
|
# the OCR process completes which could take several minutes :/
|
||||||
#@receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
|
#@receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
|
||||||
#def call_queue(sender, **kwargs):
|
#def call_queue(sender, **kwargs):
|
||||||
# if kwargs.get('created', False):
|
# if kwargs.get('created', False):
|
||||||
# logger.debug('got call_queue signal: %s' % kwargs)
|
# logger.debug('got call_queue signal: %s' % kwargs)
|
||||||
# task_process_document_queues()
|
# task_process_document_queues()
|
||||||
|
|
||||||
|
|
||||||
create_default_queue()
|
create_default_queue()
|
||||||
|
|
||||||
register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)
|
register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user