Permalink
Browse files

or should be and because of GlobalPagePermission, only run test_06_pa…

…ge_added_by_slave_can_be_published with failfast because of debugging assert
  • Loading branch information...
1 parent da018c6 commit ad5cdebe2693caafae704b50826718519c3e0a47 @fivethreeo fivethreeo committed Dec 30, 2010
Showing with 13 additions and 6 deletions.
  1. +7 −0 cms/models/managers.py
  2. +5 −5 cms/models/pagemodel.py
  3. +1 −1 cms/tests/permmod.py
@@ -457,17 +457,24 @@ def __get_id_list(self, user, site, attr):
qs.order_by('page__tree_id', 'page__level', 'page__lft')
# default is denny...
page_id_allow_list = []
+ desc_list = []
for permission in qs:
+ desc_list.append((permission.page.pk, permission.grant_on, permission.page.get_descendants().values_list('id', flat=True)))
+
is_allowed = getattr(permission, attr)
if is_allowed:
+
# can add is special - we are actually adding page under current page
if permission.grant_on & MASK_PAGE or attr is "can_add":
page_id_allow_list.append(permission.page.id)
if permission.grant_on & MASK_CHILDREN and not attr is "can_add":
page_id_allow_list.extend(permission.page.get_children().values_list('id', flat=True))
elif permission.grant_on & MASK_DESCENDANTS:
page_id_allow_list.extend(permission.page.get_descendants().values_list('id', flat=True))
+
+ assert False, str(desc_list) # no pages with permissions has descendants???
# store value in cache
+
#set_permission_cache(user, attr, page_id_allow_list)
return page_id_allow_list
@@ -713,14 +713,14 @@ def has_change_permission(self, request):
opts = self._meta
if request.user.is_superuser:
return True
- return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()) or \
+ return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()) and \
self.has_generic_permission(request, "change")
def has_delete_permission(self, request):
opts = self._meta
if request.user.is_superuser:
return True
- return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission()) or \
+ return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission()) and \
self.has_generic_permission(request, "delete")
def has_publish_permission(self, request):
@@ -752,17 +752,17 @@ def has_moderate_permission(self, request):
return False
return self.has_generic_permission(request, "moderate")
- def has_generic_permission(self, request, type):
+ def has_generic_permission(self, request, perm_type):
"""
Return true if the current user has permission on the page.
Return the string 'All' if the user has all rights.
"""
- att_name = "permission_%s_cache" % type
+ att_name = "permission_%s_cache" % perm_type
if not hasattr(self, "permission_user_cache") or not hasattr(self, att_name) \
or request.user.pk != self.permission_user_cache.pk:
from cms.utils.permissions import has_generic_permission
self.permission_user_cache = request.user
- setattr(self, att_name, has_generic_permission(self.id, request.user, type, self.site_id))
+ setattr(self, att_name, has_generic_permission(self.id, request.user, perm_type, self.site_id))
if getattr(self, att_name):
self.permission_edit_cache = True
@@ -349,7 +349,7 @@ def test_05_slave_can_add_page_under_slave_home(self):
def test_06_page_added_by_slave_can_be_published_approved_by_user_master(self):
self.login_user(self.user_master)
slave_page = self.slave_page
-
+
# add page
page = self.create_page(slave_page, user=self.user_slave)
# same as test_05_slave_can_add_page_under_slave_home

0 comments on commit ad5cdeb

Please sign in to comment.