From b55e406f93df3889abfcd00a58e7a9db2a2a3ecc Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 16 Nov 2013 11:07:55 -0500 Subject: [PATCH] Display deactivated users at the bottom of the admin users page. (imported from commit 1a5d5d64fffc9ed7633d468b975dd56c28f85ccf) --- static/js/admin.js | 35 ++++++++++++++++----- static/templates/admin_user_list.handlebars | 6 ++++ templates/zerver/administration.html | 8 +++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/static/js/admin.js b/static/js/admin.js index 43d1ac1c28..86eb89cd4b 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -2,36 +2,55 @@ var admin = (function () { var exports = {}; -function populate_users () { +function populate_users (realm_people_data) { var users_table = $("#admin_users_table"); + var deactivated_users_table = $("#admin_deactivated_users_table"); var bots_table = $("#admin_bots_table"); users_table.empty(); + deactivated_users_table.empty(); bots_table.empty(); - var humans = []; + var active_users = []; + var deactivated_users = []; var bots = []; - - realm_people_dict.each(function (user) { + _.each(realm_people_data.members, function (user) { if (user.is_bot) { bots.push(user); + } else if (user.is_active) { + active_users.push(user); } else { - humans.push(user); + deactivated_users.push(user); } }); - humans = _.sortBy(humans, 'full_name'); + active_users = _.sortBy(active_users, 'full_name'); + deactivated_users = _.sortBy(deactivated_users, 'full_name'); bots = _.sortBy(bots, 'full_name'); _.each(bots, function (user) { bots_table.append(templates.render("admin_user_list", {user: user})); }); - _.each(humans, function (user) { + _.each(active_users, function (user) { users_table.append(templates.render("admin_user_list", {user: user})); }); + _.each(deactivated_users, function (user) { + deactivated_users_table.append(templates.render("admin_user_list", {user: user})); + }); } exports.setup_page = function () { - populate_users(); + function failed_listing(xhr, error) { + ui.report_error("Error listing streams or subscriptions", xhr, $("#subscriptions-status")); + } + + var req = $.ajax({ + type: 'GET', + url: '/json/users', + dataType: 'json', + timeout: 10*1000, + success: populate_users, + error: failed_listing + }); $(".admin_user_table").on("click", ".deactivate", function (e) { e.preventDefault(); diff --git a/static/templates/admin_user_list.handlebars b/static/templates/admin_user_list.handlebars index f1ac41c189..c78002f6e1 100644 --- a/static/templates/admin_user_list.handlebars +++ b/static/templates/admin_user_list.handlebars @@ -7,9 +7,15 @@ {{email}} + {{#if is_active}} + {{else}} + + {{/if}} {{/with}} diff --git a/templates/zerver/administration.html b/templates/zerver/administration.html index c44aa1ff7f..88fde33451 100644 --- a/templates/zerver/administration.html +++ b/templates/zerver/administration.html @@ -20,6 +20,14 @@ Actions +

Deactivated Users

+ + + + + + +
NameEmailActions