From 2e2c462a696bff3ebcc04eabced0dbd35076a9a8 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Sun, 11 Dec 2011 22:16:25 +0100 Subject: [PATCH] "type" should be calculated in DecoRegistry --- plone/app/deco/browser/config.py | 9 +++++---- plone/app/deco/resources/js/deco.core.js | 17 +---------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/plone/app/deco/browser/config.py b/plone/app/deco/browser/config.py index 054c521..5667ef0 100644 --- a/plone/app/deco/browser/config.py +++ b/plone/app/deco/browser/config.py @@ -13,13 +13,14 @@ class DecoConfigView(BrowserView): - def obtain_type(self): + # TODO: this should move to DecoRegistry + def _type(self): """ Obtains the type of the context object or of the object we are adding. """ - if 'type' in self.request.form: - return self.request.form['type'] + if '++add++' in self.request.getURL(): + return self.request.getURL().split('++add++')[1] else: if hasattr(self.context, 'portal_type'): @@ -31,7 +32,7 @@ def obtain_type(self): def config(self): registry = IDecoRegistry(getUtility(IRegistry)) config = registry(**{ - 'type': self.obtain_type(), + 'type': self.type(), 'context': self.context, 'request': self.request, }) diff --git a/plone/app/deco/resources/js/deco.core.js b/plone/app/deco/resources/js/deco.core.js index 5d187f5..52960f4 100644 --- a/plone/app/deco/resources/js/deco.core.js +++ b/plone/app/deco/resources/js/deco.core.js @@ -78,25 +78,10 @@ immed: true, strict: true, maxlen: 80, maxerr: 9999 */ // Set document $.deco.document = window.parent.document; - // Get the url of the page - var match = $.deco.options.url.match(/^([\w#!:.?+=&%@!\-\/]+)\/edit$/); - if (match) { - $.deco.options.url = match[1]; - } - - // Chop add - match = $.deco.options.url.match(/^([\w#:.?=%@!\-\/]+)\/\+\+add\+\+([\w#!:.?+=&%@!\-\/]+)$/); - if (match) { - $.deco.options.url = match[1]; - $.deco.options.type = match[2]; - $.deco.options.ignore_context = true; - } - // Get the configuration from the backend $.ajax({ type: "GET", - url: $.deco.options.url + "/@@deco-config" + - ($.deco.options.type === '' ? '' : "?type=" + $.deco.options.type), + url: $.deco.options.url + "/@@deco-config", success: function (configdata) { // Add global options