Cleanup OCR app code and link registration
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -157,8 +157,9 @@ class OCRApp(MayanAppConfig):
|
||||
link_document_ocr_download, link_document_submit
|
||||
),
|
||||
sources=(
|
||||
'ocr:document_submit', 'ocr:document_ocr_content',
|
||||
'ocr:document_ocr_download', 'ocr:document_ocr_error_list'
|
||||
'ocr:document_ocr_content_delete',
|
||||
'ocr:document_ocr_content', 'ocr:document_ocr_download',
|
||||
'ocr:document_ocr_error_list', 'ocr:document_submit',
|
||||
)
|
||||
)
|
||||
menu_secondary.bind_links(
|
||||
|
||||
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DocumentPageOCRContentManager(models.Manager):
|
||||
def delete_ocr_content_for(self, document, user=None):
|
||||
def delete_content_for(self, document, user=None):
|
||||
with transaction.atomic():
|
||||
for document_page in document.pages.all():
|
||||
self.filter(document_page=document_page).delete()
|
||||
|
||||
@@ -56,12 +56,6 @@ class OCRViewTestMixin(object):
|
||||
}
|
||||
)
|
||||
|
||||
def _request_document_type_ocr_settings_view(self):
|
||||
return self.get(
|
||||
viewname='ocr:document_type_ocr_settings',
|
||||
kwargs={'pk': self.test_document.document_type.pk}
|
||||
)
|
||||
|
||||
|
||||
class OCRViewsTestCase(OCRViewTestMixin, GenericDocumentViewTestCase):
|
||||
# PyOCR's leak descriptor in get_available_languages and image_to_string
|
||||
@@ -194,13 +188,27 @@ class OCRViewsTestCase(OCRViewTestMixin, GenericDocumentViewTestCase):
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class DocumentTypeOCRViewTestMixin(object):
|
||||
def _request_document_type_ocr_settings_view(self):
|
||||
return self.get(
|
||||
viewname='ocr:document_type_ocr_settings',
|
||||
kwargs={'pk': self.test_document_type.pk}
|
||||
)
|
||||
|
||||
|
||||
class DocumentTypeOCRViewsTestCase(
|
||||
DocumentTypeOCRViewTestMixin, GenericDocumentViewTestCase
|
||||
):
|
||||
auto_upload_document = False
|
||||
|
||||
def test_document_type_ocr_settings_view_no_permission(self):
|
||||
response = self._request_document_type_ocr_settings_view()
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_type_ocr_settings_view_with_access(self):
|
||||
self.grant_access(
|
||||
obj=self.test_document.document_type,
|
||||
obj=self.test_document_type,
|
||||
permission=permission_document_type_ocr_setup
|
||||
)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class DocumentOCRContentDeleteView(MultipleObjectConfirmActionView):
|
||||
return result
|
||||
|
||||
def object_action(self, form, instance):
|
||||
DocumentPageOCRContent.objects.delete_ocr_content_for(
|
||||
DocumentPageOCRContent.objects.delete_content_for(
|
||||
document=instance, user=self.request.user
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user