From fd415c376a89fd3002004e62337c0d3303bb2acc Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sun, 27 Apr 2014 18:28:50 -0500 Subject: [PATCH] Settings API Primary Document refactor Closes #2606 - Refactor settings api responses to { settings: [ ] } format - Update all code using api.settings to handle new response format - Update test stubs to return new format - Update client site settings model to parse new format into one object of key/value pairs - Refactor to include all setting values - Remove unused settingsCollection method - Update settingsCache to store all attributes - Update settingsResult to send all attributes - Remove unnecessary when() wraps - Reject if editing a setting that doesn't exist - Reject earlier if setting key is empty - Update tests with new error messages - Use setting.add instead of edit that was incorrectly adding - Update importer to properly import activePlugins and installedPlugins - Update expected setting result fields - Fix a weird situation where hasOwnProperty didn't exist :shrug: --- ghost/admin/models/settings.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ghost/admin/models/settings.js b/ghost/admin/models/settings.js index f5b2c93710..8ffe3ec7b5 100644 --- a/ghost/admin/models/settings.js +++ b/ghost/admin/models/settings.js @@ -1,10 +1,20 @@ -/*global Ghost */ +/*global Ghost, _ */ (function () { 'use strict'; //id:0 is used to issue PUT requests Ghost.Models.Settings = Ghost.ProgressModel.extend({ url: Ghost.paths.apiRoot + '/settings/?type=blog,theme,app', - id: '0' + id: '0', + + parse: function (response) { + var result = _.reduce(response.settings, function (settings, setting) { + settings[setting.key] = setting.value; + + return settings; + }, {}); + + return result; + } }); }());