Move the merge as version heirarchy checks to the bulk edit method

This commit is contained in:
shamoon committed 2026-11-14 11:51:41 -08:00
1 parent 6d26d3f5ca
commit bb775a16c1
3 files changed
+105 -78

No files matched your search

+8
View File
@@ -702,7 +702,15 @@ def merge_as_versions(
)
documents_by_id = {document.id: document for document in documents}
if any(document.root_document_id is not None for document in documents):
raise ValueError("Only top-level documents can be merged as versions.")
source_ids = [doc_id for doc_id in doc_ids if doc_id != root_document_id]
if Document.global_objects.filter(root_document_id__in=source_ids).exists():
raise ValueError(
"Documents with existing versions cannot be merged into another document.",
)
root_document = documents_by_id[root_document_id]
next_version_index = (
Document.global_objects.filter(