- if depth == current_depth:
- return navigation
- import pdb
- pdb.set_trace()
- found_node_pks = found_node_pks or [self.pk]
- ordered_child_pks = NodeNavigationOverride.objects.filter(parent=self, child__parent=self).values_list('child__pk', flat=True)
-
- children = self.children.exclude(pk__in=found_node_pks)
- ordered_children = children.filter(pk__in=ordered_child_pks)
- unordered_children = children.exclude(pk__in=ordered_child_pks)
-
- children = list(ordered_children) + list(unordered_children)
-
- if children:
- child_navigation = []
- for child in children:
- found_node_pks.append(child.pk)
- try:
- child_navigation.append(child.get_navigation(depth, current_depth + 1, found_node_pks))
- except NotImplementedError:
- pass
+ def get_nav(parent, nodes):
+ node_overrides = dict([(override.child.pk, override) for override in NodeNavigationOverride.objects.filter(parent=parent, child__in=nodes).select_related('child')])