2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
Handles routes related to users in the admin section.
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-05-08 01:30:12 +08:00
|
|
|
@class AdminUserRoute
|
2013-02-23 04:41:12 +08:00
|
|
|
@extends Discourse.Route
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
2013-07-17 01:24:59 +08:00
|
|
|
Discourse.AdminUserRoute = Discourse.Route.extend({
|
2013-06-06 00:40:06 +08:00
|
|
|
|
2014-03-19 14:32:27 +08:00
|
|
|
serialize: function(model) {
|
|
|
|
return { username: model.get('username').toLowerCase() };
|
2013-05-08 01:30:12 +08:00
|
|
|
},
|
|
|
|
|
2013-06-06 00:40:06 +08:00
|
|
|
model: function(params) {
|
|
|
|
return Discourse.AdminUser.find(Em.get(params, 'username').toLowerCase());
|
2013-05-15 00:03:15 +08:00
|
|
|
},
|
|
|
|
|
2013-06-06 00:40:06 +08:00
|
|
|
renderTemplate: function() {
|
2013-06-04 04:12:24 +08:00
|
|
|
this.render({into: 'admin/templates/admin'});
|
2013-06-14 01:46:50 +08:00
|
|
|
},
|
|
|
|
|
2013-07-17 01:24:59 +08:00
|
|
|
afterModel: function(adminUser) {
|
|
|
|
var controller = this.controllerFor('adminUser');
|
|
|
|
|
2014-07-15 21:48:02 +08:00
|
|
|
Discourse.Group.findAll().then(function(groups){
|
|
|
|
controller.set("availableGroups", groups.filterBy("automatic", false));
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
2014-02-11 05:59:36 +08:00
|
|
|
return adminUser.loadDetails().then(function () {
|
2013-07-17 01:24:59 +08:00
|
|
|
adminUser.setOriginalTrustLevel();
|
|
|
|
controller.set('model', adminUser);
|
2014-02-11 05:59:36 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
controller.setProperties({
|
|
|
|
originalPrimaryGroupId: model.get('primary_group_id'),
|
|
|
|
model: model
|
2013-07-17 01:24:59 +08:00
|
|
|
});
|
2013-11-01 22:47:03 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2013-11-08 02:53:32 +08:00
|
|
|
showSuspendModal: function(user) {
|
|
|
|
Discourse.Route.showModal(this, 'admin_suspend_user', user);
|
|
|
|
this.controllerFor('modal').set('modalClass', 'suspend-user-modal');
|
2013-11-01 22:47:03 +08:00
|
|
|
}
|
2013-05-15 00:49:15 +08:00
|
|
|
}
|
2013-05-15 00:03:15 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|
2014-01-23 06:09:56 +08:00
|
|
|
|
|
|
|
Discourse.AdminUserIndexRoute = Discourse.Route.extend({
|
|
|
|
setupController: function(c) {
|
|
|
|
c.set('model', this.controllerFor('adminUser').get('model'));
|
|
|
|
}
|
|
|
|
});
|