diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 4c558379..1be642d7 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -206,7 +206,7 @@ class CompetitionTeamsController < ApplicationController teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? - @status, @message = -1, '老师不能参加该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:学生' return end @@ -218,7 +218,7 @@ class CompetitionTeamsController < ApplicationController else max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) if max_member_count.zero? - @status, @message = -1, '学生不能参加该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:教师' return elsif team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' @@ -277,16 +277,18 @@ class CompetitionTeamsController < ApplicationController end def member_and_teacher_count_valid?(is_teacher) + single_staff = @competition.competition_staffs.count == 1 + teacher_text = single_staff ? '队员' : '导师' teacher_staff = @competition.competition_staffs.where(category: 'teacher').first teacher_count = params[:teacher_ids].try(:size) || 0 teacher_count += 1 if is_teacher # 检查老师数量 if teacher_staff.blank? && teacher_count > 0 - @status, @message = -1, '老师不能参与该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:学生' return false elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count) @status = -1 - @message = teacher_staff.maximum == teacher_staff.maximum ? "导师数量应为#{teacher_staff.minimum}人" : "导师数量应为#{teacher_staff.minimum}-#{teacher_staff.maximum}人" + @message = teacher_staff.maximum == teacher_staff.maximum ? "#{teacher_text}数量应为#{teacher_staff.minimum}人" : "#{teacher_text}数量应为#{teacher_staff.minimum}-#{teacher_staff.maximum}人" return false end @@ -297,11 +299,11 @@ class CompetitionTeamsController < ApplicationController member_count += 1 unless is_teacher # 检查成员数据 if member_relations.count.zero? && member_count > 0 - @status, @message = -1, '学生不能参与该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:教师' return false elsif min_member_count > member_count || member_count > max_member_count @status = -1 - @message = min_member_count == max_member_count ? "成员数量应为#{max_member_count}人" : "成员数量应为#{min_member_count}-#{max_member_count}人" + @message = min_member_count == max_member_count ? "队员数量应为#{max_member_count}人" : "队员数量应为#{min_member_count}-#{max_member_count}人" return false end @@ -327,7 +329,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}.join(',')}已经加入其它战队了" + @status, @message = -1, "队员#{repeat_members.map{|t| t.user.show_real_name}.join(',')}已经加入其它战队了" return false end diff --git a/app/views/competition_teams/_competition_team_form.html.erb b/app/views/competition_teams/_competition_team_form.html.erb index c68cc3b2..3f076d6a 100644 --- a/app/views/competition_teams/_competition_team_form.html.erb +++ b/app/views/competition_teams/_competition_team_form.html.erb @@ -1,4 +1,5 @@ <% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> +<% single_staff = @competition.competition_staffs.count == 1 %> <%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %> <% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %> <% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %> @@ -10,19 +11,19 @@ - <% if none_edit %> + <% if teacher_staff && none_edit %>
报名已截止,只能编辑导师信息
<% end %><% if teacher_staff.present? %>
<% end %> @@ -68,7 +69,7 @@ <% creator_teacher = @team.user.user_extensions.identity == 0 %>
<%= @team.user.show_name %> - <%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %> + <%= @team.user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %> <%= @team.user.school_name %> <%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %> @@ -79,7 +80,7 @@
<%= teacher.user.show_name %> - 导师 + <%= single_staff ? '队员' : '导师' %> <%= teacher.user.school_name %> 职称:<%= teacher.user.identity %> @@ -91,7 +92,7 @@
<%= team_user.user.show_name %>
- 成员
+ 队员
<%= team_user.user.school_name %>
学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %>
@@ -105,7 +106,7 @@
<% creator_teacher = @team_user.user_extensions.identity == 0 %>
<%= @team_user.show_name %>
- <%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %>
+ <%= @team_user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %>
<%= @team_user.school_name %>
<%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %>
@@ -167,7 +168,7 @@
var li = ' ' +
' ' +
' '+$("#teacher_name").val()+'' +
- ' 导师' +
+ ' <%= single_staff ? "队员" : "导师" %>' +
' '+$("#teacher_school").val()+'' +
' 职称:'+$("#teacher_title").val()+'' +
' ' +
@@ -193,7 +194,7 @@
var li = ' ' +
' ' +
' '+$("#member_name").val()+'' +
- ' 成员' +
+ ' 队员' +
' '+$("#member_school").val()+'' +
' 学号:'+$("#member_student_id").val()+'' +
' ' +
diff --git a/app/views/competition_teams/_search_teacher_list.html.erb b/app/views/competition_teams/_search_teacher_list.html.erb
index 9847daec..ab7adcd8 100644
--- a/app/views/competition_teams/_search_teacher_list.html.erb
+++ b/app/views/competition_teams/_search_teacher_list.html.erb
@@ -1,4 +1,4 @@
- 请选择指导老师,允许修改