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')); 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

@ -8,13 +8,13 @@
<a href="{{unbound content.path}}" class='btn'> <a href="{{unbound content.path}}" class='btn'>
<i class='icon icon-user'></i> <i class='icon icon-user'></i>
{{i18n admin.user.show_public_profile}} {{i18n admin.user.show_public_profile}}
</a> </a>
{{#if content.can_impersonate}} {{#if content.can_impersonate}}
<button class='btn' {{action impersonate target="content"}}> <button class='btn' {{action impersonate target="content"}}>
<i class='icon icon-screenshot'></i> <i class='icon icon-screenshot'></i>
{{i18n admin.user.impersonate}} {{i18n admin.user.impersonate}}
</button> </button>
{{/if}} {{/if}}
</div> </div>
</div> </div>
<div class='display-row'> <div class='display-row'>
@ -44,21 +44,21 @@
<div class='field'>{{i18n admin.users.approved}}</div> <div class='field'>{{i18n admin.users.approved}}</div>
<div class='value'> <div class='value'>
{{#if content.approved}} {{#if content.approved}}
{{i18n admin.user.approved_by}} {{i18n admin.user.approved_by}}
<a href="{{unbound content.approved_by.adminPath}}">{{avatar approved_by imageSize="small"}}</a> <a href="{{unbound content.approved_by.adminPath}}">{{avatar approved_by imageSize="small"}}</a>
<a href="{{unbound adminPath}}">{{content.approved_by.username}}</a> <a href="{{unbound adminPath}}">{{content.approved_by.username}}</a>
{{else}} {{else}}
{{i18n no_value}} {{i18n no_value}}
{{/if}} {{/if}}
</div> </div>
<div class='controls'> <div class='controls'>
{{#if content.can_approve}} {{#if content.can_approve}}
<button class='btn' {{action approve target="content"}}> <button class='btn' {{action approve target="content"}}>
<i class='icon icon-ok'></i> <i class='icon icon-ok'></i>
{{i18n admin.user.approve}} {{i18n admin.user.approve}}
</button> </button>
{{/if}} {{/if}}
</div> </div>
</div> </div>
@ -66,7 +66,7 @@
<div class='field'>{{i18n admin.user.admin}}</div> <div class='field'>{{i18n admin.user.admin}}</div>
<div class='value'>{{content.admin}}</div> <div class='value'>{{content.admin}}</div>
<div class='controls'> <div class='controls'>
{{#if content.can_revoke_admin}} {{#if content.can_revoke_admin}}
<button class='btn' {{action revokeAdmin target="content"}}> <button class='btn' {{action revokeAdmin target="content"}}>
<i class='icon icon-trophy'></i> <i class='icon icon-trophy'></i>
{{i18n admin.user.revoke_admin}} {{i18n admin.user.revoke_admin}}
@ -77,7 +77,7 @@
<i class='icon icon-trophy'></i> <i class='icon icon-trophy'></i>
{{i18n admin.user.grant_admin}} {{i18n admin.user.grant_admin}}
</button> </button>
{{/if}} {{/if}}
</div> </div>
</div> </div>
@ -85,7 +85,7 @@
<div class='field'>{{i18n admin.user.moderator}}</div> <div class='field'>{{i18n admin.user.moderator}}</div>
<div class='value'>{{content.moderator}}</div> <div class='value'>{{content.moderator}}</div>
<div class='controls'> <div class='controls'>
{{#if content.can_revoke_moderation}} {{#if content.can_revoke_moderation}}
<button class='btn' {{action revokeModeration target="content"}}> <button class='btn' {{action revokeModeration target="content"}}>
<i class='icon icon-eye-close'></i> <i class='icon icon-eye-close'></i>
{{i18n admin.user.revoke_moderation}} {{i18n admin.user.revoke_moderation}}
@ -96,26 +96,24 @@
<i class='icon icon-eye-open'></i> <i class='icon icon-eye-open'></i>
{{i18n admin.user.grant_moderation}} {{i18n admin.user.grant_moderation}}
</button> </button>
{{/if}} {{/if}}
</div> </div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n trust_level}}</div> <div class='field'>{{i18n trust_level}}</div>
<div class='value'>{{content.trustLevel.name}}</div> <div class='value'>{{content.trustLevel.name}}</div>
</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"}}>
@ -125,7 +123,7 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
</div> </div>
</div> </div>
</section> </section>
<section class='details'> <section class='details'>
@ -150,7 +148,7 @@
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.topics_entered}}</div> <div class='field'>{{i18n admin.user.topics_entered}}</div>
<div class='value'>{{content.topics_entered}}</div> <div class='value'>{{content.topics_entered}}</div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.post_count}}</div> <div class='field'>{{i18n admin.user.post_count}}</div>
<div class='value'>{{content.post_count}}</div> <div class='value'>{{content.post_count}}</div>
@ -166,15 +164,15 @@
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.posts_read_count}}</div> <div class='field'>{{i18n admin.user.posts_read_count}}</div>
<div class='value'>{{content.posts_read_count}}</div> <div class='value'>{{content.posts_read_count}}</div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.flags_given_count}}</div> <div class='field'>{{i18n admin.user.flags_given_count}}</div>
<div class='value'>{{content.flags_given_count}}</div> <div class='value'>{{content.flags_given_count}}</div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.flags_received_count}}</div> <div class='field'>{{i18n admin.user.flags_received_count}}</div>
<div class='value'>{{content.flags_received_count}}</div> <div class='value'>{{content.flags_received_count}}</div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.private_topics_count}}</div> <div class='field'>{{i18n admin.user.private_topics_count}}</div>
<div class='value'>{{content.private_topics_count}}</div> <div class='value'>{{content.private_topics_count}}</div>
@ -182,10 +180,10 @@
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n admin.user.time_read}}</div> <div class='field'>{{i18n admin.user.time_read}}</div>
<div class='value'>{{{content.time_read}}}</div> <div class='value'>{{{content.time_read}}}</div>
</div> </div>
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n user.invited.days_visited}}</div> <div class='field'>{{i18n user.invited.days_visited}}</div>
<div class='value'>{{{content.days_visited}}}</div> <div class='value'>{{{content.days_visited}}}</div>
</div> </div>
</section> </section>