竞赛的管理员、评委、参赛者列表
This commit is contained in:
parent
64fd365414
commit
59853b1558
|
@ -5,7 +5,8 @@ class ContestsController < ApplicationController
|
|||
helper :contest_members
|
||||
helper :users
|
||||
|
||||
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew]
|
||||
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew,
|
||||
:member]
|
||||
before_filter :is_logged, :only => [:index, :new, :create]
|
||||
before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy]
|
||||
before_filter :is_member?, :only => [:show, :contest_activities]
|
||||
|
@ -131,11 +132,8 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
|
||||
def settings
|
||||
if params[:tab] && params[:tab] == 'boards'
|
||||
@tab = 2
|
||||
else
|
||||
@tab = 0
|
||||
end
|
||||
@select_tab = params[:tab]
|
||||
|
||||
@member ||= @contest.contest_members.new
|
||||
@roles = Role.where("id in (13, 14, 15)")
|
||||
@members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
|
@ -253,6 +251,36 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 成员列表
|
||||
def member
|
||||
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
|
||||
@role = params[:role].nil? ? '3' : params[:role]
|
||||
case @role
|
||||
when '1'
|
||||
@members = contest_managers @contest
|
||||
when '2'
|
||||
@members = contest_judges @contest
|
||||
when '3'
|
||||
@members = contest_contestants @contest
|
||||
end
|
||||
if params[:name]
|
||||
q = "#{params[:name].strip}"
|
||||
@members = search_member_by_name_login_school @members, q
|
||||
end
|
||||
@limit = 50
|
||||
@page = params[:page].nil? ? 1 : params['page'].to_i
|
||||
@members_count = @members.count
|
||||
@mem_pages = Paginator.new @members_count, @limit, @page
|
||||
@members = paginateHelper @members, @limit
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'base_contests'}
|
||||
format.js
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_contest
|
||||
|
|
|
@ -76,4 +76,21 @@ module ContestsHelper
|
|||
end
|
||||
result
|
||||
end
|
||||
|
||||
def search_member_by_name_login_school members, name
|
||||
mems = []
|
||||
if name != ""
|
||||
name = name.to_s.downcase
|
||||
school_ids = School.where("name like '%#{name}%'").map{|school| school.id}
|
||||
members.each do |m|
|
||||
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
||||
if(m.user[:login].to_s.downcase.include?(name) || school_ids.include?(m.user.user_extensions[:school_id]) || username.include?(name))
|
||||
mems << m
|
||||
end
|
||||
end
|
||||
else
|
||||
mems = members
|
||||
end
|
||||
mems
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<% if @members.count > 0 %>
|
||||
<table class="sy_new_table clearfix" cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr class="clearfix">
|
||||
<th style="width:50px;">序号</th>
|
||||
<th style="width:150px">姓名</th>
|
||||
<th style="width:150px;">登录名</th>
|
||||
<th style="width:368px; ">单位</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @members.each_with_index do |member, index| %>
|
||||
<% user = member.user %>
|
||||
<tr class="clearfix">
|
||||
<td><%= index + 1%></td>
|
||||
<td>
|
||||
<%= link_to image_tag(url_to_avatar(user), :width => "30", :height => "30", :style => "display: block;"), user_path(user), :class => 'sy_class_users_st fl mt5 mr5' ,:alt => "用户头像", :target => '_blank' %>
|
||||
<%= link_to user.show_name, user_path(user), :class => 'fl sy_class_users_st_name ml5', :style => "width: 105px; text-align: left;", :title => "#{user.show_name}", :target => '_blank' %>
|
||||
<div class="cl"></div>
|
||||
</td>
|
||||
<td><span class="sy_new_name ml15" ><%= user.login%></span></td>
|
||||
<td><%=user.user_extensions.school ? user.user_extensions.school.name : '--' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="text-align:center;">
|
||||
<div class="pages" style="width:auto; display:inline-block;">
|
||||
<ul id="homework_pository_ref_pages">
|
||||
<%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render :partial => 'users/no_data'%>
|
||||
<% end %>
|
|
@ -22,9 +22,9 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<p class="sy_cgrey ">
|
||||
<span class=" mr15">管理员:<a class="sy_cblue" id="admin_num"><%= contest_managers(@contest).count %></a></span>
|
||||
<span class=" mr15">评委:<a class="sy_cblue" id="judge_num"><%= contest_judges(@contest).count %></a></span>
|
||||
<span class=" mr15">参赛者:<a class="sy_cblue" id="contestant_num"><%= contest_contestants(@contest).count %></a></span>
|
||||
<span class=" mr15">管理员:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 1)%>" id="admin_num"><%= contest_managers(@contest).count %></a></span>
|
||||
<span class=" mr15">评委:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 2)%>" id="judge_num"><%= contest_judges(@contest).count %></a></span>
|
||||
<span class=" mr15">参赛者:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 3)%>" id="contestant_num"><%= contest_contestants(@contest).count %></a></span>
|
||||
</p>
|
||||
</div>
|
||||
<% if User.current.member_of_contest?(@contest) %>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="sy_class_r fr ml10">
|
||||
<h3 class="game-setting-h3 clear">
|
||||
<span class="ml15"></span>
|
||||
<%= @role == '1' ? '管理员' : @role == '2' ? '评委' : '参赛者' %>列表
|
||||
<% if User.current.admin_of_contest?(@contest) %>
|
||||
<%=link_to "成员管理", {:controller => 'contests', :action => 'settings', :id => @contest.id, :tab=>'member'}, :class => 'fr mr15 sy_cblue'%>
|
||||
<% end %>
|
||||
</h3>
|
||||
<div class="hw_search_box fr mt15 mr15 mb10">
|
||||
<%= form_tag(member_contest_path(@contest), method: 'get',:class => "f_l",:remote=>true,:id => "search_member") do %>
|
||||
<input class="hw_search-input" name="name" id="search_member_input" placeholder="输入<%= @role == '1' ? '管理员' : @role == '2' ? '评委' : '参赛者' %>登录名/姓名/单位名称进行搜索" type="text">
|
||||
<input type="hidden" name="role" value="<%=@role %>"/>
|
||||
<% end %>
|
||||
<a href="javascript:void(0)" class="hw_btn_search" onclick="$('#search_member').submit();"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
||||
<div class="ml15 mr15 mb15" id="contest_all_member">
|
||||
<%=render :partial => 'contest_all_member' %>
|
||||
</div>
|
||||
|
||||
|
||||
</div><!--sy_class_r end-->
|
|
@ -0,0 +1 @@
|
|||
$("#contest_all_member").html("<%=escape_javascript(render :partial => 'contest_all_member') %>");
|
|
@ -30,6 +30,11 @@
|
|||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
<% if @select_tab == 'member'%>
|
||||
$("#game-setting-tab-nav-2").click();
|
||||
<% end %>
|
||||
});
|
||||
function g(o){
|
||||
return document.getElementById(o);
|
||||
}
|
||||
|
|
|
@ -635,6 +635,7 @@ RedmineApp::Application.routes.draw do
|
|||
get "switch_role"
|
||||
get 'set_invite_code_halt'
|
||||
get 'renew'
|
||||
get 'member'
|
||||
end
|
||||
|
||||
resources :boards
|
||||
|
|
Loading…
Reference in New Issue