Ghost/ghost/admin/adapters/user.js
Fabian Becker 1325f87671 Fix revoke user invite and user.destroy
fixes #3630
- Extend user adapter in ember to load users with status: all
- Fix user.destroy by loading all users with status: all
2014-08-06 16:48:18 +00:00

45 lines
1.5 KiB
JavaScript

import EmbeddedRelationAdapter from 'ghost/adapters/embedded-relation-adapter';
var UserAdapter = EmbeddedRelationAdapter.extend({
createRecord: function (store, type, record) {
var data = {},
serializer = store.serializerFor(type.typeKey),
url = this.buildURL(type.typeKey);
// Ask the API to include full role objects in its response
url += '?include=roles';
// Use the UserSerializer to transform the model back into
// an array of user objects like the API expects
serializer.serializeIntoHash(data, type, record);
// Use the url from the ApplicationAdapter's buildURL method
return this.ajax(url, 'POST', { data: data });
},
updateRecord: function (store, type, record) {
var data = {},
serializer = store.serializerFor(type.typeKey),
id = Ember.get(record, 'id'),
url = this.buildURL(type.typeKey, id);
// Ask the API to include full role objects in its response
url += '?include=roles';
// Use the UserSerializer to transform the model back into
// an array of user objects like the API expects
serializer.serializeIntoHash(data, type, record);
// Use the url from the ApplicationAdapter's buildURL method
return this.ajax(url, 'PUT', { data: data });
},
find: function (store, type, id) {
var url = this.buildQuery(store, type, id);
url.status = 'all';
return this.findQuery(store, type, url);
}
});
export default UserAdapter;