fix the issue regarding the unban button

This commit is contained in:
Régis Hanol 2013-03-21 01:25:41 +01:00
parent 8b6dbfc1c6
commit ad8d078c87
2 changed files with 36 additions and 41 deletions

View file

@ -71,15 +71,18 @@ Discourse.AdminUser = Discourse.Model.extend({
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
}).property('trust_level'),
isBanned: (function() {
return this.get('is_banned') === true;
}).property('is_banned'),
canBan: (function() {
return !this.admin && !this.moderator;
return !this.get('admin') && !this.get('moderator');
}).property('admin', 'moderator'),
banDuration: (function() {
var banned_at, banned_till;
banned_at = Date.create(this.banned_at);
banned_till = Date.create(this.banned_till);
return "" + (banned_at.short()) + " - " + (banned_till.short());
var banned_at = Date.create(this.banned_at);
var banned_till = Date.create(this.banned_till);
return banned_at.short() + " - " + banned_till.short();
}).property('banned_till', 'banned_at'),
ban: function() {
@ -94,10 +97,7 @@ Discourse.AdminUser = Discourse.Model.extend({
window.location.reload();
},
error: function(e) {
var error;
error = Em.String.i18n('admin.user.ban_failed', {
error: "http: " + e.status + " - " + e.body
});
var error = Em.String.i18n('admin.user.ban_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
}
});
@ -113,10 +113,7 @@ Discourse.AdminUser = Discourse.Model.extend({
window.location.reload();
},
error: function(e) {
var error;
error = Em.String.i18n('admin.user.unban_failed', {
error: "http: " + e.status + " - " + e.body
});
var error = Em.String.i18n('admin.user.unban_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
}
});

View file

@ -106,16 +106,14 @@
</div>
<div class='display-row'>
<div class='field'>{{i18n admin.user.banned}}</div>
<div class='value'>{{content.is_banned}}</div>
<div class='value'>{{content.isBanned}}</div>
<div class='controls'>
{{#if content.is_banned}}
{{#if content.canBan}}
{{#if content.isBanned}}
<button class='btn' {{action unban target="content"}}>
<i class='icon icon-screenshot'></i>
{{i18n admin.user.unban}}
</button>
{{content.banDuration}}
{{/if}}
{{else}}
{{#if content.canBan}}
<button class='btn' {{action ban target="content"}}>