管理员用户列表页面
This commit is contained in:
parent
84844a8c73
commit
0bdd38d264
|
|
@ -7,32 +7,32 @@ class ManagementsController < ApplicationController
|
|||
include UsersHelper
|
||||
include ApplicationHelper
|
||||
|
||||
# 0 全部;1 活动的; 2 已注册; 3 锁定
|
||||
def users
|
||||
@menu_type = 6
|
||||
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 => 50})
|
||||
else
|
||||
@limit = 50 #per_page_option
|
||||
status = params[:user_status].nil? ? 0 : params[:user_status].to_i
|
||||
condition = (params[:research_condition].nil? || params[:research_condition] == "name") ? "concat(lastname, firstname)" : params[:research_condition]
|
||||
if 0 == status
|
||||
@users = User.where("#{condition} like '%#{params[:research_contents]}%'").order("created_on desc").all
|
||||
else
|
||||
@users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("created_on desc").all
|
||||
end
|
||||
@users_count = @users.count
|
||||
@limit = 20
|
||||
@is_remote = true
|
||||
@users_pages = Paginator.new @users_count, @limit, params['page'] || 1
|
||||
@offset ||= @users_pages.offset
|
||||
@users = paginateHelper @users, @limit
|
||||
|
||||
@status = params[:status] || 1
|
||||
scope = User.logged.status(@status)
|
||||
scope = User.like(params[:name]) if params[:name].present?
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
|
||||
@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
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@groups = Group.all.sort
|
||||
}
|
||||
format.api
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update_user_status
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3632,7 +3632,7 @@ class UsersController < ApplicationController
|
|||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(admin_users_path) }
|
||||
format.html { redirect_back_or_default(params[:back_url]) }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2559,6 +2559,19 @@ module ApplicationHelper
|
|||
link_to l(:button_delete), url, options
|
||||
end
|
||||
|
||||
def update_status_link(user)
|
||||
url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
|
||||
|
||||
if user.locked?
|
||||
link_to "解锁", url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'mr10 link-color-blue'
|
||||
elsif user.registered?
|
||||
link_to "激活", url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'mr10 link-color-blue'
|
||||
elsif user != User.current
|
||||
link_to "加锁", url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'mr10 link-color-blue'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def delete_version_link(url, options={})
|
||||
options = {
|
||||
:method => :delete,
|
||||
|
|
|
|||
|
|
@ -325,11 +325,11 @@ module UsersHelper
|
|||
url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
|
||||
|
||||
if user.locked?
|
||||
link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
|
||||
link_to "解锁", url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'mr10 link-color-blue'
|
||||
elsif user.registered?
|
||||
link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
|
||||
elsif user != User.current
|
||||
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock'
|
||||
link_to "加锁", url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'mr10 link-color-blue'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@
|
|||
$("#code_estimate").html("<a href='<%= next_step_myshixun_game_path(@game, :myshixun_id => @myshixun) %>' class='task-btn task-btn-blue mr15 mt8' id='next_step' data-remote='true'>下一关</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 0}) %>";
|
||||
}else{
|
||||
$("#code_estimate").html("<a href='<%= shixuns_path() %>' class='task-btn task-btn-blue mt8 mr15' >退出实训</a>");
|
||||
$("#code_estimate").html("<a href='<%= shixun_path(@shixun) %>' class='task-btn task-btn-blue mt8 mr15' >退出实训</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>";
|
||||
}
|
||||
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<li class="fl edu-admin-nav-li"><a href="javascript:void(0);" class="edu-admin-nav-a">单位</a></li>
|
||||
<li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 6 %>"><a href="javascript:void(0);" class="edu-admin-nav-a">用户</a>
|
||||
<ul class="edu-admin-nav-inner edu-absolute">
|
||||
<!-- <li><%#= link_to "用户列表", users_managements_path %></li>-->
|
||||
<li><%= link_to "用户列表", users_managements_path %></li>
|
||||
<li><%= link_to "试用授权列表", users_trial_managements_path %></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<table class="edu-pop-table edu-txt-center font-12 table-pa5" cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>真实姓名</th>
|
||||
<th>邮件地址</th>
|
||||
<th>手机号码</th>
|
||||
<th>单位</th>
|
||||
<th><a href="javascript:void(0);">创建于<i class="fa fa-long-arrow-down ml5 color-blue"></i></a></th>
|
||||
<th>最后登录</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.login %></td>
|
||||
<td><a href="<%= user_path(user) %>" class="edu-txt-w100 task-hide" title="<%= user.try(:show_name) %>"><%= user.try(:show_name) %></a></td>
|
||||
<td><span class="edu-txt-w140 task-hide" title="<%= user.mail.blank? ? "--" : user.mail %>"><%= user.mail.blank? ? "--" : user.mail %></span></td>
|
||||
<td title="<%= user.phone.blank? ? "--" : user.phone %>"><%= user.phone.blank? ? "--" : user.phone %></td>
|
||||
<td>
|
||||
<span class="edu-txt-w140 task-hide" title=" <%= user.try(:user_extensions).try(:school).try(:name).blank? ? "--" : user.try(:user_extensions).try(:school) %>">
|
||||
<%= user.try(:user_extensions).try(:school).try(:name).blank? ? "--" : user.try(:user_extensions).try(:school) %>
|
||||
</span>
|
||||
</td>
|
||||
<td><%= format_time user.created_on %></td>
|
||||
<td title="<%= user.last_login_on.blank? ? "--" : (format_time user.last_login_on) %>"><%= user.last_login_on.blank? ? "--" : (format_time user.last_login_on) %></td>
|
||||
<td>
|
||||
<!-- <a href="<%#= update_user_status_managements_path(:status => user.status, :page => params[:page]) %>" class="mr10 link-color-blue" id="lock_user"><%#= user.status == 3 ? "解锁" : "锁定" %></a>-->
|
||||
<%= update_status_link(user) %>
|
||||
<!-- <a href="javascript:void(0);" methods="delete" class="link-color-blue" id="delete_user">删除</a>-->
|
||||
<%= link_to "删除", user_path(user, :back_url => users_managements_path), :method => "delete", :class => "link-color-blue", :confirm => l(:text_are_you_sure) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% if @users_count > 20 %>
|
||||
<div style="text-align:center;" class="new_expand">
|
||||
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
|
||||
<ul id="homework_pository_ref_pages">
|
||||
<%= pagination_links_full @users_pages, @users_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -1,55 +1,32 @@
|
|||
<div class="edu-class-top mt15 clearfix">
|
||||
<div class=" edu-position edu-admin-select fl mr10" style="width:120px;" >
|
||||
<p>全部状态<i class="fa fa-caret-down ml10" ></i></p>
|
||||
<input type="hidden" name="user_status" value="status">
|
||||
<ul class="edu-admin-option">
|
||||
<li data-val="all">全部状态</li>
|
||||
<li data-val="active">活动的(53888)</li>
|
||||
<li data-val="unactive">未激活(4800)</li>
|
||||
<li data-val="lock">已锁定(200)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="edu-position edu-admin-select fl mr10" style="width:150px;">
|
||||
<p>真实姓名搜索<i class="fa fa-caret-down ml10"></i></p>
|
||||
<input type="hidden" name="research_condition" value="name">
|
||||
<ul class="edu-admin-option">
|
||||
<li data-val="name">真实姓名搜索</li>
|
||||
<li data-val="email">邮箱地址搜索</li>
|
||||
<li data-val="phone">手机号码搜索</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="fl with30">
|
||||
<input type="text" class="fl task-form-60 task-height-40 panel-box-sizing" placeholder="输入关键字进行搜索">
|
||||
<a href="javascript:void(0);" class="fl task-btn task-btn-blue ml5 mt5">搜索</a>
|
||||
<a href="javascript:void(0);" class="fl task-btn ml5 mt5">清除</a>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="fr task-btn task-btn-green mt5">新建用户</a>
|
||||
<%= form_tag(url_for(users_managements_path), :id => "managements_users_search", :method => "post", :remote => true) do %>
|
||||
<div class=" edu-position edu-admin-select fl mr10" style="width:120px;" >
|
||||
<p>全部状态<i class="fa fa-caret-down ml10" ></i></p>
|
||||
<input type="hidden" name="user_status" value="0">
|
||||
<ul class="edu-admin-option">
|
||||
<li data-val="0">全部状态</li>
|
||||
<li data-val="1">活动的(53888)</li>
|
||||
<li data-val="2">未激活(4800)</li>
|
||||
<li data-val="3">已锁定(200)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="edu-position edu-admin-select fl mr10" style="width:150px;">
|
||||
<p>真实姓名搜索<i class="fa fa-caret-down ml10"></i></p>
|
||||
<input type="hidden" name="research_condition" value="name">
|
||||
<ul class="edu-admin-option">
|
||||
<li data-val="name">真实姓名搜索</li>
|
||||
<li data-val="mail">邮箱地址搜索</li>
|
||||
<li data-val="phone">手机号码搜索</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="fl with30">
|
||||
<input type="text" class="fl task-form-60 task-height-40 panel-box-sizing" name="research_contents" placeholder="输入关键字进行搜索">
|
||||
<a href="javascript:void(0);" class="fl task-btn task-btn-blue ml5 mt5" onclick="$('#managements_users_search').submit();">搜索</a>
|
||||
<a href="javascript:void(0);" class="fl task-btn ml5 mt5" id="clear_contents">清除</a>
|
||||
</div>
|
||||
<!-- <a href="javascript:void(0);" class="fr task-btn task-btn-green mt5">新建用户</a>-->
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="edu-con-bg01 mt15">
|
||||
<table class="edu-pop-table edu-txt-center font-12 table-pa5" cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>真实姓名</th>
|
||||
<th>邮件地址</th>
|
||||
<th>手机号码</th>
|
||||
<th>单位</th>
|
||||
<th><a href="javascript:void(0);">创建于<i class="fa fa-long-arrow-down ml5 color-blue"></i></a></th>
|
||||
<th>最后登录</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>m12345678</td>
|
||||
<td><a href="javascript:void(0);" class="edu-txt-w100 task-hide">欧阳莎</a></td>
|
||||
<td><span class="edu-txt-w140 task-hide">1234567810@test.com</span></td>
|
||||
<td>12345678901</td>
|
||||
<td ><span class="edu-txt-w140 task-hide">国防科学技术大学国防科学技术大学国防科学技术大学</span></td>
|
||||
<td >2017-05-01 10:06</td>
|
||||
<td>2017-05-01 10:06</td>
|
||||
<td><a href="javascript:void(0);" class="mr10 link-color-blue">锁定</a><a href="javascript:void(0);" class="link-color-blue">删除</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="edu-con-bg01 mt15" id="managements_user_list">
|
||||
<%= render :partial => "managements/user_list" %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
$("#managements_user_list").html("<%= j( render :partial => "managements/user_list" ) %>");
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="hascon">
|
||||
<% str = current_user ? '' : 'TA的' %>
|
||||
<ul id="edu-user-tab-nav">
|
||||
<li id="my_courses_span" class="edu-user-tab-hover new-tab-nav">
|
||||
<li class="edu-user-tab-hover new-tab-nav">
|
||||
<a href="javascript:void(0);" class="font-16 tab_type">我的课堂 <%= @courses_count %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@
|
|||
<div class="hascon">
|
||||
<% str = current_user ? '' : 'TA的' %>
|
||||
<ul id="edu-user-tab-nav">
|
||||
<li id="my_courses_span" class="edu-user-tab-hover new-tab-nav">
|
||||
<li class="edu-user-tab-hover new-tab-nav">
|
||||
<a href="javascript:void(0);" class="tab_type font-16">我的实训 <%= @shixuns_count %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -116,10 +116,11 @@ RedmineApp::Application.routes.draw do
|
|||
match 'trial_authorization_operation', :as => 'trial_authorization_operation'
|
||||
get 'reject_authentication'
|
||||
get 'agree_authentication'
|
||||
get 'users'
|
||||
match 'users', :via => [:get, :post]
|
||||
get 'users_trial'
|
||||
match 'users_authorization_agree'
|
||||
match 'users_authorization_cancel'
|
||||
get 'update_user_status'
|
||||
end
|
||||
end
|
||||
# Enable Grack support
|
||||
|
|
|
|||
|
|
@ -45,3 +45,5 @@ $(".edu-position").live("mouseout", function(){
|
|||
$("#clear_contents").live("click", function(){
|
||||
$("input[name='research_contents']").val("");
|
||||
});
|
||||
|
||||
/*------------------- 锁定/删除 用户----------------------*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue