Moved DocumentQueueManager to a separate manager.py file
This commit is contained in:
13
apps/ocr/manager.py
Normal file
13
apps/ocr/manager.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
|
||||
from ocr.exceptions import AlreadyQueued
|
||||
|
||||
class DocumentQueueManager(models.Manager):
|
||||
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