]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: replace strtobool
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 19 Jun 2025 16:01:00 +0000 (09:01 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Thu, 19 Jun 2025 16:02:10 +0000 (09:02 -0700)
src/documents/utils.py
src/documents/views.py

index 04aa95bce657b2c04423ebeb7933f935a3d53cce..2b6a6074909858b6fbf4b550ae2ae99ffc7e9467 100644 (file)
@@ -121,3 +121,10 @@ def run_subprocess(
         completed_proc.check_returncode()
 
     return completed_proc
+
+
+def get_boolean(boolstr: str) -> bool:
+    """
+    Return a boolean value from a string representation.
+    """
+    return bool(boolstr.lower() in ("yes", "y", "1", "t", "true"))
index 4dc1862607cf332472c26e7566372103fd597062..74d1ff3eac8676eb2c2af189eb4a0d403978cfaf 100644 (file)
@@ -6,7 +6,6 @@ import re
 import tempfile
 import zipfile
 from datetime import datetime
-from distutils.util import strtobool
 from pathlib import Path
 from time import mktime
 from unicodedata import normalize
@@ -169,6 +168,7 @@ from documents.tasks import index_optimize
 from documents.tasks import sanity_check
 from documents.tasks import train_classifier
 from documents.templating.filepath import validate_filepath_template_and_render
+from documents.utils import get_boolean
 from paperless import version
 from paperless.celery import app as celery_app
 from paperless.config import GeneralConfig
@@ -238,8 +238,8 @@ class PassUserMixin(GenericAPIView):
     def get_serializer(self, *args, **kwargs):
         kwargs.setdefault("user", self.request.user)
         try:
-            full_perms = bool(
-                strtobool(str(self.request.query_params.get("full_perms", "false"))),
+            full_perms = get_boolean(
+                str(self.request.query_params.get("full_perms", "false")),
             )
         except ValueError:
             full_perms = False
@@ -600,8 +600,8 @@ class DocumentViewSet(
         kwargs.setdefault("fields", fields)
         kwargs.setdefault("truncate_content", truncate_content.lower() in ["true", "1"])
         try:
-            full_perms = bool(
-                strtobool(str(self.request.query_params.get("full_perms", "false"))),
+            full_perms = get_boolean(
+                str(self.request.query_params.get("full_perms", "false")),
             )
         except ValueError:
             full_perms = False