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