mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 15:55:31 +01:00
Just include comments on document object
This commit is contained in:
parent
727fb38baf
commit
89c639f850
14 changed files with 147 additions and 85 deletions
|
|
@ -16,7 +16,6 @@ from rest_framework import serializers
|
|||
from rest_framework.fields import SerializerMethodField
|
||||
|
||||
from . import bulk_edit
|
||||
from .models import Comment
|
||||
from .models import Correspondent
|
||||
from .models import Document
|
||||
from .models import DocumentType
|
||||
|
|
@ -383,7 +382,7 @@ class DocumentSerializer(OwnedObjectSerializer, DynamicFieldsModelSerializer):
|
|||
archived_file_name = SerializerMethodField()
|
||||
created_date = serializers.DateField(required=False)
|
||||
|
||||
n_comments = SerializerMethodField()
|
||||
num_comments = serializers.IntegerField(read_only=True)
|
||||
|
||||
owner = serializers.PrimaryKeyRelatedField(
|
||||
queryset=User.objects.all(),
|
||||
|
|
@ -400,9 +399,6 @@ class DocumentSerializer(OwnedObjectSerializer, DynamicFieldsModelSerializer):
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_n_comments(self, obj):
|
||||
return Comment.objects.filter(document=obj).count()
|
||||
|
||||
def to_representation(self, instance):
|
||||
doc = super().to_representation(instance)
|
||||
if self.truncate_content:
|
||||
|
|
@ -448,7 +444,8 @@ class DocumentSerializer(OwnedObjectSerializer, DynamicFieldsModelSerializer):
|
|||
"owner",
|
||||
"permissions",
|
||||
"set_permissions",
|
||||
"n_comments",
|
||||
"comments",
|
||||
"num_comments",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue