From: Scott Baker Date: Wed, 12 Nov 2014 02:01:34 +0000 (-0800) Subject: use the right REST url when saving a model that has no id X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=93ec93614d04e66bc0b8443fd2ee225b8dd1bb0c;p=plstackapi.git use the right REST url when saving a model that has no id --- diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js index 555d827..b514ff3 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js @@ -29,7 +29,12 @@ if (! window.XOSLIB_LOADED ) { var url = this.attributes.resource_uri; if (!url) { - url = this.urlRoot + this.id; + if (this.id) { + url = this.urlRoot + this.id; + } else { + // this happens when creating a new model. + url = this.urlRoot; + } } if (!url) { @@ -253,14 +258,17 @@ if (! window.XOSLIB_LOADED ) { modelName: "userDeployment"}); this.userDeployments = new this.userDeploymentCollection(); - this.deployment = XOSModel.extend({ urlRoot: DEPLOYMENT_API, modelName: "deployment" }); + this.deployment = XOSModel.extend({ urlRoot: DEPLOYMENT_API, + modelName: "deployment", + defaults: xosdefaults.deployment }); this.deploymentCollection = XOSCollection.extend({ urlRoot: DEPLOYMENT_API, relatedCollections: {"nodes": "deployment", "slivers": "deploymentNetwork", "networkDeployments": "deployment", "userDeployments": "deployment"}, model: this.deployment, modelName: "deployment"}); this.deployments = new this.deploymentCollection(); - this.image = XOSModel.extend({ urlRoot: IMAGE_API, modelName: "image" }); + this.image = XOSModel.extend({ urlRoot: IMAGE_API, + modelName: "image" }); this.imageCollection = XOSCollection.extend({ urlRoot: IMAGE_API, model: this.image, modelName: "image"});