modify competition error message

dev_auth
p31729568 5 years ago
parent f07b44a028
commit fe66b770fd

@ -16,14 +16,13 @@ class Competitions::SaveTeamForm
validate :check_teachers_enrollable
def check_teachers_enrollable
if competition.teacher_enroll_forbidden? # 禁止老师报名
return if creator.is_teacher? # 因为创建者有单独校验,所以这里跳过
return if teacher_ids.blank?
if teacher_ids.present?
errors.add(:teacher_ids, :enroll_forbidden)
return
end
return if creator.is_teacher? # 因为创建者有单独校验,所以这里跳过
end
self.teacher_ids = teacher_ids.map(&:to_i)
@ -50,14 +49,13 @@ class Competitions::SaveTeamForm
validate :check_members_enrollable
def check_members_enrollable
if competition.member_enroll_forbidden? # 禁止学生报名
return unless creator.is_teacher? # 因为创建者有单独校验,所以这里跳过
return if member_ids.blank?
if member_ids.present?
errors.add(:member_ids, :enroll_forbidden)
return
end
return unless creator.is_teacher? # 因为创建者有单独校验,所以这里跳过
end
self.member_ids = member_ids.map(&:to_i)

Loading…
Cancel
Save