2014-04-29 00:42:38 +04:00
|
|
|
/*global Ghost,Backbone */
|
2013-08-05 21:26:44 +04:00
|
|
|
(function () {
|
2013-09-24 14:46:30 +04:00
|
|
|
'use strict';
|
2013-08-05 21:26:44 +04:00
|
|
|
|
2013-11-23 01:47:03 +04:00
|
|
|
Ghost.Models.User = Ghost.ProgressModel.extend({
|
2014-04-29 00:42:38 +04:00
|
|
|
url: Ghost.paths.apiRoot + '/users/me/',
|
|
|
|
|
|
|
|
parse: function (resp) {
|
|
|
|
// unwrap user from {users: [{...}]}
|
|
|
|
if (resp.users) {
|
|
|
|
resp = resp.users[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp;
|
|
|
|
},
|
|
|
|
|
|
|
|
sync: function (method, model, options) {
|
|
|
|
// wrap user in {users: [{...}]}
|
|
|
|
if (method === 'create' || method === 'update') {
|
|
|
|
options.data = JSON.stringify({users: [this.attributes]});
|
|
|
|
options.contentType = 'application/json';
|
|
|
|
}
|
|
|
|
|
|
|
|
return Backbone.Model.prototype.sync.apply(this, arguments);
|
|
|
|
}
|
2013-08-05 21:26:44 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// Ghost.Collections.Users = Backbone.Collection.extend({
|
2013-11-27 06:00:55 +04:00
|
|
|
// url: Ghost.paths.apiRoot + '/users/'
|
2013-08-05 21:26:44 +04:00
|
|
|
// });
|
|
|
|
|
2013-08-09 05:22:49 +04:00
|
|
|
}());
|