Chore: give OCR templates their own matching fields

Templates are never assigned to documents, so the classifier-based Automatic
matching inherited from MatchingModel could never work. Declare the matching
fields with the workflow trigger choices instead. Also keep zones when their
custom field is deleted, allow longer OCR language lists, fix help texts,
and regenerate the unreleased migration.
This commit is contained in:
stumpylog committed 2026-11-19 10:04:31 -08:00
1 parent 8e07452604
commit 4c2df48795
6 files changed
+91 -36

No files matched your search

@@ -1,4 +1,4 @@
# Generated by Django 5.2.17 on 2026-10-20 20:29
# Generated by Django 5.2.18 on 2026-11-19 17:29
import django.core.validators
import django.db.models.deletion
@@ -42,7 +42,6 @@ class Migration(migrations.Migration):
(3, "Exact match"),
(4, "Regular expression"),
(5, "Fuzzy word"),
(6, "Automatic"),
],
default=1,
verbose_name="matching algorithm",
@@ -161,7 +160,7 @@ class Migration(migrations.Migration):
"page",
models.IntegerField(
blank=True,
help_text="Page (1 = first, -1 = last; blank uses the template default)",
help_text="Page (1 = first, -1 = last; blank = first page)",
null=True,
verbose_name="page",
),
@@ -219,7 +218,7 @@ class Migration(migrations.Migration):
models.CharField(
default="eng",
help_text="Tesseract language code(s), e.g. 'deu+eng'",
max_length=20,
max_length=32,
verbose_name="OCR language",
),
),
@@ -259,7 +258,7 @@ class Migration(migrations.Migration):
models.CharField(
blank=True,
default="",
help_text="Optional regex pattern — extracted text is only accepted if it matches",
help_text="Optional regex pattern. Extracted text is only accepted if it fully matches.",
max_length=256,
verbose_name="validation regex",
),
@@ -271,7 +270,7 @@ class Migration(migrations.Migration):
blank=True,
help_text="Target custom field (only used when target is 'custom_field')",
null=True,
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.SET_NULL,
related_name="ocr_zones",
to="documents.customfield",
verbose_name="custom field",