diff --git a/paperless.conf.example b/paperless.conf.example index 5fabbf390..63ee7be22 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -81,7 +81,6 @@ #PAPERLESS_THUMBNAIL_FONT_NAME= #PAPERLESS_IGNORE_DATES= #PAPERLESS_ENABLE_UPDATE_CHECK= -#PAPERLESS_ALLOW_CUSTOM_FIELD_LOOKUP=iexact,contains,startswith,endswith,regex,iregex # Tika settings diff --git a/src/documents/filters.py b/src/documents/filters.py index d2232485a..9ea7920c7 100644 --- a/src/documents/filters.py +++ b/src/documents/filters.py @@ -30,13 +30,15 @@ from documents.models import Log from documents.models import ShareLink from documents.models import StoragePath from documents.models import Tag -from paperless import settings CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"] ID_KWARGS = ["in", "exact"] INT_KWARGS = ["exact", "gt", "gte", "lt", "lte", "isnull"] DATE_KWARGS = ["year", "month", "day", "date__gt", "gt", "date__lt", "lt"] +CUSTOM_FIELD_LOOKUP_MAX_DEPTH = 10 +CUSTOM_FIELD_LOOKUP_MAX_ATOMS = 20 + class CorrespondentFilterSet(FilterSet): class Meta: @@ -394,13 +396,7 @@ class CustomFieldLookupParser: self._atom_count += 1 if self._atom_count > self._max_atom_count: raise serializers.ValidationError( - [ - _( - "Maximum number of query conditions exceeded. You can raise " - "the limit by setting PAPERLESS_CUSTOM_FIELD_LOOKUP_MAX_ATOMS " - "in your configuration file.", - ), - ], + [_("Maximum number of query conditions exceeded.")], ) custom_field = self._get_custom_field(id_or_name, validation_prefix="0") @@ -597,15 +593,7 @@ class CustomFieldLookupParser: # guard against queries that are too deeply nested self._current_depth += 1 if self._current_depth > self._max_query_depth: - raise serializers.ValidationError( - [ - _( - "Maximum nesting depth exceeded. You can raise the limit " - "by setting PAPERLESS_CUSTOM_FIELD_LOOKUP_MAX_DEPTH in " - "your configuration file.", - ), - ], - ) + raise serializers.ValidationError([_("Maximum nesting depth exceeded.")]) try: yield finally: @@ -629,8 +617,8 @@ class CustomFieldLookupFilter(Filter): parser = CustomFieldLookupParser( self._validation_prefix, - max_query_depth=settings.CUSTOM_FIELD_LOOKUP_MAX_DEPTH, - max_atom_count=settings.CUSTOM_FIELD_LOOKUP_MAX_ATOMS, + max_query_depth=CUSTOM_FIELD_LOOKUP_MAX_DEPTH, + max_atom_count=CUSTOM_FIELD_LOOKUP_MAX_ATOMS, ) q, annotations = parser.parse(value) diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 2e2306e2a..95badde2f 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -1195,16 +1195,3 @@ EMAIL_ENABLE_GPG_DECRYPTOR: Final[bool] = __get_boolean( # Soft Delete # ############################################################################### EMPTY_TRASH_DELAY = max(__get_int("PAPERLESS_EMPTY_TRASH_DELAY", 30), 1) - -############################################################################### -# custom_field_lookup Filter Settings # -############################################################################### - -CUSTOM_FIELD_LOOKUP_MAX_DEPTH = __get_int( - "PAPERLESS_CUSTOM_FIELD_LOOKUP_MAX_DEPTH", - default=10, -) -CUSTOM_FIELD_LOOKUP_MAX_ATOMS = __get_int( - "PAPERLESS_CUSTOM_FIELD_LOOKUP_MAX_ATOMS", - default=20, -)