Skip to content
Browse files

Only check permissions if permissions are enabled.

  • Loading branch information...
1 parent d8b7027 commit c8312f7ba42c9766e45d9d67618ab434d0f36370 @stephrdev stephrdev committed Aug 19, 2011
Showing with 19 additions and 10 deletions.
  1. +15 −7 cms/templatetags/cms_admin.py
  2. +4 −3 cms/utils/admin.py
View
22 cms/templatetags/cms_admin.py
@@ -80,13 +80,21 @@ def boolean_icon(value):
@register.filter
def is_restricted(page, request):
- all_perms = get_any_page_view_permissions(request, page)
- icon = boolean_icon(all_perms.exists())
- return mark_safe(
- ugettext('<span title="Restrictions: %(title)s">%(icon)s</span>') % {
- 'title': u', '.join((perm.get_grant_on_display() for perm in all_perms)) or None,
- 'icon': icon,
- })
+ if settings.CMS_PERMISSION:
+ all_perms = get_any_page_view_permissions(request, page)
+ icon = boolean_icon(all_perms.exists())
+ return mark_safe(
+ ugettext('<span title="Restrictions: %(title)s">%(icon)s</span>') % {
+ 'title': u', '.join((perm.get_grant_on_display() for perm in all_perms)) or None,
+ 'icon': icon,
+ })
+ else:
+ icon = boolean_icon(None)
+ return mark_safe(
+ ugettext('<span title="Restrictions: %(title)s">%(icon)s</span>') % {
+ 'title': None,
+ 'icon': icon,
+ })
@register.filter
def moderator_choices(page, user):
View
7 cms/utils/admin.py
@@ -41,9 +41,10 @@ def get_admin_menu_item_context(request, page, filtered=False):
moderator_state = moderator.page_moderator_state(request, page)
has_add_on_same_level_permission = False
opts = Page._meta
- if (request.user.has_perm(opts.app_label + '.' + opts.get_add_permission()) and
- GlobalPagePermission.objects.with_user(request.user).filter(can_add=True, sites__in=[page.site_id])):
- has_add_on_same_level_permission = True
+ if settings.CMS_PERMISSION:
+ if (request.user.has_perm(opts.app_label + '.' + opts.get_add_permission()) and
+ GlobalPagePermission.objects.with_user(request.user).filter(can_add=True, sites__in=[page.site_id])):
+ has_add_on_same_level_permission = True
if not has_add_on_same_level_permission and page.parent_id:
has_add_on_same_level_permission = permissions.has_generic_permission(page.parent_id, request.user, "add", page.site)

0 comments on commit c8312f7

Please sign in to comment.
Something went wrong with that request. Please try again.