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

Fix for image upload with clean database

no issue
- reversed workaround for PUT to model
- changed save function for image to unset availableThemes
This commit is contained in:
Sebastian Gierlinger 2013-09-11 16:37:23 +00:00
parent eadc8b9371
commit cfb83d6e40
2 changed files with 8 additions and 4 deletions

View file

@ -1,9 +1,10 @@
/*global window, document, Ghost, $, _, Backbone */ /*global window, document, Ghost, $, _, Backbone */
(function () { (function () {
"use strict"; "use strict";
//id:0 is used to issue PUT requests
Ghost.Models.Settings = Backbone.Model.extend({ Ghost.Models.Settings = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/settings' url: Ghost.settings.apiRoot + '/settings',
id: "0"
}); });
}()); }());

View file

@ -160,7 +160,6 @@
var themes = this.model.get('availableThemes'); var themes = this.model.get('availableThemes');
this.model.unset('availableThemes'); this.model.unset('availableThemes');
this.model.save({ this.model.save({
id: 0, //workaround to use put
title: this.$('#blog-title').val(), title: this.$('#blog-title').val(),
description: $('#blog-description').val(), description: $('#blog-description').val(),
logo: this.$('#blog-logo').attr("src"), logo: this.$('#blog-logo').attr("src"),
@ -185,12 +184,16 @@
showUpload: function (id, key, src) { showUpload: function (id, key, src) {
var self = this, upload = new Ghost.Models.uploadModal({'id': id, 'key': key, 'src': src, 'accept': { var self = this, upload = new Ghost.Models.uploadModal({'id': id, 'key': key, 'src': src, 'accept': {
func: function () { // The function called on acceptance func: function () { // The function called on acceptance
var data = {}; var data = {},
themes;
data[key] = this.$('.js-upload-target').attr('src'); data[key] = this.$('.js-upload-target').attr('src');
themes = self.model.get('availableThemes');
self.model.unset('availableThemes');
self.model.save(data, { self.model.save(data, {
success: self.saveSuccess, success: self.saveSuccess,
error: self.saveError error: self.saveError
}); });
self.model.set({availableThemes: themes});
self.render(); self.render();
return true; return true;
}, },