From 2534d3c16b941f4f6f89d3b96b29d989dec4f1ad Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 20 Oct 2026 16:46:21 -0700 Subject: [PATCH] Absurd comments --- src/documents/models.py | 24 ++++-------------------- src/documents/signals/handlers.py | 4 +--- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/documents/models.py b/src/documents/models.py index 323cbff0c..8d888129b 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -2152,13 +2152,7 @@ class WorkflowRun(SoftDeleteModel): class OcrTemplate(MatchingModel): - """ - Defines a set of OCR extraction zones for documents with a common layout. - - When a consumed document matches the template, each zone is cropped from - the document image and OCR'd separately. The extracted text is written to - the configured custom field or built-in document field. - """ + """Matching rules and extraction zones for documents with a common layout.""" source_width = models.PositiveIntegerField( _("source width"), @@ -2213,11 +2207,7 @@ class OcrTemplate(MatchingModel): class OcrTemplateZone(models.Model): - """ - A rectangular region within a document page to OCR and extract into a custom - field or built-in document field. Coordinates are relative to the source - image dimensions stored on the template. - """ + """A page region and the field its extracted value is written to.""" template = models.ForeignKey( OcrTemplate, @@ -2279,11 +2269,7 @@ class OcrTemplateZone(models.Model): help_text=_("Zone height (px)"), ) - # Per-zone source dimensions for coordinate scaling. - # Stored from the page image the zone was drawn on. - # If null, falls back to the template's source_width/source_height. - # This handles PDFs with mixed page sizes (e.g. landscape + portrait, - # or different paper formats across pages). + # Mixed-size PDFs need each zone's original page dimensions for scaling. zone_source_width = models.PositiveIntegerField( _("zone source width"), null=True, @@ -2362,9 +2348,7 @@ class OcrTemplateZone(models.Model): return f"{self.template.name} -> {self.name}" -# Custom field data types that zone OCR can extract into. DOCUMENTLINK and -# SELECT are excluded (they reference other objects, not free text). Single -# source of truth for the serializer and the engine. +# Document links and select fields require object references, not OCR text. OCR_SUPPORTED_FIELD_TYPES = frozenset( { CustomField.FieldDataType.STRING, diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index ec8322d98..8d81cbf91 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -1409,9 +1409,7 @@ def close_connection_pool_on_worker_init(**kwargs) -> None: def run_zone_ocr_extraction(sender, document, original_file=None, **kwargs): - """ - Run zone-based OCR extraction with the OCR templates that match the document. - """ + """Apply matching templates without failing consumption if extraction fails.""" try: from documents.zone_ocr import run_zone_extraction