fix competition join team

dev_bj
p31729568 5 years ago
parent 0c478172ee
commit 65523c2d2c

@ -145,7 +145,7 @@ class CompetitionTeamsController < ApplicationController
# 老师身份加入战队
if User.current.user_extensions.identity == 0
teacher_staff = @competition.where(category: 'teacher').first
teacher_staff = @competition.competition_staffs.where(category: 'teacher').first
if teacher_staff.blank?
@status, @message = -1, '该竞赛不能配备导师'
@ -158,7 +158,7 @@ class CompetitionTeamsController < ApplicationController
end
team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true)
else
max_member_count = @competition.where('category != "teacher"').sum(:maximum)
max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum)
if team.members.count + 1 > max_member_count
@status, @message = -1, '该战队成员人数已满'
return

Loading…
Cancel
Save