p31729568 5 years ago
parent bb4aad5803
commit 3c91b68f03

@ -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

@ -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()});
}
}

@ -1,10 +1,15 @@
<p class="pl30 color-orange-tip mt5 pb5 bor-bottom-greyE">请选择指导老师,允许修改</p>
<% @teachers.each do |teacher| %>
<li class="clearfix">
<% 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) %>
<li class="clearfix <%= has_enroll ? 'added' : 'unadded' %>">
<input type="hidden" value="<%= teacher.id %>">
<span class="pt-s task-hide"><%= teacher.show_name %></span>
<span class="pt-s-n task-hide"><%= teacher.identity %></span>
<span class="pt-l task-hide"><%= teacher.school_name %></span>
<% if has_enroll %>
<span class="pt-s color-orange-tip task-hide">已加入其他战队</span>
<% end %>
</li>
<% 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());

Loading…
Cancel
Save