2013-05-28 23:52:31 +08:00
|
|
|
/**
|
|
|
|
A controller related to viewing a user in the admin section
|
|
|
|
|
|
|
|
@class AdminUserController
|
|
|
|
@extends Discourse.ObjectController
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
2013-06-26 06:39:20 +08:00
|
|
|
Discourse.AdminUserController = Discourse.ObjectController.extend({
|
|
|
|
editingTitle: false,
|
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
showApproval: function() {
|
|
|
|
return Discourse.SiteSettings.must_approve_users;
|
|
|
|
}.property(),
|
2013-06-26 06:39:20 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
actions: {
|
|
|
|
toggleTitleEdit: function() {
|
|
|
|
this.toggleProperty('editingTitle');
|
|
|
|
},
|
2013-06-26 06:39:20 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
saveTitle: function() {
|
|
|
|
Discourse.ajax("/users/" + this.get('username').toLowerCase(), {
|
|
|
|
data: {title: this.get('title')},
|
|
|
|
type: 'PUT'
|
|
|
|
}).then(null, function(e){
|
|
|
|
bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body}));
|
|
|
|
});
|
|
|
|
|
|
|
|
this.send('toggleTitleEdit');
|
2013-10-23 03:53:08 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
generateApiKey: function() {
|
|
|
|
this.get('model').generateApiKey();
|
|
|
|
},
|
|
|
|
|
|
|
|
regenerateApiKey: function() {
|
|
|
|
var self = this;
|
|
|
|
bootbox.confirm(I18n.t("admin.api.confirm_regen"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
|
|
|
if (result) {
|
|
|
|
self.get('model').generateApiKey();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
revokeApiKey: function() {
|
|
|
|
var self = this;
|
|
|
|
bootbox.confirm(I18n.t("admin.api.confirm_revoke"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
|
|
|
if (result) {
|
|
|
|
self.get('model').revokeApiKey();
|
|
|
|
}
|
|
|
|
});
|
2013-09-17 02:08:55 +08:00
|
|
|
}
|
|
|
|
}
|
2013-09-10 00:21:47 +08:00
|
|
|
|
2013-07-09 07:32:16 +08:00
|
|
|
});
|