From ad8d078c871c80d3f2f8a3664a75ce98008bf9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 21 Mar 2013 01:25:41 +0100 Subject: [PATCH] fix the issue regarding the unban button --- .../javascripts/admin/models/admin_user.js | 23 ++++---- .../admin/templates/user.js.handlebars | 54 +++++++++---------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index 1bc09ddb9..0afcbb130 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -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); } }); diff --git a/app/assets/javascripts/admin/templates/user.js.handlebars b/app/assets/javascripts/admin/templates/user.js.handlebars index ca6832ca9..e38d63089 100644 --- a/app/assets/javascripts/admin/templates/user.js.handlebars +++ b/app/assets/javascripts/admin/templates/user.js.handlebars @@ -8,13 +8,13 @@ {{i18n admin.user.show_public_profile}} - + {{#if content.can_impersonate}} - {{/if}} + {{/if}}
@@ -44,21 +44,21 @@
{{i18n admin.users.approved}}
{{#if content.approved}} - {{i18n admin.user.approved_by}} + {{i18n admin.user.approved_by}} {{avatar approved_by imageSize="small"}} {{content.approved_by.username}} {{else}} {{i18n no_value}} {{/if}} - +
- {{#if content.can_approve}} + {{#if content.can_approve}} - {{/if}} + {{/if}}
@@ -66,7 +66,7 @@
{{i18n admin.user.admin}}
{{content.admin}}
- {{#if content.can_revoke_admin}} + {{#if content.can_revoke_admin}} - {{/if}} + {{/if}}
@@ -85,7 +85,7 @@
{{i18n admin.user.moderator}}
{{content.moderator}}
- {{#if content.can_revoke_moderation}} + {{#if content.can_revoke_moderation}} - {{/if}} + {{/if}}
- +
{{i18n trust_level}}
{{content.trustLevel.name}}
-
+
{{i18n admin.user.banned}}
-
{{content.is_banned}}
+
{{content.isBanned}}
- {{#if content.is_banned}} - {{#if content.canBan}} - - {{content.banDuration}} - {{/if}} + {{#if content.isBanned}} + + {{content.banDuration}} {{else}} {{#if content.canBan}}
-
+
@@ -150,7 +148,7 @@
{{i18n admin.user.topics_entered}}
{{content.topics_entered}}
-
+
{{i18n admin.user.post_count}}
{{content.post_count}}
@@ -166,15 +164,15 @@
{{i18n admin.user.posts_read_count}}
{{content.posts_read_count}}
-
+
{{i18n admin.user.flags_given_count}}
{{content.flags_given_count}}
-
+
{{i18n admin.user.flags_received_count}}
{{content.flags_received_count}}
-
+
{{i18n admin.user.private_topics_count}}
{{content.private_topics_count}}
@@ -182,10 +180,10 @@
{{i18n admin.user.time_read}}
{{{content.time_read}}}
-
+
{{i18n user.invited.days_visited}}
{{{content.days_visited}}}
-
+