2013-11-01 10:47:03 -04:00
|
|
|
/**
|
|
|
|
The modal for banning a user.
|
|
|
|
|
|
|
|
@class AdminBanUserController
|
|
|
|
@extends Discourse.Controller
|
|
|
|
@namespace Discourse
|
|
|
|
@uses Discourse.ModalFunctionality
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.AdminBanUserController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
ban: function() {
|
|
|
|
var duration = parseInt(this.get('duration'), 10);
|
|
|
|
if (duration > 0) {
|
2013-11-01 12:13:09 -04:00
|
|
|
var self = this;
|
|
|
|
this.send('hideModal');
|
2013-11-01 10:47:03 -04:00
|
|
|
this.get('model').ban(duration, this.get('reason')).then(function() {
|
|
|
|
window.location.reload();
|
|
|
|
}, function(e) {
|
|
|
|
var error = I18n.t('admin.user.ban_failed', { error: "http: " + e.status + " - " + e.body });
|
2013-11-01 12:13:09 -04:00
|
|
|
bootbox.alert(error, function() { self.send('showModal'); });
|
2013-11-01 10:47:03 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|