From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 24 Jan 2023 04:28:12 +0000 (-0800) Subject: Explicitly limit asn integer X-Git-Tag: v1.12.0-beta.rc0~18^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c2df48a1a5c7cc9e52024d75e9a08fd148b73cc;p=thirdparty%2Fpaperless-ngx.git Explicitly limit asn integer --- 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 index 0000000000..fe591c3916 --- /dev/null +++ b/src/documents/migrations/1029_alter_document_archive_serial_number.py @@ -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", + ), + ), + ] diff --git a/src/documents/models.py b/src/documents/models.py index a59340e5bc..e9da713aa6 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -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.", ),