Trash versions when deleting head docs

This commit is contained in:
shamoon
2026-02-10 09:53:28 -08:00
parent 90e3ed142f
commit 57395ff99c
3 changed files with 43 additions and 3 deletions

View File

@@ -436,6 +436,12 @@ class Document(SoftDeleteModel, ModelWithOwner):
tags_to_add = self.tags.model.objects.filter(id__in=tag_ids)
self.tags.add(*tags_to_add)
def delete(self, using=None, *, keep_parents=False):
# If deleting a head document, move all versions to trash as well.
if self.head_version_id is None:
Document.objects.filter(head_version=self).delete()
return super().delete(using=using, keep_parents=keep_parents)
class SavedView(ModelWithOwner):
class DisplayMode(models.TextChoices):