mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 20:46:53 +00:00
Move run_zone_ocr to the new bulk operations pathway
This commit is contained in:
13 files changed
+193
-47
No files matched your search
@@ -13,8 +13,10 @@ from rest_framework.exceptions import PermissionDenied
|
||||
from documents import bulk_edit
|
||||
from documents.models import CustomFieldInstance
|
||||
from documents.models import Document
|
||||
from documents.models import OcrTemplate
|
||||
from documents.models import PaperlessTask
|
||||
from documents.permissions import has_document_operation_permissions
|
||||
from documents.permissions import has_perms_owner_aware
|
||||
from documents.tasks import bulk_update_documents
|
||||
|
||||
MODIFIED_FIELDS = {
|
||||
@@ -34,6 +36,7 @@ QUEUED_OPERATIONS = frozenset(
|
||||
"delete",
|
||||
"reprocess",
|
||||
"run_workflow",
|
||||
"run_zone_ocr",
|
||||
"rotate",
|
||||
"merge",
|
||||
"merge_as_versions",
|
||||
@@ -113,6 +116,11 @@ def execute_bulk_operation(
|
||||
if operation == "run_workflow" and not user.has_perm("documents.view_workflow"):
|
||||
raise PermissionDenied("Insufficient permissions to run this workflow")
|
||||
|
||||
if operation == "run_zone_ocr" and parameters.get("template") is not None:
|
||||
template = OcrTemplate.objects.get(pk=parameters["template"])
|
||||
if not has_perms_owner_aware(user, "view_ocrtemplate", template):
|
||||
raise PermissionDenied("Insufficient permissions to run this OCR template")
|
||||
|
||||
actor_context = set_actor(user) if settings.AUDIT_LOG_ENABLED else nullcontext()
|
||||
|
||||
if operation not in MODIFIED_FIELDS:
|
||||
|
||||
Reference in new issue
Block a user