FEATURE: Anonymize User. A way to remove a user but keep their topics and posts.
This commit is contained in:
@@ -328,6 +328,48 @@ Discourse.AdminUser = Discourse.User.extend({
|
||||
});
|
||||
},
|
||||
|
||||
anonymizeForbidden: Em.computed.not("can_be_anonymized"),
|
||||
|
||||
anonymize: function() {
|
||||
var user = this;
|
||||
|
||||
var performAnonymize = function() {
|
||||
Discourse.ajax("/admin/users/" + user.get('id') + '/anonymize.json', {type: 'PUT'}).then(function(data) {
|
||||
if (data.success) {
|
||||
bootbox.alert(I18n.t("admin.user.anonymize_successful"));
|
||||
if (data.username) {
|
||||
document.location = "/admin/users/" + data.username;
|
||||
} else {
|
||||
document.location = "/admin/users/list/active";
|
||||
}
|
||||
} else {
|
||||
bootbox.alert(I18n.t("admin.user.anonymize_failed"));
|
||||
if (data.user) {
|
||||
user.setProperties(data.user);
|
||||
}
|
||||
}
|
||||
}, function() {
|
||||
bootbox.alert(I18n.t("admin.user.anonymize_failed"));
|
||||
});
|
||||
};
|
||||
|
||||
var message = I18n.t("admin.user.anonymize_confirm");
|
||||
|
||||
var buttons = [{
|
||||
"label": I18n.t("composer.cancel"),
|
||||
"class": "cancel",
|
||||
"link": true
|
||||
}, {
|
||||
"label": '<i class="fa fa-exclamation-triangle"></i>' + I18n.t('admin.user.anonymize_yes'),
|
||||
"class": "btn btn-danger",
|
||||
"callback": function(){
|
||||
performAnonymize();
|
||||
}
|
||||
}];
|
||||
|
||||
bootbox.dialog(message, buttons, {"classes": "delete-user-modal"});
|
||||
},
|
||||
|
||||
deleteForbidden: Em.computed.not("canBeDeleted"),
|
||||
|
||||
deleteExplanation: function() {
|
||||
|
||||
@@ -450,6 +450,11 @@
|
||||
|
||||
<section>
|
||||
<hr/>
|
||||
<button {{bind-attr class=":btn :btn-danger :pull-right anonymizeForbidden:hidden"}} {{action "anonymize" target="content"}} {{bind-attr disabled="anonymizeForbidden"}}>
|
||||
<i class="fa fa-exclamation-triangle"></i>
|
||||
{{i18n 'admin.user.anonymize'}}
|
||||
</button>
|
||||
|
||||
<button {{bind-attr class=":btn :btn-danger :pull-right deleteForbidden:hidden"}} {{action "destroy" target="content"}} {{bind-attr disabled="deleteForbidden"}}>
|
||||
<i class="fa fa-exclamation-triangle"></i>
|
||||
{{i18n 'admin.user.delete'}}
|
||||
|
||||
Reference in New Issue
Block a user