diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 444b5b03e..43f51498d 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -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 diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index af89231a3..a16c75f24 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -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 diff --git a/app/views/contests/_contest_all_member.html.erb b/app/views/contests/_contest_all_member.html.erb new file mode 100644 index 000000000..3a0b5d486 --- /dev/null +++ b/app/views/contests/_contest_all_member.html.erb @@ -0,0 +1,37 @@ +<% if @members.count > 0 %> +
序号 | +姓名 | +登录名 | +单位 | +
---|---|---|---|
<%= index + 1%> | ++ <%= 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' %> + + | +<%= user.login%> | +<%=user.user_extensions.school ? user.user_extensions.school.name : '--' %> | +
- 管理员:<%= contest_managers(@contest).count %> - 评委:<%= contest_judges(@contest).count %> - 参赛者:<%= contest_contestants(@contest).count %> + 管理员:<%= contest_managers(@contest).count %> + 评委:<%= contest_judges(@contest).count %> + 参赛者:<%= contest_contestants(@contest).count %>
<% if User.current.member_of_contest?(@contest) %> diff --git a/app/views/contests/member.html.erb b/app/views/contests/member.html.erb new file mode 100644 index 000000000..c2e7bcdd7 --- /dev/null +++ b/app/views/contests/member.html.erb @@ -0,0 +1,23 @@ +