Skip to content
Snippets Groups Projects
Commit 84a8fb25 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Add get_descendings

parent 73349120
No related branches found
No related tags found
1 merge request!18Transcription search
......@@ -22,6 +22,15 @@ class DocumentManager(models.Manager):
"""Get all child documents for a specific document ID."""
return self.filter(dc_child__id=id).order_by('dc_child__ordering')
def get_descendings(self, *ids):
"""Get all parent documents for some document IDs."""
from documents.models import DocumentChildren
dcs = DocumentChildren.objects.filter(id__in=ids).order_by('id', 'ordering').only('id', 'child').select_related('child')
return {
pk: [dc.child for dc in items]
for pk, items in groupby(dcs, lambda d: d.id)
}
def get_related(self, id):
"""Get all parent and child documents for a specific document ID."""
return self.filter(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment