diff --git a/src/documents/filters.py b/src/documents/filters.py index cdf6f63b0..76a0dd296 100755 --- a/src/documents/filters.py +++ b/src/documents/filters.py @@ -3,10 +3,8 @@ from django_filters.rest_framework import BooleanFilter, FilterSet from .models import Correspondent, Document, Tag, DocumentType -CHAR_KWARGS = ( - "startswith", "endswith", "contains", - "istartswith", "iendswith", "icontains" -) +CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"] +ID_KWARGS = ["in", "exact"] class CorrespondentFilterSet(FilterSet): @@ -14,11 +12,7 @@ class CorrespondentFilterSet(FilterSet): class Meta: model = Correspondent fields = { - "name": [ - "startswith", "endswith", "contains", - "istartswith", "iendswith", "icontains" - ], - "slug": ["istartswith", "iendswith", "icontains"] + "name": CHAR_KWARGS } @@ -27,11 +21,7 @@ class TagFilterSet(FilterSet): class Meta: model = Tag fields = { - "name": [ - "startswith", "endswith", "contains", - "istartswith", "iendswith", "icontains" - ], - "slug": ["istartswith", "iendswith", "icontains"] + "name": CHAR_KWARGS } @@ -40,11 +30,7 @@ class DocumentTypeFilterSet(FilterSet): class Meta: model = DocumentType fields = { - "name": [ - "startswith", "endswith", "contains", - "istartswith", "iendswith", "icontains" - ], - "slug": ["istartswith", "iendswith", "icontains"] + "name": CHAR_KWARGS } @@ -62,15 +48,15 @@ class DocumentFilterSet(FilterSet): fields = { "title": CHAR_KWARGS, - "content": ("contains", "icontains"), + "content": CHAR_KWARGS, + "correspondent__id": ID_KWARGS, "correspondent__name": CHAR_KWARGS, - "correspondent__slug": CHAR_KWARGS, + "tags__id": ID_KWARGS, "tags__name": CHAR_KWARGS, - "tags__slug": CHAR_KWARGS, - "document_type__name": CHAR_KWARGS, - "document_type__slug": CHAR_KWARGS, + "document_type__id": ID_KWARGS, + "document_type__name": CHAR_KWARGS } diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index a6ecfccaa..92b804f1b 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -58,22 +58,24 @@ class DocumentTypeField(serializers.PrimaryKeyRelatedField): class DocumentSerializer(serializers.ModelSerializer): - correspondent = CorrespondentField( - allow_null=True) - tags = TagsField(many=True) - document_type = DocumentTypeField( - allow_null=True) + correspondent_id = CorrespondentField(allow_null=True, source='correspondent') + tags_id = TagsField(many=True, source='tags') + document_type_id = DocumentTypeField(allow_null=True, source='document_type') class Meta: model = Document + depth = 1 fields = ( "id", "correspondent", + "correspondent_id", "document_type", + "document_type_id", "title", "content", "file_type", "tags", + "tags_id", "checksum", "created", "modified", diff --git a/src/paperless/views.py b/src/paperless/views.py index b219379da..560a27980 100644 --- a/src/paperless/views.py +++ b/src/paperless/views.py @@ -7,7 +7,7 @@ from rest_framework.pagination import PageNumberPagination class StandardPagination(PageNumberPagination): page_size = 25 - page_size_query_param = "page-size" + page_size_query_param = "page_size" max_page_size = 100000