Merge pull request #2508 from TracksApp/order_user_list

Allow changing the ordering of the user list
This commit is contained in:
Jyri-Petteri Paloposki 2020-10-23 01:03:50 +03:00 committed by GitHub
commit b9a5ab8b4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 13 deletions

View file

@ -7,16 +7,20 @@ class UsersController < ApplicationController
# GET /users GET /users.xml
def index
respond_to do |format|
order_by = 'login'
if params[:order] && User.column_names.include?(params[:order])
order_by = params[:order]
end
format.html do
@page_title = "TRACKS::Manage Users"
@users = User.order('login ASC').paginate :page => params[:page]
@page_title = t('users.manage_users_title')
@users = User.order(order_by + ' ASC').paginate :page => params[:page]
@total_users = User.count
# When we call users/signup from the admin page we store the URL so that
# we get returned here when signup is successful
store_location
end
format.xml do
@users = User.order('login')
@users = User.order(order_by)
render :xml => @users.to_xml(:root => :users, :except => [:password])
end
end

View file

@ -4,24 +4,24 @@
<table class="users_table">
<tr>
<th><%= User.human_attribute_name('login') %></th>
<th><%= User.human_attribute_name('display_name') %></th>
<th><%= User.human_attribute_name('email') %></th>
<th><%= User.human_attribute_name('auth_type') %></th>
<th><%= User.human_attribute_name('open_id_url') %></th>
<th><%= link_to User.human_attribute_name('login'), url_for(:order => 'login') %></th>
<th><%= h User.human_attribute_name('display_name') %></th>
<th><%= link_to User.human_attribute_name('email'), url_for(:order => 'email') %></th>
<th><%= link_to User.human_attribute_name('auth_type'), url_for(:order => 'auth_type') %></th>
<th><%= link_to User.human_attribute_name('open_id_url'), url_for(:order => 'open_id_url') %></th>
<th><%= t('users.total_actions') %></th>
<th><%= t('users.total_contexts') %></th>
<th><%= t('users.total_projects') %></th>
<th><%= t('users.total_notes') %></th>
<th><%= User.human_attribute_name('created_at') %></th>
<th><%= User.human_attribute_name('last_login_at') %></th>
<th><%= link_to User.human_attribute_name('created_at'), url_for(:order => 'created_at') %></th>
<th><%= link_to User.human_attribute_name('last_login_at'), url_for(:order => 'last_login_at') %></th>
<th>&nbsp;</th>
</tr>
<% for user in @users %>
<tr <%= "class=\"highlight\"" if user.is_admin? %> id="user-<%= user.id %>">
<td><%=h user.login %></td>
<td><%=h user.display_name %></td>
<td><%=h user.email %></td>
<td><%= h user.login %></td>
<td><%= h user.display_name %></td>
<td><%= h user.email %></td>
<td><%= h user.auth_type %></td>
<td><%= h user.open_id_url || '-' %></td>
<td><%= h user.todos.size %></td>

View file

@ -1091,6 +1091,7 @@ en:
identity_url: Identity URL
label_auth_type: Authentication type
manage_users: Manage users
manage_users_title: TRACKS::Manage Users
new_password_label: New password
new_token_generated: New token successfully generated
new_user_heading: 'Sign up a new user:'

View file

@ -1091,6 +1091,7 @@ fi:
identity_url: Identity URL
label_auth_type: Authentication type
manage_users: Manage users
manage_users_title: TRACKS::Hallitse käyttäjiä
new_password_label: New password
new_token_generated: New token successfully generated
new_user_heading: 'Sign up a new user:'