Exemplo n.º 1
0
 def schedule(self):
     if self.enabled:
         register_interval_job(self.internal_name(),
                               title=self.fullname(),
                               func=self.execute,
                               kwargs={'source_id': self.pk},
                               seconds=self.interval)
Exemplo n.º 2
0
 def schedule(self):
     if self.enabled:
         register_interval_job(self.internal_name(),
             title=self.fullname(), func=self.execute,
             kwargs={'source_id': self.pk}, seconds=self.interval
         )
Exemplo n.º 3
0
        # doing syncdb and creating the database tables
    else:
        transaction.commit()


def document_post_save(sender, instance, **kwargs):
    if kwargs.get('created', False):
        if AUTOMATIC_OCR:
            DocumentQueue.objects.queue_document(instance)


post_save.connect(document_post_save, sender=Document)

# Disabled because it appears Django execute signals using the same
# process effectively blocking the view until the OCR process completes
# which could take several minutes :/
#@receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
#def call_queue(sender, **kwargs):
#    if kwargs.get('created', False):
#        logger.debug('got call_queue signal: %s' % kwargs)
#        task_process_document_queues()

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_tool(ocr_tool_link)
Exemplo n.º 4
0
            except AlreadyQueued:
                pass


@receiver(post_syncdb, dispatch_uid='create_default_queue', sender=ocr_models)
def create_default_queue_signal_handler(sender, **kwargs):
    default_queue, created = DocumentQueue.objects.get_or_create(name='default')


def reset_queue_documents():
    try:
        default_queue = DocumentQueue.objects.get(name='default')
    except (DatabaseError, DocumentQueue.DoesNotExist):
        pass
    else:
        default_queue.queuedocument_set.filter(state=QUEUEDOCUMENT_STATE_PROCESSING).update(state=QUEUEDOCUMENT_STATE_PENDING)


register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)

register_tool(ocr_tool_link)

class_permissions(Document, [
    PERMISSION_OCR_DOCUMENT,
])

reset_queue_documents()

namespace = StatisticNamespace(name='ocr', label=_(u'OCR'))
namespace.add_statistic(OCRStatistics(name='ocr_stats', label=_(u'OCR queue statistics')))
Exemplo n.º 5
0
from .tasks import task_check_expired_check_outs
from .events import (HISTORY_DOCUMENT_CHECKED_OUT, HISTORY_DOCUMENT_CHECKED_IN,
    HISTORY_DOCUMENT_AUTO_CHECKED_IN, HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)


def initialize_document_checkout_extra_methods():
    Document.add_to_class('is_checked_out', lambda document: DocumentCheckout.objects.is_document_checked_out(document))
    Document.add_to_class('check_in', lambda document, user=None: DocumentCheckout.objects.check_in_document(document, user))
    Document.add_to_class('checkout_info', lambda document: DocumentCheckout.objects.document_checkout_info(document))
    Document.add_to_class('checkout_state', lambda document: DocumentCheckout.objects.document_checkout_state(document))
    Document.add_to_class('is_new_versions_allowed', lambda document, user=None: DocumentCheckout.objects.is_document_new_versions_allowed(document, user))

register_top_menu(name='checkouts', link=checkout_list)
register_links(Document, [checkout_info], menu_name='form_header')
register_links(['checkout_info', 'checkout_document', 'checkin_document'], [checkout_document, checkin_document], menu_name="sidebar")

class_permissions(Document, [
    PERMISSION_DOCUMENT_CHECKOUT,
    PERMISSION_DOCUMENT_CHECKIN,
    PERMISSION_DOCUMENT_CHECKIN_OVERRIDE,
    PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE
])

CHECK_EXPIRED_CHECK_OUTS_INTERVAL=60  # Lowest check out expiration allowed
register_interval_job('task_check_expired_check_outs', _(u'Check expired check out documents and checks them in.'), task_check_expired_check_outs, seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL)
initialize_document_checkout_extra_methods()
register_history_type(HISTORY_DOCUMENT_CHECKED_OUT)
register_history_type(HISTORY_DOCUMENT_CHECKED_IN)
register_history_type(HISTORY_DOCUMENT_AUTO_CHECKED_IN)
register_history_type(HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)
Exemplo n.º 6
0
                DocumentQueue.objects.queue_document(instance.document)
            except AlreadyQueued:
                pass


# Disabled because it appears Django execute signals using the same
# process of the signal emiter effectively blocking the view until
# the OCR process completes which could take several minutes :/
# @receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
# def call_queue(sender, **kwargs):
#    if kwargs.get('created', False):
#        logger.debug('got call_queue signal: %s' % kwargs)
#        task_process_document_queues()


@receiver(post_syncdb, dispatch_uid="create_default_queue", sender=ocr_models)
def create_default_queue_signal_handler(sender, **kwargs):
    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_tool(ocr_tool_link)

class_permissions(Document, [PERMISSION_OCR_DOCUMENT])
Exemplo n.º 7
0
        'checkout_state', lambda document: DocumentCheckout.objects.
        document_checkout_state(document))
    Document.add_to_class('is_new_versions_allowed',
                          lambda document, user=None: DocumentCheckout.objects.
                          is_document_new_versions_allowed(document, user))


register_top_menu(name='checkouts', link=checkout_list)
register_links(Document, [checkout_info], menu_name='form_header')
register_links(['checkout_info', 'checkout_document', 'checkin_document'],
               [checkout_document, checkin_document],
               menu_name="sidebar")

class_permissions(Document, [
    PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN,
    PERMISSION_DOCUMENT_CHECKIN_OVERRIDE,
    PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE
])

CHECK_EXPIRED_CHECK_OUTS_INTERVAL = 60  # Lowest check out expiration allowed
register_interval_job(
    'task_check_expired_check_outs',
    _(u'Check expired check out documents and checks them in.'),
    task_check_expired_check_outs,
    seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL)
initialize_document_checkout_extra_methods()
register_history_type(HISTORY_DOCUMENT_CHECKED_OUT)
register_history_type(HISTORY_DOCUMENT_CHECKED_IN)
register_history_type(HISTORY_DOCUMENT_AUTO_CHECKED_IN)
register_history_type(HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)