Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion navutils/templatetags/navutils_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ def render_node(context, node, **kwargs):
max_depth = kwargs.get('max_depth', context.get('max_depth', 999))
start_depth = kwargs.get('start_depth', context.get('start_depth', node.depth))
current_depth = kwargs.get('current_depth', context.get('current_depth', node.depth - start_depth))
template_file = kwargs.get('template', node.template)

viewable_children = []
if current_depth + 1 <= max_depth:
for child in node.children:
if child.is_viewable_by(user, context):
viewable_children.append(child)

t = template.loader.get_template(node.template)
t = template.loader.get_template(template_file)

c = {
'is_current': node.is_current(current),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ def test_render_node_template_tag_with_node_attrs(self):
<a href="http://test.com">Test</a>
</li>""")

def test_render_node_template_tag_with_overridden_template_file(self):
attrs = {'id': 'important'}
node = menu.Node('test', 'Test', url='http://test.com', attrs=attrs)

output = navutils_tags.render_node({}, node=node, user=self.user, template='navutils/node.html')
self.assertHTMLEqual(
output,
"""<li class="menu-item" id="important">
<a href="http://test.com">Test</a>
</li>""")

def test_render_node_template_tag_with_children(self):
child1 = menu.Node('c1', 'c1', url='c1')
child2 = menu.Node('c2', 'c2', url='c2')
Expand Down