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