2013-11-01 10:47:03 -04:00
|
|
|
/**
|
2013-11-07 13:53:32 -05:00
|
|
|
The modal for suspending a user.
|
2013-11-01 10:47:03 -04:00
|
|
|
|
2013-11-07 13:53:32 -05:00
|
|
|
@class AdminSuspendUserController
|
2013-11-01 10:47:03 -04:00
|
|
|
@extends Discourse.Controller
|
|
|
|
@namespace Discourse
|
|
|
|
@uses Discourse.ModalFunctionality
|
|
|
|
@module Discourse
|
|
|
|
**/
|
2013-11-07 13:53:32 -05:00
|
|
|
Discourse.AdminSuspendUserController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
2013-11-01 10:47:03 -04:00
|
|
|
|
|
|
|
actions: {
|
2013-11-07 13:53:32 -05:00
|
|
|
suspend: function() {
|
2013-11-01 10:47:03 -04:00
|
|
|
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-07 13:53:32 -05:00
|
|
|
this.get('model').suspend(duration, this.get('reason')).then(function() {
|
2013-11-01 10:47:03 -04:00
|
|
|
window.location.reload();
|
|
|
|
}, function(e) {
|
2013-11-07 13:53:32 -05:00
|
|
|
var error = I18n.t('admin.user.suspend_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
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|