From a18b58a2f61a8cc4f665bcdf8b24b545b52a405c Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Wed, 30 Jul 2014 17:40:30 +0200 Subject: [PATCH] Transfer ownership end point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #3426 - added transfer ownership endpoint - added owner to roles.permissible - manually removed owner from roles.browse - removed hard coded author role - fixed tests that were passing due to hard coded author role - added testUtils.setup(‚roles‘) --- .../controllers/modals/transfer-owner.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ghost/admin/controllers/modals/transfer-owner.js b/ghost/admin/controllers/modals/transfer-owner.js index c4d1cbf272..5afa0a36d3 100644 --- a/ghost/admin/controllers/modals/transfer-owner.js +++ b/ghost/admin/controllers/modals/transfer-owner.js @@ -2,27 +2,24 @@ var TransferOwnerController = Ember.Controller.extend({ actions: { confirmAccept: function () { var user = this.get('model'), + url = this.get('ghostPaths.url').api('users', 'owner'), self = this; self.get('popover').closePopovers(); - // Get owner role - this.store.find('role').then(function (result) { - return result.findBy('name', 'Owner'); - }).then(function (ownerRole) { - // remove roles and assign owner role - user.get('roles').clear(); - user.get('roles').pushObject(ownerRole); - - return user.saveOnly('roles'); + ic.ajax.request(url, { + type: 'PUT', + data: { + owner: [{ + 'id': user.get('id') + }] + } }).then(function () { self.notifications.closePassive(); self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name')); - }).catch(function (errors) { + }).catch(function (error) { self.notifications.closePassive(); - - errors = Ember.isArray(errors) ? errors : Ember.A([errors]); - self.notifications.showErrors(errors); + self.notifications.showAPIError(error); }); },