Revert how the OCR and document parsing generators end their iteration. Originally they issue an empty return, then a blank yield was added. This commit reverts the blank yield and restores the original 'return' behavior. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
25 lines
663 B
Python
25 lines
663 B
Python
from __future__ import unicode_literals
|
|
|
|
from django.apps import apps
|
|
from django.utils.encoding import force_text
|
|
from django.utils.html import conditional_escape
|
|
|
|
|
|
def get_document_content(document):
|
|
DocumentPageContent = apps.get_model(
|
|
app_label='document_parsing', model_name='DocumentPageContent'
|
|
)
|
|
|
|
for page in document.pages.all():
|
|
try:
|
|
page_content = page.content.content
|
|
except DocumentPageContent.DoesNotExist:
|
|
return
|
|
else:
|
|
yield conditional_escape(force_text(page_content))
|
|
|
|
|
|
@property
|
|
def document_property_content(self):
|
|
return ' '.join(get_document_content(self))
|