Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/speedups' of https://github.com/stephrdev/djang…

…o-cms into stephrdev-feature/speedups
  • Loading branch information...
commit 421961d5b90b9ef9ccf1d291968fc5bfe8cd4d14 2 parents 2a46231 + c8312f7
@ojii ojii authored
Showing with 25 additions and 11 deletions.
  1. +6 −1 cms/api.py
  2. +15 −7 cms/templatetags/cms_admin.py
  3. +4 −3 cms/utils/admin.py
View
7 cms/api.py
@@ -11,6 +11,7 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
+from django.db.models import Max
from django.template.defaultfilters import slugify
from menus.menu_pool import menu_pool
@@ -266,10 +267,14 @@ def add_plugin(placeholder, plugin_type, language, position='last-child',
# validate and normalize plugin type
plugin_model, plugin_type = _verify_plugin_type(plugin_type)
+
+ max_pos = CMSPlugin.objects.filter(language=language,
+ placeholder=placeholder).aggregate(Max('position')).values()[0] or 0
+
plugin_base = CMSPlugin(
plugin_type=plugin_type,
placeholder=placeholder,
- position=1,
+ position=max_pos + 1,
language=language
)
plugin_base.insert_at(target, position=position, save=False)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.