Permalink
Browse files

Merge pull request #935 from ojii/failfast-on-invalid-menu-usage

When using the menu tag wrong (eg give a page as 'namespace') the menu ta
  • Loading branch information...
fivethreeo committed Aug 14, 2011
2 parents e22acbd + 68a5390 commit 16086e19e5af1af699030942e283ff5ee553f6ef
Showing with 15 additions and 7 deletions.
  1. +9 −1 cms/tests/menu.py
  2. +1 −1 docs/getting_started/installation.rst
  3. +4 −4 menus/templatetags/menu_tags.py
  4. +1 −1 setup.py
View
@@ -13,7 +13,7 @@
from django.contrib.auth.models import AnonymousUser, User, Permission, Group
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
-from django.template import Template
+from django.template import Template, TemplateSyntaxError
from menus.base import NavigationNode
from menus.menu_pool import menu_pool, _build_nodes_inner_for_one_menu
from menus.utils import mark_descendants, find_selected, cut_levels
@@ -71,6 +71,14 @@ def get_level(self, num):
def get_all_pages(self):
return Page.objects.all()
+ def test_menu_failfast_on_invalid_usage(self):
+ context = self.get_context()
+ context['child'] = self.get_page(1)
+ # test standard show_menu
+ with SettingsOverride(DEBUG=True, TEMPLATE_DEBUG=True):
+ tpl = Template("{% load menu_tags %}{% show_menu 0 0 0 0 'menu/menu.html' child %}")
+ self.assertRaises(TemplateSyntaxError, tpl.render, context)
+
def test_basic_cms_menu(self):
self.assertEqual(len(menu_pool.menus), 1)
response = self.client.get(self.get_pages_root()) # path = '/'
@@ -13,7 +13,7 @@ Requirements
* `Django`_ 1.2.5 (or a 1.3.x release).
* `South`_ 0.7.2 or higher
* `PIL`_ 1.1.6 or higher
-* `django-classy-tags`_ 0.3.2 or higher
+* `django-classy-tags`_ 0.3.4.1 or higher
* `django-mptt`_ 0.4.2 or higher
* `django-sekizai`_ 0.4.2 or higher
* An installed and working instance of one of the databases listed in the
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from classytags.arguments import IntegerArgument, Argument
+from classytags.arguments import IntegerArgument, Argument, StringArgument
from classytags.core import Options
from classytags.helpers import InclusionTag
from django import template
@@ -104,9 +104,9 @@ class ShowMenu(InclusionTag):
IntegerArgument('to_level', default=100, required=False),
IntegerArgument('extra_inactive', default=0, required=False),
IntegerArgument('extra_active', default=1000, required=False),
- Argument('template', default='menu/menu.html', required=False),
- Argument('namespace', default=None, required=False),
- Argument('root_id', default=None, required=False),
+ StringArgument('template', default='menu/menu.html', required=False),
+ StringArgument('namespace', default=None, required=False),
+ StringArgument('root_id', default=None, required=False),
Argument('next_page', default=None, required=False),
)
View
@@ -29,7 +29,7 @@
classifiers=CLASSIFIERS,
install_requires=[
'Django>=1.2.5',
- 'django-classy-tags>=0.3.3',
+ 'django-classy-tags>=0.3.4.1',
'south>=0.7.2',
'django-mptt>=0.4.2',
'django-sekizai>=0.4.2',

0 comments on commit 16086e1

Please sign in to comment.