mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-06-20 15:17:32 -05:00
Fix: replace strtobool
This commit is contained in:
parent
497fdcaf4e
commit
434b1e3245
@ -121,3 +121,10 @@ def run_subprocess(
|
|||||||
completed_proc.check_returncode()
|
completed_proc.check_returncode()
|
||||||
|
|
||||||
return completed_proc
|
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"))
|
||||||
|
@ -6,7 +6,6 @@ import re
|
|||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils.util import strtobool
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from time import mktime
|
from time import mktime
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
@ -169,6 +168,7 @@ from documents.tasks import index_optimize
|
|||||||
from documents.tasks import sanity_check
|
from documents.tasks import sanity_check
|
||||||
from documents.tasks import train_classifier
|
from documents.tasks import train_classifier
|
||||||
from documents.templating.filepath import validate_filepath_template_and_render
|
from documents.templating.filepath import validate_filepath_template_and_render
|
||||||
|
from documents.utils import get_boolean
|
||||||
from paperless import version
|
from paperless import version
|
||||||
from paperless.celery import app as celery_app
|
from paperless.celery import app as celery_app
|
||||||
from paperless.config import GeneralConfig
|
from paperless.config import GeneralConfig
|
||||||
@ -238,8 +238,8 @@ class PassUserMixin(GenericAPIView):
|
|||||||
def get_serializer(self, *args, **kwargs):
|
def get_serializer(self, *args, **kwargs):
|
||||||
kwargs.setdefault("user", self.request.user)
|
kwargs.setdefault("user", self.request.user)
|
||||||
try:
|
try:
|
||||||
full_perms = bool(
|
full_perms = get_boolean(
|
||||||
strtobool(str(self.request.query_params.get("full_perms", "false"))),
|
str(self.request.query_params.get("full_perms", "false")),
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
full_perms = False
|
full_perms = False
|
||||||
@ -600,8 +600,8 @@ class DocumentViewSet(
|
|||||||
kwargs.setdefault("fields", fields)
|
kwargs.setdefault("fields", fields)
|
||||||
kwargs.setdefault("truncate_content", truncate_content.lower() in ["true", "1"])
|
kwargs.setdefault("truncate_content", truncate_content.lower() in ["true", "1"])
|
||||||
try:
|
try:
|
||||||
full_perms = bool(
|
full_perms = get_boolean(
|
||||||
strtobool(str(self.request.query_params.get("full_perms", "false"))),
|
str(self.request.query_params.get("full_perms", "false")),
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
full_perms = False
|
full_perms = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user