|
|
|
@ -39,9 +39,9 @@ class Competitions::SaveTeamForm
|
|
|
|
|
|
|
|
|
|
# 存在已报名老师
|
|
|
|
|
enrolled_teacher_members = competition.team_members.where(user_id: all_teachers)
|
|
|
|
|
.where.not(competition_team_id: team.id).includes(:user)
|
|
|
|
|
.where.not(competition_team_id: team.id).pluck(:user_id)
|
|
|
|
|
if enrolled_teacher_members.present?
|
|
|
|
|
errors.add(:teacher_ids, :enrolled, names: enrolled_teacher_members.map { |m| m.user.real_name }.join(','))
|
|
|
|
|
errors.add(:teacher_ids, :enrolled, names: User.where(id: enrolled_teacher_members).map(&:real_name).join(','))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -72,9 +72,9 @@ class Competitions::SaveTeamForm
|
|
|
|
|
|
|
|
|
|
# 存在已报名成员
|
|
|
|
|
enrolled_members = competition.team_members.where(user_id: all_members)
|
|
|
|
|
.where.not(competition_team_id: team.id).includes(:user)
|
|
|
|
|
.where.not(competition_team_id: team.id).pluck(:user_id)
|
|
|
|
|
if enrolled_members.present?
|
|
|
|
|
errors.add(:member_ids, :enrolled, names: enrolled_members.map { |m| m.user.real_name }.join(','))
|
|
|
|
|
errors.add(:member_ids, :enrolled, names: User.where(id: enrolled_members).map(&:real_name).join(','))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|