- def get_navigation(self, depth=DEFAULT_NAVIGATION_DEPTH, current_depth=0, found_node_pks=None):
- navigation = self.view.get_navigation(self, depth, current_depth)
-
- 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
-
- if child_navigation:
- if 'children' in navigation:
- navigation['children'] += child_navigation
- else:
- navigation['children'] = child_navigation
-
- return navigation
-
- def save(self):
- super(Node, self).save()
-
-