Make it a matchingmodel

This commit is contained in:
shamoon committed 2026-10-20 13:29:42 -07:00
1 parent 1bdeb7ebcd
commit 8b77a924dc
2 files changed
+52 -37

No files matched your search

@@ -1,4 +1,4 @@
# Generated by Django 5.2.14 on 2026-06-16 17:36
# Generated by Django 5.2.17 on 2026-10-20 20:29
import django.core.validators
import django.db.models.deletion
@@ -11,6 +11,7 @@ from django.db import models
class Migration(migrations.Migration):
dependencies = [
("documents", "0027_documentbarcode"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
@@ -28,16 +29,29 @@ class Migration(migrations.Migration):
),
("name", models.CharField(max_length=128, verbose_name="name")),
(
"owner",
models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
verbose_name="owner",
"match",
models.CharField(blank=True, max_length=256, verbose_name="match"),
),
(
"matching_algorithm",
models.PositiveSmallIntegerField(
choices=[
(0, "None"),
(1, "Any word"),
(2, "All words"),
(3, "Exact match"),
(4, "Regular expression"),
(5, "Fuzzy word"),
(6, "Automatic"),
],
default=1,
verbose_name="matching algorithm",
),
),
(
"is_insensitive",
models.BooleanField(default=True, verbose_name="is insensitive"),
),
(
"source_width",
models.PositiveIntegerField(
@@ -78,12 +92,14 @@ class Migration(migrations.Migration):
models.DateTimeField(auto_now=True, verbose_name="updated"),
),
(
"document_type",
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="ocr_templates",
to="documents.documenttype",
verbose_name="document type",
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
verbose_name="owner",
),
),
(
@@ -103,6 +119,7 @@ class Migration(migrations.Migration):
"verbose_name": "OCR template",
"verbose_name_plural": "OCR templates",
"ordering": ("name",),
"abstract": False,
},
),
migrations.CreateModel(
@@ -276,4 +293,19 @@ class Migration(migrations.Migration):
"ordering": ("template", "order"),
},
),
migrations.AddConstraint(
model_name="ocrtemplate",
constraint=models.UniqueConstraint(
fields=("name", "owner"),
name="documents_ocrtemplate_unique_name_owner",
),
),
migrations.AddConstraint(
model_name="ocrtemplate",
constraint=models.UniqueConstraint(
condition=models.Q(("owner__isnull", True)),
fields=("name",),
name="documents_ocrtemplate_name_uniq",
),
),
]