Add "ocr_content" accessor to the DocumentVersion class to return
the ocr content. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@ from .links import (
|
||||
)
|
||||
from .permissions import permission_ocr_document, permission_ocr_content_view
|
||||
from .queues import * # NOQA
|
||||
from .utils import get_document_ocr_content
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -84,6 +85,9 @@ class OCRApp(MayanAppConfig):
|
||||
DocumentVersionOCRError = self.get_model('DocumentVersionOCRError')
|
||||
|
||||
Document.add_to_class('submit_for_ocr', document_ocr_submit)
|
||||
DocumentVersion.add_to_class(
|
||||
'ocr_content', get_document_ocr_content
|
||||
)
|
||||
DocumentVersion.add_to_class(
|
||||
'submit_for_ocr', document_version_ocr_submit
|
||||
)
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.html import conditional_escape
|
||||
|
||||
from .models import DocumentPageOCRContent
|
||||
|
||||
|
||||
def get_document_ocr_content(document):
|
||||
DocumentPageOCRContent = apps.get_model(
|
||||
app_label='ocr', model_name='DocumentPageOCRContent'
|
||||
)
|
||||
|
||||
for page in document.pages.all():
|
||||
try:
|
||||
page_content = page.ocr_content.content
|
||||
|
||||
Reference in New Issue
Block a user