Update the document type auto ocr value to be defined at runtime by turning it into a setting.
This commit is contained in:
@@ -5,6 +5,7 @@ import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from .models import DocumentTypeSettings
|
||||
from .settings import setting_auto_ocr
|
||||
|
||||
|
||||
def post_version_upload_ocr(sender, instance, **kwargs):
|
||||
@@ -16,4 +17,6 @@ def post_version_upload_ocr(sender, instance, **kwargs):
|
||||
|
||||
def initialize_new_ocr_settings(sender, instance, **kwargs):
|
||||
if kwargs['created']:
|
||||
DocumentTypeSettings.objects.create(document_type=instance)
|
||||
DocumentTypeSettings.objects.create(
|
||||
document_type=instance, auto_ocr=setting_auto_ocr.value
|
||||
)
|
||||
|
||||
@@ -21,3 +21,9 @@ setting_ocr_backend = namespace.add_setting(
|
||||
global_name='OCR_BACKEND', default='ocr.backends.tesseract.Tesseract',
|
||||
help_text=_('Full path to the backend to be used to do OCR.')
|
||||
)
|
||||
setting_auto_ocr = namespace.add_setting(
|
||||
global_name='OCR_AUTO_OCR', default=True,
|
||||
help_text=_(
|
||||
'Set new document types to perform OCR automatically by default.'
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user