mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-20 06:49:27 +00:00
feat: update DocumentVersionInfo and Document interfaces for DocumentVersion API
- Add version_number field to DocumentVersionInfo interface - Remove root_document field from Document interface (field removed from backend model) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -162,7 +162,6 @@ export interface Document extends ObjectWithPermissions {
|
||||
duplicate_documents?: Document[]
|
||||
|
||||
// Versioning
|
||||
root_document?: number
|
||||
versions?: DocumentVersionInfo[]
|
||||
|
||||
// Frontend only
|
||||
@@ -171,6 +170,7 @@ export interface Document extends ObjectWithPermissions {
|
||||
|
||||
export interface DocumentVersionInfo {
|
||||
id: number
|
||||
version_number: number
|
||||
added?: Date
|
||||
version_label?: string
|
||||
checksum?: string
|
||||
|
||||
@@ -70,10 +70,8 @@ class DocumentFactory(DjangoModelFactory):
|
||||
@factory.post_generation
|
||||
def with_version(self, create, extracted, **kwargs):
|
||||
"""Create an initial DocumentVersion(version_number=1) matching the Document's fields."""
|
||||
if not create:
|
||||
if not create or not extracted:
|
||||
return
|
||||
from documents.models import DocumentVersion
|
||||
|
||||
DocumentVersion.objects.create(
|
||||
document=self,
|
||||
version_number=1,
|
||||
|
||||
@@ -41,25 +41,6 @@ def get_version_by_pk(doc: Document, version_pk: int) -> DocumentVersion | None:
|
||||
return DocumentVersion.objects.filter(pk=version_pk, document=doc).first()
|
||||
|
||||
|
||||
def get_root_document(doc: Document) -> Document:
|
||||
"""Return the root document.
|
||||
|
||||
In the new model, every Document IS the root. This is a compatibility stub
|
||||
used by bulk_edit.py; Task 10 will refactor the callers.
|
||||
"""
|
||||
return doc
|
||||
|
||||
|
||||
def get_latest_version_for_root(doc: Document) -> Document:
|
||||
"""Return the document to use as the version source.
|
||||
|
||||
In the new model, DocumentVersion holds per-version files. This stub
|
||||
returns the document itself so that bulk_edit callers that have not yet
|
||||
been updated to the new model do not crash. Task 10 will replace this.
|
||||
"""
|
||||
return doc
|
||||
|
||||
|
||||
def resolve_requested_version(
|
||||
doc: Document,
|
||||
request: Any,
|
||||
|
||||
Reference in New Issue
Block a user