Permalink
Browse files

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

…ure/toolbar-frontend
  • Loading branch information...
2 parents 1c76e75 + 329df64 commit d9f5a78908df964186790d7b19886535f7a362aa @FinalAngel FinalAngel committed Jun 5, 2011
View
@@ -1,5 +1,6 @@
Current or previous core committers:
+* Angelo Dini
* Chris Glass
* Eric Robitaille
* Jonas Obrist
@@ -18,7 +19,6 @@ Contributors (in alphabetical order):
* Adrián Ribao
* Alberto Paro
* Alessandro Ronchi
-* Angelo Dini
* angular_circle
* Antoni Aloy López
* Arne Gellhaus
View
@@ -2,14 +2,15 @@
from cms.toolbar.base import Toolbar
from cms.toolbar.constants import LEFT, RIGHT
from cms.toolbar.items import (Anchor, Switcher, TemplateHTML, ListItem, List,
- PostButton, GetButton)
+ GetButton)
from cms.utils.moderator import page_moderator_state, I_APPROVE
from django import forms
from django.conf import settings
from django.contrib.auth import authenticate, login, logout
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
+import urllib
def _get_page_admin_url(context, request, **kwargs):
@@ -19,10 +20,21 @@ def _get_page_history_url(context, request, **kwargs):
return reverse('admin:cms_page_history', args=(request.current_page.pk,))
def _get_add_child_url(context, request, **kwargs):
- return '%s?target=%s&position=last-child' % (reverse('admin:cms_page_add'), request.current_page.pk)
+ data = {
+ 'position': 'last-child',
+ 'target': request.current_page.pk,
+ }
+ args = urllib.urlencode(data)
+ return '%s?%s' % (reverse('admin:cms_page_add'), args)
def _get_add_sibling_url(context, request, **kwargs):
- return '%s?target=%s&position=last-child' % (reverse('admin:cms_page_add'), request.current_page.parent.pk)
+ data = {
+ 'position': 'last-child',
+ }
+ if request.current_page.parent_id:
+ data['target'] = request.current_page.parent_id
+ args = urllib.urlencode(data)
+ return '%s?%s' % (reverse('admin:cms_page_add'), args)
def _get_delete_url(context, request, **kwargs):
return reverse('admin:cms_page_delete', args=(request.current_page.pk,))
@@ -82,7 +94,6 @@ def get_items(self, context, request, **kwargs):
if request.current_page and self.edit_mode:
moderator_state = page_moderator_state(request, request.current_page)
- print moderator_state
should_approve = moderator_state['state'] >= I_APPROVE
has_perms = request.current_page.has_moderate_permission(request)
if should_approve and has_perms:
@@ -137,12 +148,11 @@ def get_page_menu(self, context, request, can_change, is_staff):
'cms/images/toolbar/icons/icon_child.png')
)
- if not request.current_page.is_home():
- menu_items.append(
- ListItem('addsibling', _('Add sibling page'),
- _get_add_sibling_url,
- 'cms/images/toolbar/icons/icon_sibling.png')
- )
+ menu_items.append(
+ ListItem('addsibling', _('Add sibling page'),
+ _get_add_sibling_url,
+ 'cms/images/toolbar/icons/icon_sibling.png')
+ )
menu_items.append(
ListItem('delete', _('Delete Page'), _get_delete_url,
@@ -12,8 +12,9 @@
SITE_ID = 1
# Which templates should be used for extracting the placeholders?
+# Empty by default, as we don't impose any rigid requirements on users.
# example: CMS_TEMPLATES = (('base.html', 'default template'),)
-CMS_TEMPLATES = None
+CMS_TEMPLATES = ()
# Should pages be allowed to inherit their parent templates?
CMS_TEMPLATE_INHERITANCE = True
View
@@ -33,7 +33,11 @@ def post_patch_check():
"""Post patch check, just make sure there isn't any misconfiguration. All
the code for checking settings should go here.
"""
- if settings.CMS_TEMPLATES is None:
+
+ # Ensure templates are set, and more than just the inheritance setting.
+ cms_templates_length = len(settings.CMS_TEMPLATES)
+ if (cms_templates_length < 1 or
+ (cms_templates_length == 1 and settings.CMS_TEMPLATES[0][0] == settings.CMS_TEMPLATE_INHERITANCE_MAGIC)):
raise ImproperlyConfigured('Please make sure you specified a CMS_TEMPLATES setting.')
# check if is user middleware installed
@@ -39,9 +39,10 @@
cookies : {},
callback: {
beforemove : function(what, where, position, tree) {
- item_id = what.id.split("page_")[1];
- target_id = where.id.split("page_")[1];
- old_node = what;
+ var old_target, old_position;
+ var item_id = what.id.split("page_")[1];
+ var target_id = where.id.split("page_")[1];
+ var old_node = what;
if($(what).parent().children("li").length > 1){
if($(what).next("li").length){
old_target = $(what).next("li")[0];
@@ -62,8 +63,9 @@
return true;
},
onmove: function(what, where, position, tree){
- item_id = what.id.split("page_")[1];
- target_id = where.id.split("page_")[1];
+ var position;
+ var item_id = what.id.split("page_")[1];
+ var target_id = where.id.split("page_")[1];
if (position == "before") {
position = "left";
}else if (position == "after") {
@@ -75,7 +77,7 @@
},
onchange: function(node, tree){
var url = $(node).find('a.title').attr("href");
- self.location = url;
+ window.location = url;
}
}
};
@@ -104,7 +106,7 @@
// always
$('#loader-message').show();
- callback = s.success || false;
+ var callback = s.success || false;
s.success = function(data, status){
if (callback) {
callback(data, status);
@@ -156,19 +158,20 @@
$('#changelist li').click(function(e) {
// I want a link to check the class
- if(e.target.tagName == 'IMG' || e.target.tagName == 'SPAN')
- var target = e.target.parentNode;
- else
- var target = e.target;
- var jtarget = $(target);
-
+ var target, selected_page, action, id, page_id, view_page_url, admin_base_url, pageId, parent, value, position, target_id, site;
+ if(e.target.tagName == 'IMG' || e.target.tagName == 'SPAN') {
+ target = e.target.parentNode;
+ } else {
+ target = e.target;
+ }
+ var jtarget = $(target);
if(jtarget.hasClass("move")) {
// prepare tree for move / cut paste
- var id = e.target.id.split("move-link-")[1];
+ id = e.target.id.split("move-link-")[1];
if(id==null){
id = e.target.parentNode.id.split("move-link-")[1];
}
- var page_id = id;
+ page_id = id;
selected_page = page_id;
action = "move";
$('span.move-target-container, span.line, a.move-target').show();
@@ -180,7 +183,7 @@
if(jtarget.hasClass("copy")) {
// prepare tree for copy
- var id = e.target.id.split("copy-link-")[1];
+ id = e.target.id.split("copy-link-")[1];
if(id==null){
id = e.target.parentNode.id.split("copy-link-")[1];
}
@@ -191,7 +194,7 @@
}
if(jtarget.hasClass("viewpage")) {
- var view_page_url = $('#' + target.id + '-select').val();
+ view_page_url = $('#' + target.id + '-select').val();
if(view_page_url){
window.open(view_page_url);
}
@@ -206,7 +209,7 @@
$("tr").removeClass("target");
$("#changelist table").removeClass("table-selected");
- var page_id = target.id.split("add-link-")[1];
+ page_id = target.id.split("add-link-")[1];
selected_page = page_id;
action = "add";
$('tr').removeClass("selected");
@@ -223,7 +226,7 @@
// publish
if(jtarget.hasClass("publish-checkbox")) {
- var pageId = jtarget.attr("name").split("status-")[1];
+ pageId = jtarget.attr("name").split("status-")[1];
// if I don't put data in the post, django doesn't get it
reloadItem(jtarget, admin_base_url + "cms/page/" + pageId + "/change-status/", { 1:1 });
e.stopPropagation();
@@ -232,7 +235,7 @@
// in navigation
if(jtarget.hasClass("navigation-checkbox")) {
- var pageId = jtarget.attr("name").split("navigation-")[1];
+ pageId = jtarget.attr("name").split("navigation-")[1];
// if I don't put data in the post, django doesn't get it
reloadItem(jtarget, admin_base_url + "cms/page/" + pageId + "/change-navigation/", { 1:1 });
e.stopPropagation();
@@ -241,7 +244,7 @@
// moderation
if(jtarget.hasClass("moderator-checkbox")) {
- var pageId = jtarget.parents('li[id^=page_]').attr('id').split('_')[1];
+ pageId = jtarget.parents('li[id^=page_]').attr('id').split('_')[1];
parent = jtarget.parents('div.col-moderator');
value = 0;
@@ -260,7 +263,7 @@
// quick approve
if(jtarget.hasClass("approve")) {
- var pageId = jtarget.parents('li[id^=page_]').attr('id').split('_')[1];
+ pageId = jtarget.parents('li[id^=page_]').attr('id').split('_')[1];
// just reload the page for now in callback...
// TODO: this must be changed sometimes to reloading just the portion
// of the tree = current node + descendants
@@ -270,13 +273,16 @@
}
if(jtarget.hasClass("move-target")) {
- if(jtarget.hasClass("left"))
- var position = "left";
- if(jtarget.hasClass("right"))
- var position = "right";
- if(jtarget.hasClass("last-child"))
- var position = "last-child";
- var target_id = target.parentNode.id.split("move-target-")[1];
+ if(jtarget.hasClass("left")){
+ position = "left";
+ }
+ if(jtarget.hasClass("right")){
+ position = "right";
+ }
+ if(jtarget.hasClass("last-child")){
+ position = "last-child";
+ }
+ target_id = target.parentNode.id.split("move-target-")[1];
if(action=="move") {
moveTreeItem(null, selected_page, target_id, position, tree);
@@ -335,8 +341,8 @@
var copy_splits = window.location.href.split("copy=");
if(copy_splits.length > 1){
var id = copy_splits[1].split("&")[0];
- selected_page = id;
- action = mark_copy_node(id);
+ var selected_page = id;
+ var action = mark_copy_node(id);
}
// moderation checkboxes over livequery
@@ -357,7 +363,7 @@
};
function _copyTreeItem(item_id, target_id, position, site, options) {
- data = {
+ var data = {
position:position,
target:target_id,
site:site
Oops, something went wrong.

0 comments on commit d9f5a78

Please sign in to comment.