mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-04 04:29:52 +01:00
Changes before error encountered
Co-authored-by: dawnsystem <42047891+dawnsystem@users.noreply.github.com>
This commit is contained in:
parent
780decf543
commit
1b4bc75a80
2 changed files with 101 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ from documents.filters import CustomFieldQueryParser
|
||||||
from documents.models import Correspondent
|
from documents.models import Correspondent
|
||||||
from documents.models import CustomField
|
from documents.models import CustomField
|
||||||
from documents.models import CustomFieldInstance
|
from documents.models import CustomFieldInstance
|
||||||
|
from documents.models import DeletionRequest
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
from documents.models import DocumentType
|
from documents.models import DocumentType
|
||||||
from documents.models import MatchingModel
|
from documents.models import MatchingModel
|
||||||
|
|
@ -2696,3 +2697,100 @@ class StoragePathTestSerializer(SerializerWithPerms):
|
||||||
label="Document",
|
label="Document",
|
||||||
write_only=True,
|
write_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DeletionRequestSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
Serializer for DeletionRequest model.
|
||||||
|
Provides full CRUD operations for AI-initiated deletion requests.
|
||||||
|
"""
|
||||||
|
|
||||||
|
user_username = serializers.CharField(
|
||||||
|
source="user.username",
|
||||||
|
read_only=True,
|
||||||
|
label="User",
|
||||||
|
)
|
||||||
|
|
||||||
|
reviewed_by_username = serializers.CharField(
|
||||||
|
source="reviewed_by.username",
|
||||||
|
read_only=True,
|
||||||
|
label="Reviewed By",
|
||||||
|
allow_null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
document_count = serializers.SerializerMethodField(
|
||||||
|
label="Document Count",
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
documents_detail = serializers.SerializerMethodField(
|
||||||
|
label="Documents",
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DeletionRequest
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"requested_by_ai",
|
||||||
|
"ai_reason",
|
||||||
|
"user",
|
||||||
|
"user_username",
|
||||||
|
"status",
|
||||||
|
"documents",
|
||||||
|
"documents_detail",
|
||||||
|
"document_count",
|
||||||
|
"impact_summary",
|
||||||
|
"reviewed_at",
|
||||||
|
"reviewed_by",
|
||||||
|
"reviewed_by_username",
|
||||||
|
"review_comment",
|
||||||
|
"completed_at",
|
||||||
|
"completion_details",
|
||||||
|
]
|
||||||
|
read_only_fields = [
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"reviewed_at",
|
||||||
|
"reviewed_by",
|
||||||
|
"completed_at",
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_document_count(self, obj):
|
||||||
|
"""Get the count of documents in this deletion request."""
|
||||||
|
return obj.documents.count()
|
||||||
|
|
||||||
|
def get_documents_detail(self, obj):
|
||||||
|
"""Get detailed information about documents in this deletion request."""
|
||||||
|
documents = obj.documents.all()[:100] # Limit to prevent large responses
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": doc.id,
|
||||||
|
"title": doc.title,
|
||||||
|
"created": doc.created,
|
||||||
|
"correspondent": (
|
||||||
|
doc.correspondent.name if doc.correspondent else None
|
||||||
|
),
|
||||||
|
"document_type": (
|
||||||
|
doc.document_type.name if doc.document_type else None
|
||||||
|
),
|
||||||
|
"tags": [tag.name for tag in doc.tags.all()],
|
||||||
|
}
|
||||||
|
for doc in documents
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class DeletionRequestActionSerializer(serializers.Serializer):
|
||||||
|
"""
|
||||||
|
Serializer for approve/reject actions on DeletionRequest.
|
||||||
|
"""
|
||||||
|
|
||||||
|
review_comment = serializers.CharField(
|
||||||
|
required=False,
|
||||||
|
allow_blank=True,
|
||||||
|
label="Review Comment",
|
||||||
|
help_text="Optional comment when reviewing the deletion request",
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ from documents.matching import match_storage_paths
|
||||||
from documents.matching import match_tags
|
from documents.matching import match_tags
|
||||||
from documents.models import Correspondent
|
from documents.models import Correspondent
|
||||||
from documents.models import CustomField
|
from documents.models import CustomField
|
||||||
|
from documents.models import DeletionRequest
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
from documents.models import DocumentType
|
from documents.models import DocumentType
|
||||||
from documents.models import Note
|
from documents.models import Note
|
||||||
|
|
@ -157,6 +158,8 @@ from documents.serialisers import BulkEditObjectsSerializer
|
||||||
from documents.serialisers import BulkEditSerializer
|
from documents.serialisers import BulkEditSerializer
|
||||||
from documents.serialisers import CorrespondentSerializer
|
from documents.serialisers import CorrespondentSerializer
|
||||||
from documents.serialisers import CustomFieldSerializer
|
from documents.serialisers import CustomFieldSerializer
|
||||||
|
from documents.serialisers import DeletionRequestActionSerializer
|
||||||
|
from documents.serialisers import DeletionRequestSerializer
|
||||||
from documents.serialisers import DocumentListSerializer
|
from documents.serialisers import DocumentListSerializer
|
||||||
from documents.serialisers import DocumentSerializer
|
from documents.serialisers import DocumentSerializer
|
||||||
from documents.serialisers import DocumentTypeSerializer
|
from documents.serialisers import DocumentTypeSerializer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue