admin账户个人主页显示修改
admin账户用户管理功能分离到/admin/users,软件创客功能与普通账户一致
This commit is contained in:
parent
0ec7d6b4e7
commit
6583ccb001
|
@ -23,6 +23,7 @@ class AdminController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
helper :sort
|
helper :sort
|
||||||
|
helper :Users
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -39,6 +40,121 @@ class AdminController < ApplicationController
|
||||||
render :action => "projects", :layout => false if request.xhr?
|
render :action => "projects", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def users
|
||||||
|
@project_type = params[:project_type]
|
||||||
|
role = params[:role]
|
||||||
|
|
||||||
|
sort_init 'login', 'asc'
|
||||||
|
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||||
|
|
||||||
|
case params[:format]
|
||||||
|
when 'xml', 'json'
|
||||||
|
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||||
|
else
|
||||||
|
@limit = 15#per_page_option
|
||||||
|
end
|
||||||
|
|
||||||
|
@status = params[:status] || 1
|
||||||
|
has = {
|
||||||
|
"show_changesets" => true
|
||||||
|
}
|
||||||
|
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||||
|
|
||||||
|
scope = UserStatus.visible
|
||||||
|
case role
|
||||||
|
when 'teacher'
|
||||||
|
scope = UserStatus.teacher
|
||||||
|
when 'student'
|
||||||
|
scope = UserStatus.student
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||||
|
# scope.each do |user|
|
||||||
|
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||||
|
# end
|
||||||
|
@user_count = scope.count
|
||||||
|
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||||
|
#@offset ||= @user_pages.offset
|
||||||
|
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||||
|
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||||
|
if params[:user_sort_type].present?
|
||||||
|
case params[:user_sort_type]
|
||||||
|
when '0'
|
||||||
|
@offset ||= @user_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @user_count % @limit
|
||||||
|
if limit == 0
|
||||||
|
limit = @limit
|
||||||
|
end
|
||||||
|
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
@s_type = 0
|
||||||
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||||
|
# @projects = @projects[@offset, @limit]
|
||||||
|
when '1'
|
||||||
|
@offset ||= @user_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @user_count % @limit
|
||||||
|
if limit == 0
|
||||||
|
limit = @limit
|
||||||
|
end
|
||||||
|
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
@s_type = 1
|
||||||
|
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||||
|
#@users = @users[@offset, @limit]
|
||||||
|
when '2'
|
||||||
|
@offset ||= @user_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @user_count % @limit
|
||||||
|
if limit == 0
|
||||||
|
limit = @limit
|
||||||
|
end
|
||||||
|
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
@s_type = 2
|
||||||
|
#@users = @users[@offset, @limit]
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
@offset ||= @user_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @user_count % @limit
|
||||||
|
if limit == 0
|
||||||
|
limit = @limit
|
||||||
|
end
|
||||||
|
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
@s_type = 1
|
||||||
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||||
|
# @projects = @projects[@offset, @limit]
|
||||||
|
end
|
||||||
|
|
||||||
|
@users = []
|
||||||
|
@users_statuses.each do |obj|
|
||||||
|
@users << User.find_by_id("#{obj.user_id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@groups = Group.all.sort
|
||||||
|
render :layout => @user_base_tag
|
||||||
|
}
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def plugins
|
def plugins
|
||||||
@plugins = Redmine::Plugin.all
|
@plugins = Redmine::Plugin.all
|
||||||
end
|
end
|
||||||
|
|
|
@ -782,7 +782,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_layout(default_base='base_users')
|
def setting_layout(default_base='base_users')
|
||||||
User.current.admin? ? 'base_admin' : default_base
|
User.current.admin? ? default_base : default_base
|
||||||
end
|
end
|
||||||
|
|
||||||
# 必填自己的工作单位,其实就是学校
|
# 必填自己的工作单位,其实就是学校
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
<% if User.current.admin? %>
|
||||||
|
<div class="contextual">
|
||||||
|
<%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3><%= l(:label_user_plural)%></h3>
|
||||||
|
|
||||||
|
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_filter_plural) %>
|
||||||
|
</legend>
|
||||||
|
<label for='status'><%= l(:field_status) %>:</label>
|
||||||
|
<%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
|
||||||
|
|
||||||
|
<% if @groups.present? %>
|
||||||
|
<label for='group_id'><%= l(:label_group) %>:</label>
|
||||||
|
<%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<label for='name'><%= l(:label_user) %>:</label>
|
||||||
|
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||||
|
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="autoscroll">
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<%= sort_header_tag('login', :caption => l(:field_login)) %>
|
||||||
|
<%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
|
||||||
|
<%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
|
||||||
|
<%= sort_header_tag('mail', :caption => l(:field_mail)) %>
|
||||||
|
|
||||||
|
<%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
|
||||||
|
<%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
|
||||||
|
<%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% for user in @users -%>
|
||||||
|
<tr class="<%= user.css_classes %> <%= cycle("odd", "even") %>">
|
||||||
|
<td class="username"><%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %></td>
|
||||||
|
<td class="firstname"><%= h(user.firstname) %></td>
|
||||||
|
<td class="lastname"><%= h(user.lastname) %></td>
|
||||||
|
<td class="email"><%= mail_to(h(user.mail)) %></td>
|
||||||
|
<td align="center"><%= checked_image user.admin? %></td>
|
||||||
|
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
||||||
|
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
||||||
|
<td class="buttons"> <%= change_status_link(user) %>
|
||||||
|
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
||||||
|
</tr>
|
||||||
|
<% end -%>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="pagination">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @user_pages, @user_count %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% html_title(l(:label_user_plural)) -%>
|
||||||
|
<%else %>
|
||||||
|
|
||||||
|
<% end%>
|
|
@ -1,71 +1,3 @@
|
||||||
<% if User.current.admin? %>
|
|
||||||
<div class="contextual">
|
|
||||||
<%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3><%= l(:label_user_plural)%></h3>
|
|
||||||
|
|
||||||
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
|
||||||
<fieldset>
|
|
||||||
<legend>
|
|
||||||
<%= l(:label_filter_plural) %>
|
|
||||||
</legend>
|
|
||||||
<label for='status'><%= l(:field_status) %>:</label>
|
|
||||||
<%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
|
|
||||||
|
|
||||||
<% if @groups.present? %>
|
|
||||||
<label for='group_id'><%= l(:label_group) %>:</label>
|
|
||||||
<%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<label for='name'><%= l(:label_user) %>:</label>
|
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
|
||||||
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
|
|
||||||
</fieldset>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="autoscroll">
|
|
||||||
<table class="list">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<%= sort_header_tag('login', :caption => l(:field_login)) %>
|
|
||||||
<%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
|
|
||||||
<%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
|
|
||||||
<%= sort_header_tag('mail', :caption => l(:field_mail)) %>
|
|
||||||
|
|
||||||
<%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
|
|
||||||
<%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
|
|
||||||
<%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% for user in @users -%>
|
|
||||||
<tr class="<%= user.css_classes %> <%= cycle("odd", "even") %>">
|
|
||||||
<td class="username"><%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %></td>
|
|
||||||
<td class="firstname"><%= h(user.firstname) %></td>
|
|
||||||
<td class="lastname"><%= h(user.lastname) %></td>
|
|
||||||
<td class="email"><%= mail_to(h(user.mail)) %></td>
|
|
||||||
<td align="center"><%= checked_image user.admin? %></td>
|
|
||||||
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
|
||||||
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
|
||||||
<td class="buttons"> <%= change_status_link(user) %>
|
|
||||||
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
|
||||||
</tr>
|
|
||||||
<% end -%>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="pagination">
|
|
||||||
<ul>
|
|
||||||
<%= pagination_links_full @user_pages, @user_count %>
|
|
||||||
<ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% html_title(l(:label_user_plural)) -%>
|
|
||||||
|
|
||||||
<% else %>
|
|
||||||
<!-- modified by huang -->
|
<!-- modified by huang -->
|
||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
||||||
|
@ -115,4 +47,3 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% html_title(l(:label_user_plural)) -%>
|
<% html_title(l(:label_user_plural)) -%>
|
||||||
<% end -%>
|
|
||||||
|
|
|
@ -520,6 +520,7 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
match 'admin', :controller => 'admin', :action => 'index', :via => :get
|
match 'admin', :controller => 'admin', :action => 'index', :via => :get
|
||||||
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
|
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
|
||||||
|
match 'admin/users', :controller => 'admin', :action => 'users', :via => :get
|
||||||
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
|
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
|
||||||
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
|
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
|
||||||
match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
|
match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
|
||||||
|
|
|
@ -305,7 +305,7 @@ end
|
||||||
########end
|
########end
|
||||||
Redmine::MenuManager.map :admin_menu do |menu|
|
Redmine::MenuManager.map :admin_menu do |menu|
|
||||||
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
|
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
|
||||||
menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
|
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
|
||||||
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
|
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
|
||||||
menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
|
menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
|
||||||
menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
|
menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
|
||||||
|
|
Loading…
Reference in New Issue