Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
"type" should be calculated in DecoRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Dec 11, 2011
1 parent 8f87433 commit 2e2c462
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
9 changes: 5 additions & 4 deletions plone/app/deco/browser/config.py
Expand Up @@ -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'):
Expand All @@ -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,
})
Expand Down
17 changes: 1 addition & 16 deletions plone/app/deco/resources/js/deco.core.js
Expand Up @@ -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
Expand Down

0 comments on commit 2e2c462

Please sign in to comment.