+ def render_to_response(self, request, extra_context=None):
+ return self.view.render_to_response(request, extra_context)
+
+ def get_absolute_url(self):
+ try:
+ root = Site.objects.get_current().root_node
+ except Site.DoesNotExist:
+ root = None
+
+ try:
+ path = self.get_path(root=root)
+ if path:
+ path += '/'
+ root_url = reverse('philo-root')
+ return '%s%s' % (root_url, path)
+ except AncestorDoesNotExist, ViewDoesNotExist:
+ return None
+
+ def get_navigation(self, depth=DEFAULT_NAVIGATION_DEPTH):
+ max_depth = depth + self.get_level()
+ tree = cache_tree_children(self.get_descendants(include_self=True).filter(level__lte=max_depth))
+
+ 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')])
+
+ navigation_list = []
+ for node in nodes:
+ node._override = node_overrides.get(node.pk, None)
+
+ if node._override:
+ if node._override.hide:
+ continue
+ navigation = node._override.get_navigation(node, max_depth)
+ else:
+ navigation = node.view.get_navigation(node, max_depth)
+
+ if not node.is_leaf_node() and node.get_level() < max_depth:
+ children = navigation.get('children', [])
+ children += get_nav(node, node.get_children())
+ navigation['children'] = children
+
+ if 'children' in navigation:
+ navigation['children'].sort(cmp=lambda x,y: cmp(x['order'], y['order']))
+
+ navigation_list.append(navigation)
+
+ return navigation_list
+
+ navigation = get_nav(self.parent, tree)
+ root = navigation[0]
+ navigation = [root] + root['children']
+ del(root['children'])
+ return navigation
+
+ def save(self):
+ super(Node, self).save()
+