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
app/assets/javascripts/admin

View file

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

View file

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