mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 16:25:33 +01:00
Merge branch 'dev' into machine-learning
This commit is contained in:
commit
8eeded95c4
5 changed files with 54 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from .models import Correspondent, Tag, Document, Log
|
||||
from .models import Correspondent, Tag, Document, Log, DocumentType
|
||||
|
||||
|
||||
class CorrespondentSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
|
@ -10,6 +10,13 @@ class CorrespondentSerializer(serializers.HyperlinkedModelSerializer):
|
|||
fields = ("id", "slug", "name", "automatic_classification")
|
||||
|
||||
|
||||
class DocumentTypeSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta(object):
|
||||
model = DocumentType
|
||||
fields = ("id", "slug", "name")
|
||||
|
||||
|
||||
class TagSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta(object):
|
||||
|
|
@ -28,17 +35,25 @@ class TagsField(serializers.HyperlinkedRelatedField):
|
|||
return Tag.objects.all()
|
||||
|
||||
|
||||
class DocumentTypeField(serializers.HyperlinkedRelatedField):
|
||||
def get_queryset(self):
|
||||
return DocumentType.objects.all()
|
||||
|
||||
|
||||
class DocumentSerializer(serializers.ModelSerializer):
|
||||
|
||||
correspondent = CorrespondentField(
|
||||
view_name="drf:correspondent-detail", allow_null=True)
|
||||
tags = TagsField(view_name="drf:tag-detail", many=True)
|
||||
document_type = DocumentTypeField(
|
||||
view_name="drf:documenttype-detail", allow_null=True)
|
||||
|
||||
class Meta(object):
|
||||
model = Document
|
||||
fields = (
|
||||
"id",
|
||||
"correspondent",
|
||||
"document_type",
|
||||
"title",
|
||||
"content",
|
||||
"file_type",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue