mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	some api changes
This commit is contained in:
		
							parent
							
								
									b0143a280e
								
							
						
					
					
						commit
						f33dca2904
					
				@ -3,10 +3,8 @@ from django_filters.rest_framework import BooleanFilter, FilterSet
 | 
				
			|||||||
from .models import Correspondent, Document, Tag, DocumentType
 | 
					from .models import Correspondent, Document, Tag, DocumentType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CHAR_KWARGS = (
 | 
					CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"]
 | 
				
			||||||
    "startswith", "endswith", "contains",
 | 
					ID_KWARGS = ["in", "exact"]
 | 
				
			||||||
    "istartswith", "iendswith", "icontains"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CorrespondentFilterSet(FilterSet):
 | 
					class CorrespondentFilterSet(FilterSet):
 | 
				
			||||||
@ -14,11 +12,7 @@ class CorrespondentFilterSet(FilterSet):
 | 
				
			|||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Correspondent
 | 
					        model = Correspondent
 | 
				
			||||||
        fields = {
 | 
					        fields = {
 | 
				
			||||||
            "name": [
 | 
					            "name": CHAR_KWARGS
 | 
				
			||||||
                "startswith", "endswith", "contains",
 | 
					 | 
				
			||||||
                "istartswith", "iendswith", "icontains"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "slug": ["istartswith", "iendswith", "icontains"]
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,11 +21,7 @@ class TagFilterSet(FilterSet):
 | 
				
			|||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Tag
 | 
					        model = Tag
 | 
				
			||||||
        fields = {
 | 
					        fields = {
 | 
				
			||||||
            "name": [
 | 
					            "name": CHAR_KWARGS
 | 
				
			||||||
                "startswith", "endswith", "contains",
 | 
					 | 
				
			||||||
                "istartswith", "iendswith", "icontains"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "slug": ["istartswith", "iendswith", "icontains"]
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -40,11 +30,7 @@ class DocumentTypeFilterSet(FilterSet):
 | 
				
			|||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = DocumentType
 | 
					        model = DocumentType
 | 
				
			||||||
        fields = {
 | 
					        fields = {
 | 
				
			||||||
            "name": [
 | 
					            "name": CHAR_KWARGS
 | 
				
			||||||
                "startswith", "endswith", "contains",
 | 
					 | 
				
			||||||
                "istartswith", "iendswith", "icontains"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "slug": ["istartswith", "iendswith", "icontains"]
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,15 +48,15 @@ class DocumentFilterSet(FilterSet):
 | 
				
			|||||||
        fields = {
 | 
					        fields = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            "title": CHAR_KWARGS,
 | 
					            "title": CHAR_KWARGS,
 | 
				
			||||||
            "content": ("contains", "icontains"),
 | 
					            "content": CHAR_KWARGS,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            "correspondent__id": ID_KWARGS,
 | 
				
			||||||
            "correspondent__name": CHAR_KWARGS,
 | 
					            "correspondent__name": CHAR_KWARGS,
 | 
				
			||||||
            "correspondent__slug": CHAR_KWARGS,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            "tags__id": ID_KWARGS,
 | 
				
			||||||
            "tags__name": CHAR_KWARGS,
 | 
					            "tags__name": CHAR_KWARGS,
 | 
				
			||||||
            "tags__slug": CHAR_KWARGS,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            "document_type__name": CHAR_KWARGS,
 | 
					            "document_type__id": ID_KWARGS,
 | 
				
			||||||
            "document_type__slug": CHAR_KWARGS,
 | 
					            "document_type__name": CHAR_KWARGS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -58,22 +58,24 @@ class DocumentTypeField(serializers.PrimaryKeyRelatedField):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class DocumentSerializer(serializers.ModelSerializer):
 | 
					class DocumentSerializer(serializers.ModelSerializer):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    correspondent = CorrespondentField(
 | 
					    correspondent_id = CorrespondentField(allow_null=True, source='correspondent')
 | 
				
			||||||
        allow_null=True)
 | 
					    tags_id = TagsField(many=True, source='tags')
 | 
				
			||||||
    tags = TagsField(many=True)
 | 
					    document_type_id = DocumentTypeField(allow_null=True, source='document_type')
 | 
				
			||||||
    document_type = DocumentTypeField(
 | 
					 | 
				
			||||||
        allow_null=True)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Document
 | 
					        model = Document
 | 
				
			||||||
 | 
					        depth = 1
 | 
				
			||||||
        fields = (
 | 
					        fields = (
 | 
				
			||||||
            "id",
 | 
					            "id",
 | 
				
			||||||
            "correspondent",
 | 
					            "correspondent",
 | 
				
			||||||
 | 
					            "correspondent_id",
 | 
				
			||||||
            "document_type",
 | 
					            "document_type",
 | 
				
			||||||
 | 
					            "document_type_id",
 | 
				
			||||||
            "title",
 | 
					            "title",
 | 
				
			||||||
            "content",
 | 
					            "content",
 | 
				
			||||||
            "file_type",
 | 
					            "file_type",
 | 
				
			||||||
            "tags",
 | 
					            "tags",
 | 
				
			||||||
 | 
					            "tags_id",
 | 
				
			||||||
            "checksum",
 | 
					            "checksum",
 | 
				
			||||||
            "created",
 | 
					            "created",
 | 
				
			||||||
            "modified",
 | 
					            "modified",
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ from rest_framework.pagination import PageNumberPagination
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class StandardPagination(PageNumberPagination):
 | 
					class StandardPagination(PageNumberPagination):
 | 
				
			||||||
    page_size = 25
 | 
					    page_size = 25
 | 
				
			||||||
    page_size_query_param = "page-size"
 | 
					    page_size_query_param = "page_size"
 | 
				
			||||||
    max_page_size = 100000
 | 
					    max_page_size = 100000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user