Permalink
Browse files

fixed tests that had page.level = None

  • Loading branch information...
1 parent 7107eb4 commit db0fdae9d5fb32e181f2d2dee58af8c009c5ecb1 @FrankBie2 committed Jan 4, 2012
Showing with 5 additions and 10 deletions.
  1. +1 −10 cms/menu.py
  2. +4 −0 cms/tests/menu.py
View
@@ -35,22 +35,13 @@ def get_visible_pages(request, pages, site=None):
for page in pages:
# taken from for_page as multiple at once version
- if page.level == None:
- # page.level might be None if the page is not saved yet
- # see - test.menu test_public_for_all_staff
-
- # set it to an invalid value
- page.level = -1
-
page_q = Q(page__tree_id=page.tree_id) & (
Q(page=page)
| (Q(page__level__lt=page.level) & (Q(grant_on=ACCESS_DESCENDANTS) | Q(grant_on=ACCESS_PAGE_AND_DESCENDANTS)))
| (Q(page__level=page.level - 1) & (Q(grant_on=ACCESS_CHILDREN) | Q(grant_on=ACCESS_PAGE_AND_CHILDREN)))
)
pages_perms_q |= page_q
- if page.level == -1:
- # restore page level to None
- page.level = None
+
pages_perms_q &= Q(can_view=True)
page_permissions = PagePermission.objects.filter(pages_perms_q).select_related('page', 'group__users')
View
@@ -763,6 +763,8 @@ def test_public_for_all_staff(self):
request.user.is_staff = True
page = Page()
page.pk = 1
+ page.level = 0
+ page.tree_id = 1
pages = [page]
result = get_visible_pages(request, pages)
self.assertEqual(result, [1])
@@ -772,6 +774,8 @@ def test_public_for_all_staff_assert_num_queries(self):
request.user.is_staff = True
page = Page()
page.pk = 1
+ page.level = 0
+ page.tree_id = 1
pages = [page]
with self.assertNumQueries(1):
"""

2 comments on commit db0fdae

Owner

FrankBie2 replied Jan 4, 2012

tests are now fixed in tests.menu

ojii replied Jan 4, 2012

awesome!

Please sign in to comment.