Display deactivated users at the bottom of the admin users page.

(imported from commit 1a5d5d64fffc9ed7633d468b975dd56c28f85ccf)
This commit is contained in:
Tim Abbott
2013-11-16 11:07:55 -05:00
parent a78ec1d0d3
commit b55e406f93
3 changed files with 41 additions and 8 deletions

View File

@@ -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();