Permalink
Browse files

testsuite works again

  • Loading branch information...
1 parent 2f26445 commit c1c96cbf754dca24758933305301a017bd80cdbe @digi604 digi604 committed Dec 11, 2009
Showing with 12 additions and 12 deletions.
  1. +0 −1 cms/models/managers.py
  2. +1 −1 cms/models/pagemodel.py
  3. +1 −7 cms/tests/permmod.py
  4. +10 −3 cms/utils/permissions.py
View
@@ -446,7 +446,6 @@ def __get_id_list(self, user, site, attr):
# his group/s
qs = PagePermission.objects.with_user(user)
qs.order_by('page__tree_id', 'page__level', 'page__lft')
-
# default is denny...
page_id_allow_list = []
for permission in qs:
View
@@ -547,12 +547,12 @@ def has_generic_permission(self, request, type):
att_name = "permission_%s_cache" % 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))
if getattr(self, att_name):
self.permission_edit_cache = True
+
return getattr(self, att_name)
def is_home(self):
View
@@ -105,8 +105,6 @@ def assign_user_to_page(self, page, user, grant_on=ACCESS_PAGE_AND_DESCENDANTS,
response = self.client.get(URL_CMS_PAGE_CHANGE % page.id)
self.assertEqual(response.status_code, 200)
- #print "TODO:", response.content
-
data = {
'can_add': can_add,
'can_change': can_change,
@@ -314,7 +312,7 @@ def test_05_slave_can_add_page_under_slave_home(self):
# can he even access it over get?
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
- print response
+ #print response
page_data = self.get_new_page_data(slave_page.pk)
# request moderation
@@ -326,12 +324,8 @@ def test_05_slave_can_add_page_under_slave_home(self):
# add page
self.login_user(self.user_slave)
- print url
- print page_data
response = self.client.post(url, page_data)
- print response
self.assertRedirects(response, URL_CMS_PAGE)
-
# public model shouldn't be available yet, because of the moderation
self.assertObjectExist(Title.objects, slug=page_data['slug'])
self.assertObjectDoesNotExist(Title.objects.public(), slug=page_data['slug'])
View
@@ -70,7 +70,13 @@ def has_page_add_permission(request):
return True
return False
-
+def has_any_page_change_permissions(request):
+ from cms.admin.utils import current_site
+ permissions = PagePermission.objects.filter(page__site=current_site(request)).filter(Q(user=request.user)|Q(group__in=request.user.groups.all()))
+ if permissions.count()>0:
+ return True
+ return False
+
def has_page_change_permission(request):
"""Return true if the current user has permission to change any page. This is
just used for building the tree - only superuser, or user with can_change in
@@ -80,11 +86,12 @@ def has_page_change_permission(request):
opts = Page._meta
if request.user.is_superuser or \
(request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()) and
- GlobalPagePermission.objects.with_user(request.user).filter(can_change=True, sites__in=[current_site(request)]).count()>0):
+ (GlobalPagePermission.objects.with_user(request.user).filter(can_change=True, sites__in=[current_site(request)]).count()>0) or
+ has_any_page_change_permissions(request)):
return True
return False
-
+
def get_user_permission_level(user):
"""Returns highest user level from the page/permission hierarchy on which
user haves can_change_permission. Also takes look into user groups. Higher

0 comments on commit c1c96cb

Please sign in to comment.