Initial changes to support the new Django 1.6 project structure
This commit is contained in:
20
mayan/apps/ocr/managers.py
Normal file
20
mayan/apps/ocr/managers.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
|
||||
from .exceptions import AlreadyQueued
|
||||
|
||||
|
||||
class DocumentQueueManager(models.Manager):
|
||||
'''
|
||||
Module manager class to handle adding documents to an OCR document
|
||||
queue
|
||||
'''
|
||||
def queue_document(self, document, queue_name='default'):
|
||||
document_queue = self.model.objects.get(name=queue_name)
|
||||
if document_queue.queuedocument_set.filter(document=document):
|
||||
raise AlreadyQueued
|
||||
|
||||
document_queue.queuedocument_set.create(document=document, delay=True)
|
||||
|
||||
return document_queue
|
||||
Reference in New Issue
Block a user