diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index fb41d3f8..f39c7708 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -1,7 +1,7 @@ class CompetitionTeamsController < ApplicationController include ApplicationHelper before_filter :find_team, :except => [:new, :create, :join_team, :search_non_user, :personal_enroll, :check_team_identity, :search_teacher] - before_filter :find_competition, :only => [:new, :create, :join_team, :search_non_user, :personal_enroll] + before_filter :find_competition, :only => [:new, :create, :join_team, :search_teacher, :search_non_user, :personal_enroll] before_filter :require_login skip_before_filter :verify_authenticity_token, :only => [:edit_rule] layout 'base_competition' @@ -13,6 +13,10 @@ class CompetitionTeamsController < ApplicationController end def search_teacher + if params[:team] && params[:team] != "" + @team = @competition.competition_teams.where(:id => params[:team]).first + end + condition = "%#{params[:search].strip}%".gsub(" ","") @teachers = User.joins(:user_extensions).where("status = 1 and LOWER(concat(lastname, firstname, login, nickname)) LIKE '#{condition}' and user_extensions.identity = 0") end @@ -271,7 +275,7 @@ class CompetitionTeamsController < ApplicationController repeat_teachers = competition.team_members.where(user_id: user_ids).includes(:user).to_a if repeat_teachers.size > 0 - @status, @message = -1, "导师#{repeat_teachers.map{|t| t.user.show_real_name}}已经加入其它战队了" + @status, @message = -1, "导师#{repeat_teachers.map{|t| t.user.show_real_name}.join(',')}已经加入其它战队了" return false end @@ -284,7 +288,7 @@ class CompetitionTeamsController < ApplicationController repeat_members = competition.team_members.where(user_id: user_ids).includes(:user).to_a if repeat_members.size > 0 - @status, @message = -1, "成员#{repeat_members.map{|t| t.user.show_real_name}}已经加入其它战队了" + @status, @message = -1, "成员#{repeat_members.map{|t| t.user.show_real_name}.join(',')}已经加入其它战队了" return false end diff --git a/app/views/competition_teams/_competition_team_form.html.erb b/app/views/competition_teams/_competition_team_form.html.erb index 359a1d11..fbba4618 100644 --- a/app/views/competition_teams/_competition_team_form.html.erb +++ b/app/views/competition_teams/_competition_team_form.html.erb @@ -247,8 +247,8 @@ function search_teacher_user(){ if($("#teacher_search_input").val().trim() != ""){ - $.post("<%= search_teacher_competition_teams_path() %>", - {"search": $("#teacher_search_input").val().trim()}); + $.post("<%= search_teacher_competition_teams_path(:com_id => @competition.id) %>", + {"search": $("#teacher_search_input").val().trim(), "team": $("#team_id").val()}); } } diff --git a/app/views/competition_teams/_search_teacher_list.html.erb b/app/views/competition_teams/_search_teacher_list.html.erb index 54538382..9847daec 100644 --- a/app/views/competition_teams/_search_teacher_list.html.erb +++ b/app/views/competition_teams/_search_teacher_list.html.erb @@ -1,10 +1,15 @@

请选择指导老师,允许修改

<% @teachers.each do |teacher| %> -
  • + <% has_enroll = @competition.teacher_enroll_mutiple_limited && (@team.present? ? @competition.team_members.where("user_id = '#{teacher.id}' and id != #{@team.id}").count > 0 : @competition.team_members.where("user_id = '#{teacher.id}'").count > 0) %> + +
  • <%= teacher.show_name %> <%= teacher.identity %> <%= teacher.school_name %> + <% if has_enroll %> + 已加入其他战队 + <% end %>
  • <% end %> @@ -14,7 +19,7 @@ e.stopPropagation(); }); /*从下拉列表中选择指导老师*/ - $("#pointerTeacher li").click(function(e){ + $("#pointerTeacher li.unadded").click(function(e){ var name=$(this).find(".pt-s").html().trim(); $("#pointerTeacher").siblings("#teacher_search_input").val(name); $("#pointerTeacher").siblings("#teacher_id").val($(this).find("input").val().trim());