##// END OF EJS Templates
Adds user count in status drop down on admin user list....
Jean-Philippe Lang -
r1734:41d44c5285a7
parent child
Show More
@@ -1,57 +1,58
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module UsersHelper
18 module UsersHelper
19 def status_options_for_select(selected)
19 def users_status_options_for_select(selected)
20 user_count_by_status = User.count(:group => 'status').to_hash
20 options_for_select([[l(:label_all), ''],
21 options_for_select([[l(:label_all), ''],
21 [l(:status_active), 1],
22 ["#{l(:status_active)} (#{user_count_by_status[1].to_i})", 1],
22 [l(:status_registered), 2],
23 ["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", 2],
23 [l(:status_locked), 3]], selected)
24 ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", 3]], selected)
24 end
25 end
25
26
26 # Options for the new membership projects combo-box
27 # Options for the new membership projects combo-box
27 def projects_options_for_select(projects)
28 def projects_options_for_select(projects)
28 options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
29 options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
29 projects_by_root = projects.group_by(&:root)
30 projects_by_root = projects.group_by(&:root)
30 projects_by_root.keys.sort.each do |root|
31 projects_by_root.keys.sort.each do |root|
31 options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
32 options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
32 projects_by_root[root].sort.each do |project|
33 projects_by_root[root].sort.each do |project|
33 next if project == root
34 next if project == root
34 options << content_tag('option', '&#187; ' + h(project.name), :value => project.id)
35 options << content_tag('option', '&#187; ' + h(project.name), :value => project.id)
35 end
36 end
36 end
37 end
37 options
38 options
38 end
39 end
39
40
40 def change_status_link(user)
41 def change_status_link(user)
41 url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]}
42 url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]}
42
43
43 if user.locked?
44 if user.locked?
44 link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
45 link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
45 elsif user.registered?
46 elsif user.registered?
46 link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
47 link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
47 elsif user != User.current
48 elsif user != User.current
48 link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
49 link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
49 end
50 end
50 end
51 end
51
52
52 def user_settings_tabs
53 def user_settings_tabs
53 tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
54 tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
54 {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
55 {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
55 ]
56 ]
56 end
57 end
57 end
58 end
@@ -1,44 +1,44
1 <div class="contextual">
1 <div class="contextual">
2 <%= link_to l(:label_user_new), {:action => 'add'}, :class => 'icon icon-add' %>
2 <%= link_to l(:label_user_new), {:action => 'add'}, :class => 'icon icon-add' %>
3 </div>
3 </div>
4
4
5 <h2><%=l(:label_user_plural)%></h2>
5 <h2><%=l(:label_user_plural)%></h2>
6
6
7 <% form_tag({}, :method => :get) do %>
7 <% form_tag({}, :method => :get) do %>
8 <fieldset><legend><%= l(:label_filter_plural) %></legend>
8 <fieldset><legend><%= l(:label_filter_plural) %></legend>
9 <label><%= l(:field_status) %> :</label>
9 <label><%= l(:field_status) %> :</label>
10 <%= select_tag 'status', status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
10 <%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
11 </fieldset>
11 </fieldset>
12 <% end %>
12 <% end %>
13 &nbsp;
13 &nbsp;
14
14
15 <table class="list">
15 <table class="list">
16 <thead><tr>
16 <thead><tr>
17 <%= sort_header_tag('login', :caption => l(:field_login)) %>
17 <%= sort_header_tag('login', :caption => l(:field_login)) %>
18 <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
18 <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
19 <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
19 <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
20 <%= sort_header_tag('mail', :caption => l(:field_mail)) %>
20 <%= sort_header_tag('mail', :caption => l(:field_mail)) %>
21 <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
21 <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
22 <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
22 <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
23 <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
23 <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
24 <th></th>
24 <th></th>
25 </tr></thead>
25 </tr></thead>
26 <tbody>
26 <tbody>
27 <% for user in @users -%>
27 <% for user in @users -%>
28 <tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>">
28 <tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>">
29 <td class="username"><%= link_to h(user.login), :action => 'edit', :id => user %></td>
29 <td class="username"><%= link_to h(user.login), :action => 'edit', :id => user %></td>
30 <td class="firstname"><%= h(user.firstname) %></td>
30 <td class="firstname"><%= h(user.firstname) %></td>
31 <td class="lastname"><%= h(user.lastname) %></td>
31 <td class="lastname"><%= h(user.lastname) %></td>
32 <td class="email"><%= mail_to(h(user.mail)) %></td>
32 <td class="email"><%= mail_to(h(user.mail)) %></td>
33 <td align="center"><%= image_tag('true.png') if user.admin? %></td>
33 <td align="center"><%= image_tag('true.png') if user.admin? %></td>
34 <td class="created_on" align="center"><%= format_time(user.created_on) %></td>
34 <td class="created_on" align="center"><%= format_time(user.created_on) %></td>
35 <td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
35 <td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
36 <td><small><%= change_status_link(user) %></small></td>
36 <td><small><%= change_status_link(user) %></small></td>
37 </tr>
37 </tr>
38 <% end -%>
38 <% end -%>
39 </tbody>
39 </tbody>
40 </table>
40 </table>
41
41
42 <p class="pagination"><%= pagination_links_full @user_pages, @user_count %></p>
42 <p class="pagination"><%= pagination_links_full @user_pages, @user_count %></p>
43
43
44 <% html_title(l(:label_user_plural)) -%>
44 <% html_title(l(:label_user_plural)) -%>
General Comments 0
You need to be logged in to leave comments. Login now