Skip to content

Commit

Permalink
Final fixes?
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoistinen committed Oct 7, 2015
1 parent f0244be commit 5cc4ba2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cms/cms_wizards.py
Expand Up @@ -14,7 +14,7 @@
class CMSPageWizard(Wizard):

def user_has_add_permission(self, user):
return user_has_page_add_perm(user)
return user.is_superuser or user_has_page_add_perm(user)


cms_page_wizard = CMSPageWizard(
Expand Down
3 changes: 2 additions & 1 deletion cms/forms/wizards.py
Expand Up @@ -57,7 +57,8 @@ def save(self, **kwargs):
# already checked this when producing a list of wizard entries, but this
# is to prevent people from possible form-hacking.

if not permissions.user_has_page_add_perm(self.user):
if not (self.user.is_superuser or
permissions.user_has_page_add_perm(self.user)):
raise NoPermissionsException(
_(u"User does not have permission to add page."))
title = self.cleaned_data['title']
Expand Down
5 changes: 2 additions & 3 deletions cms/tests/test_permmod.py
Expand Up @@ -29,8 +29,7 @@
GlobalPagePermission)
from cms.plugin_pool import plugin_pool
from cms.test_utils.testcases import (URL_CMS_PAGE_ADD, URL_CMS_PLUGIN_REMOVE,
URL_CMS_PLUGIN_ADD, CMSTestCase,
TransactionCMSTestCase)
URL_CMS_PLUGIN_ADD, CMSTestCase)
from cms.test_utils.util.context_managers import disable_logger
from cms.test_utils.util.fuzzy_int import FuzzyInt
from cms.utils.i18n import force_language
Expand Down Expand Up @@ -1093,7 +1092,7 @@ def setUp(self):
self.expected = [self.page.publisher_public_id]


class GlobalPermissionTests(TransactionCMSTestCase):
class GlobalPermissionTests(CMSTestCase):

def test_sanity_check(self):
""" Because we have a new manager, we'll do some basic checks."""
Expand Down
6 changes: 5 additions & 1 deletion cms/utils/permissions.py
Expand Up @@ -101,7 +101,11 @@ def has_page_add_permission(request):
if page.parent_id:
return has_generic_permission(page.parent_id, request.user, "add", page.site)
else:
return user_has_page_add_perm(request.user, site=site)
global_add_perm = GlobalPagePermission.objects.user_has_add_permission(
request.user, site).exists()
if (request.user.has_perm(opts.app_label + '.' + get_permission_codename('add', opts))
and global_add_perm):
return True
return False


Expand Down

0 comments on commit 5cc4ba2

Please sign in to comment.