Move document page content code to the OCR app. Prep work for issue #186.
This commit is contained in:
@@ -87,34 +87,6 @@ class DocumentPropertiesForm(DetailForm):
|
||||
model = Document
|
||||
|
||||
|
||||
class DocumentContentForm(forms.Form):
|
||||
"""
|
||||
Form that concatenates all of a document pages' text content into a
|
||||
single textarea widget
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.document = kwargs.pop('document', None)
|
||||
super(DocumentContentForm, self).__init__(*args, **kwargs)
|
||||
content = []
|
||||
self.fields['contents'].initial = ''
|
||||
try:
|
||||
document_pages = self.document.pages.all()
|
||||
except AttributeError:
|
||||
document_pages = []
|
||||
|
||||
for page in document_pages:
|
||||
if page.content:
|
||||
content.append(conditional_escape(force_unicode(page.content)))
|
||||
content.append('\n\n\n<hr/><div class="document-page-content-divider">- %s -</div><hr/>\n\n\n' % (ugettext('Page %(page_number)d') % {'page_number': page.page_number}))
|
||||
|
||||
self.fields['contents'].initial = mark_safe(''.join(content))
|
||||
|
||||
contents = forms.CharField(
|
||||
label=_('Contents'),
|
||||
widget=TextAreaDiv(attrs={'class': 'text_area_div full-height', 'data-height-difference': 360})
|
||||
)
|
||||
|
||||
|
||||
class DocumentTypeSelectForm(forms.Form):
|
||||
"""
|
||||
Form to select the document type of a document to be created, used
|
||||
|
||||
Reference in New Issue
Block a user