0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Move to new API format for Settings.

refs #2606
- Use new API format when updating settings from the client side
- Add additional test to test new API format
- Adjust functional tests to work with the new format
This commit is contained in:
Fabian Becker 2014-05-06 18:52:11 +00:00
parent fc667832c3
commit 6647b57164

View file

@ -1,4 +1,4 @@
/*global Ghost, _ */ /*global Backbone, Ghost, _ */
(function () { (function () {
'use strict'; 'use strict';
//id:0 is used to issue PUT requests //id:0 is used to issue PUT requests
@ -14,6 +14,19 @@
}, {}); }, {});
return result; return result;
},
sync: function (method, model, options) {
var settings = _.map(this.attributes, function (value, key) {
return { key: key, value: value };
});
//wrap settings in {settings: [{...}]}
if (method === 'update') {
options.data = JSON.stringify({settings: settings});
options.contentType = 'application/json';
}
return Backbone.Model.prototype.sync.apply(this, arguments);
} }
}); });