Fix: make bulk zone OCR survive a missing template or failing document

Inline extract_zones into run_zone_ocr, load documents and the template once, and process each root once. A failing document is logged and the task fails after the rest finish.
This commit is contained in:
stumpylog committed 2026-11-20 09:09:28 -08:00
1 parent a08918eb9c
commit ccbff94208
6 files changed
+346 -328

No files matched your search

+6 -2
View File
@@ -118,8 +118,12 @@ def execute_bulk_operation(
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):
template = OcrTemplate.objects.filter(pk=parameters["template"]).first()
if template is not None and 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()