]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Explicitly limit asn integer
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 24 Jan 2023 04:28:12 +0000 (20:28 -0800)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 24 Jan 2023 18:13:05 +0000 (10:13 -0800)
src/documents/migrations/1029_alter_document_archive_serial_number.py [new file with mode: 0644]
src/documents/models.py

diff --git a/src/documents/migrations/1029_alter_document_archive_serial_number.py b/src/documents/migrations/1029_alter_document_archive_serial_number.py
new file mode 100644 (file)
index 0000000..fe591c3
--- /dev/null
@@ -0,0 +1,30 @@
+# Generated by Django 4.1.4 on 2023-01-24 05:09
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("documents", "1028_remove_paperlesstask_task_args_and_more"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="document",
+            name="archive_serial_number",
+            field=models.PositiveIntegerField(
+                blank=True,
+                db_index=True,
+                help_text="The position of this document in your physical document archive.",
+                null=True,
+                unique=True,
+                validators=[
+                    django.core.validators.MaxValueValidator(2147483647),
+                    django.core.validators.MinValueValidator(0),
+                ],
+                verbose_name="archive serial number",
+            ),
+        ),
+    ]
index a59340e5bcc54bd106ea429447dd2605a5d6d066..e9da713aa60a8623ecf2864294d7fa9a551b3cf8 100644 (file)
@@ -10,6 +10,8 @@ import pathvalidate
 from celery import states
 from django.conf import settings
 from django.contrib.auth.models import User
+from django.core.validators import MaxValueValidator
+from django.core.validators import MinValueValidator
 from django.db import models
 from django.utils import timezone
 from django.utils.translation import gettext_lazy as _
@@ -227,12 +229,16 @@ class Document(models.Model):
         help_text=_("The original name of the file when it was uploaded"),
     )
 
-    archive_serial_number = models.IntegerField(
+    archive_serial_number = models.PositiveIntegerField(
         _("archive serial number"),
         blank=True,
         null=True,
         unique=True,
         db_index=True,
+        validators=[
+            MaxValueValidator(2147483647),
+            MinValueValidator(0),
+        ],
         help_text=_(
             "The position of this document in your physical document " "archive.",
         ),