Permalink
Browse files

Merge branch 'develop' of github.com:divio/django-cms into view-permi…

…ssion-performance-boost
  • Loading branch information...
Jonas Obrist
Jonas Obrist committed Aug 5, 2011
2 parents 6be7842 + 935a705 commit 6bf136d8c381a61962e96e98e74718352fea4022
Showing 339 changed files with 943 additions and 5,243 deletions.
View
@@ -90,6 +90,7 @@ Contributors (in alphabetical order):
* limpbrains :P
* Lucas Vogelsang
* Lucio Asnaghi
+* Luke Crooks
* Luke Plant
* m000
* Maik Lustenberger
View
@@ -4,7 +4,7 @@ include README.rst
include CHANGELOG.txt
recursive-include cms/locale *
recursive-include cms/templates *
-recursive-include cms/media *
+recursive-include cms/static *
recursive-include cms/plugins *
recursive-include menus/templates *
recursive-include docs *
View
@@ -176,7 +176,8 @@ def clean_overwrite_url(self):
if url:
if not any_path_re.match(url):
raise forms.ValidationError(_('Invalid URL, use /my/url format.'))
- if get_page_from_path(url.strip('/')):
+ page = get_page_from_path(url.strip('/'))
+ if page and page.pk != self.instance.pk:
raise forms.ValidationError(_('Page with redirect url %r already exist') % url)
return url
View
@@ -2,20 +2,20 @@
from cms.admin.change_list import CMSChangeList
from cms.admin.dialog.views import get_copy_dialog
from cms.admin.forms import PageForm, PageAddForm
-from cms.admin.permissionadmin import PAGE_ADMIN_INLINES, \
- PagePermissionInlineAdmin, ViewRestrictionInlineAdmin
+from cms.admin.permissionadmin import (PAGE_ADMIN_INLINES,
+ PagePermissionInlineAdmin, ViewRestrictionInlineAdmin)
from cms.admin.views import revert_plugins
from cms.apphook_pool import apphook_pool
from cms.exceptions import NoPermissionsException
from cms.forms.widgets import PluginEditor
-from cms.models import Page, Title, CMSPlugin, PagePermission, \
- PageModeratorState, EmptyTitle, GlobalPagePermission
+from cms.models import (Page, Title, CMSPlugin, PagePermission,
+ PageModeratorState, EmptyTitle, GlobalPagePermission)
from cms.models.managers import PagePermissionsPermissionManager
from cms.models.placeholdermodel import Placeholder
from cms.plugin_pool import plugin_pool
-from cms.utils import copy_plugins, helpers, moderator, permissions, plugins, \
- get_template_from_request, get_language_from_request, \
- placeholder as placeholder_utils, admin as admin_utils
+from cms.utils import (copy_plugins, helpers, moderator, permissions, plugins,
+ get_template_from_request, get_language_from_request,
+ placeholder as placeholder_utils, admin as admin_utils, cms_static_url)
from cms.utils.permissions import has_plugin_permission
from copy import deepcopy
from django import template
@@ -28,20 +28,17 @@
from django.core.urlresolvers import reverse
from django.db import transaction, models
from django.forms import CharField
-from django.http import HttpResponseRedirect, HttpResponse, Http404, \
- HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotAllowed
+from django.http import (HttpResponseRedirect, HttpResponse, Http404,
+ HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotAllowed)
from django.shortcuts import render_to_response, get_object_or_404
from django.template.context import RequestContext
-from django.template.defaultfilters import title, escape, force_escape, \
- escapejs
+from django.template.defaultfilters import (title, escape, force_escape,
+ escapejs)
from django.utils.encoding import force_unicode
-from django.utils.translation import ugettext_lazy as _
-from django.utils.translation import ugettext
+from django.utils.translation import ugettext, ugettext_lazy as _
from menus.menu_pool import menu_pool
import django
import inspect
-import os
-
@@ -164,20 +161,20 @@ class PageAdmin(ModelAdmin):
class Media:
css = {
- 'all': [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
+ 'all': [cms_static_url(path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
)]
}
- js = [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
- 'js/lib/jquery.js',
- 'js/lib/jquery.query.js',
- 'js/lib/ui.core.js',
- 'js/lib/ui.dialog.js',
-
- )]
+ js = ['%sjs/jquery.min.js' % settings.ADMIN_MEDIA_PREFIX] + [cms_static_url(path) for path in [
+ 'js/plugins/admincompat.js',
+ 'js/libs/jquery.query.js',
+ 'js/libs/jquery.ui.core.js',
+ 'js/libs/jquery.ui.dialog.js',
+ ]
+ ]
def get_urls(self):
@@ -4,38 +4,39 @@
from cms.models.placeholdermodel import Placeholder
from cms.models.pluginmodel import CMSPlugin
from cms.plugin_pool import plugin_pool
-from cms.utils import get_language_from_request
+from cms.utils import get_language_from_request, cms_static_url
from cms.utils.permissions import has_plugin_permission
from copy import deepcopy
from django.conf import settings
from django.contrib.admin import ModelAdmin
-from django.http import HttpResponse, Http404, HttpResponseBadRequest, HttpResponseForbidden
+from django.http import (HttpResponse, Http404, HttpResponseBadRequest,
+ HttpResponseForbidden)
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.template.defaultfilters import force_escape, escapejs
from django.utils.translation import ugettext as _
-import os
class PlaceholderAdmin(ModelAdmin):
class Media:
css = {
- 'all': [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
+ 'all': [cms_static_url(path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
'css/plugin_editor.css',
)]
}
- js = [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
- 'js/lib/jquery.js',
- 'js/csrf.js',
- 'js/lib/jquery.query.js',
- 'js/lib/ui.core.js',
- 'js/lib/ui.dialog.js',
- )]
+ js = ['%sjs/jquery.min.js' % settings.ADMIN_MEDIA_PREFIX] + [cms_static_url(path) for path in [
+ 'js/plugins/admincompat.js',
+ 'js/csrf.js',
+ 'js/libs/jquery.query.js',
+ 'js/libs/jquery.ui.core.js',
+ 'js/libs/jquery.ui.dialog.js',
+ ]
+ ]
def get_fieldsets(self, request, obj=None):
"""
View
@@ -3,6 +3,7 @@
from cms.toolbar.constants import LEFT, RIGHT
from cms.toolbar.items import (Anchor, Switcher, TemplateHTML, ListItem, List,
GetButton)
+from cms.utils import cms_static_url
from cms.utils.moderator import page_moderator_state, I_APPROVE
from django import forms
from django.conf import settings
@@ -124,7 +125,7 @@ def get_items(self, context, **kwargs):
items.append(
GetButton(RIGHT, 'logout', _('Logout'), '?cms-toolbar-logout',
- 'cms/images/toolbar/icons/icon_lock.png')
+ cms_static_url('images/toolbar/icons/icon_lock.png'))
)
elif not self.request.user.is_authenticated():
items.append(
@@ -133,7 +134,7 @@ def get_items(self, context, **kwargs):
else:
items.append(
GetButton(RIGHT, 'logout', _('Logout'), '?cms-toolbar-logout',
- 'cms/images/toolbar/icons/icon_lock.png')
+ cms_static_url('images/toolbar/icons/icon_lock.png'))
)
return items
@@ -158,26 +159,27 @@ def get_page_menu(self, context, can_change, is_staff):
menu_items = [
ListItem('overview', _('Move/add Pages'),
reverse('admin:cms_page_changelist'),
- icon='cms/images/toolbar/icons/icon_sitemap.png'),
+ icon=cms_static_url('images/toolbar/icons/icon_sitemap.png')),
]
menu_items.append(
ListItem('addchild', _('Add child page'),
_get_add_child_url,
- icon='cms/images/toolbar/icons/icon_child.png')
+ icon=cms_static_url('images/toolbar/icons/icon_child.png'))
)
menu_items.append(
ListItem('addsibling', _('Add sibling page'),
_get_add_sibling_url,
- icon='cms/images/toolbar/icons/icon_sibling.png')
+ icon=cms_static_url('images/toolbar/icons/icon_sibling.png'))
)
menu_items.append(
ListItem('delete', _('Delete Page'), _get_delete_url,
- icon='cms/images/toolbar/icons/icon_delete.png')
+ icon=cms_static_url('images/toolbar/icons/icon_delete.png'))
)
return List(RIGHT, 'page', _('Page'),
- 'cms/images/toolbar/icons/icon_page.png', items=menu_items)
+ cms_static_url('images/toolbar/icons/icon_page.png'),
+ items=menu_items)
def get_admin_menu(self, context, can_change, is_staff):
"""
@@ -186,21 +188,22 @@ def get_admin_menu(self, context, can_change, is_staff):
admin_items = [
ListItem('admin', _('Site Administration'),
reverse('admin:index'),
- icon='cms/images/toolbar/icons/icon_admin.png'),
+ icon=cms_static_url('images/toolbar/icons/icon_admin.png')),
]
if can_change:
admin_items.append(
ListItem('settings', _('Page Settings'),
_get_page_admin_url,
- icon='cms/images/toolbar/icons/icon_page.png')
+ icon=cms_static_url('images/toolbar/icons/icon_page.png'))
)
if 'reversion' in settings.INSTALLED_APPS:
admin_items.append(
ListItem('history', _('View History'),
_get_page_history_url,
- icon='cms/images/toolbar/icons/icon_history.png')
+ icon=cms_static_url('images/toolbar/icons/icon_history.png'))
)
- return List(RIGHT, 'admin', _('Admin'), 'cms/images/toolbar/icons/icon_admin.png',
+ return List(RIGHT, 'admin', _('Admin'),
+ cms_static_url('images/toolbar/icons/icon_admin.png'),
items=admin_items)
def request_hook(self):
@@ -216,11 +219,12 @@ def _request_hook_get(self):
def _request_hook_post(self):
# login hook
- login_form = CMSToolbarLoginForm(self.request.POST)
- if login_form.is_valid():
- username = login_form.cleaned_data['cms_username']
- password = login_form.cleaned_data['cms_password']
- user = authenticate(username=username, password=password)
- if user:
- login(self.request, user)
- self.init()
+ if 'cms-toolbar-login' in self.request.GET:
+ login_form = CMSToolbarLoginForm(self.request.POST)
+ if login_form.is_valid():
+ username = login_form.cleaned_data['cms_username']
+ password = login_form.cleaned_data['cms_password']
+ user = authenticate(username=username, password=password)
+ if user:
+ login(self.request, user)
+ self.init()
View
@@ -2,7 +2,7 @@
from cms.forms.utils import get_site_choices, get_page_choices
from cms.models import Page, PageUser, Placeholder
from cms.plugin_pool import plugin_pool
-from cms.utils import get_language_from_request
+from cms.utils import get_language_from_request, cms_static_url
from django.conf import settings
from django.contrib.sites.models import Site
from django.forms.widgets import Select, MultiWidget, Widget
@@ -11,7 +11,6 @@
from django.utils.encoding import force_unicode
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
-from os.path import join
import copy
class PageSelectWidget(MultiWidget):
@@ -130,13 +129,12 @@ def __init__(self, attrs=None):
self.attrs = {}
class Media:
- js = [join(settings.CMS_MEDIA_URL, path) for path in (
- 'js/lib/ui.core.js',
- 'js/lib/ui.sortable.js',
- 'js/plugin_editor.js',
+ js = [cms_static_url(path) for path in (
+ 'js/libs/jquery.ui.core.js',
+ 'js/libs/jquery.ui.sortable.js',
)]
css = {
- 'all': [join(settings.CMS_MEDIA_URL, path) for path in (
+ 'all': [cms_static_url(path) for path in (
'css/plugin_editor.css',
)]
}
@@ -217,4 +215,4 @@ def render(self, name, value, attrs=None):
#return mark_safe(render_to_string(
# 'admin/cms/page/widgets/plugin_editor.html', context))
return mark_safe(render_to_string(
- 'admin/cms/page/widgets/placeholder_editor.html', context, RequestContext(self.request)))
+ 'admin/cms/page/widgets/placeholder_editor.html', context, RequestContext(self.request)))
@@ -14,12 +14,22 @@ class Command(SubcommandsCommand):
make_option('--noinput', action='store_false', dest='interactive', default=True,
help='Tells django-cms to NOT prompt the user for input of any kind. '),
)
+
+ args = '<subcommand>'
command_name = 'cms'
- help = 'Various django-cms commands'
subcommands = {
'uninstall': UninstallCommand,
'list': ListCommand,
'moderator': ModeratorCommand,
- }
+ }
+
+ @property
+ def help(self):
+ lines = ['django CMS command line interface.', '', 'Available subcommands:']
+ for subcommand in sorted(self.subcommands.keys()):
+ lines.append(' %s' % subcommand)
+ lines.append('')
+ lines.append('Use `manage.py cms <subcommand> --help` for help about subcommands')
+ return '\n'.join(lines)
@@ -9,9 +9,9 @@ class ListApphooksCommand(NoArgsCommand):
help = 'Lists all apphooks in pages'
def handle_noargs(self, **options):
- urls = Title.objects.values_list("application_urls", flat=True)
+ urls = Title.objects.filter(application_urls__gt='').values_list("application_urls", flat=True)
for url in urls:
- self.stdout.write(url+'\n')
+ self.stdout.write('%s\n' % url)
class ListPluginsCommand(NoArgsCommand):
Oops, something went wrong.

0 comments on commit 6bf136d

Please sign in to comment.