competition modify

dev_aliyun
p31729568 5 years ago
parent acbbf4736e
commit 1db30cbbb3

@ -206,7 +206,7 @@ class CompetitionTeamsController < ApplicationController
teacher_staff = @competition.competition_staffs.where(category: 'teacher').first teacher_staff = @competition.competition_staffs.where(category: 'teacher').first
if teacher_staff.blank? if teacher_staff.blank?
@status, @message = -1, '老师不能参加该竞赛' @status, @message = -1, '本竞赛的参赛者限定为:学生'
return return
end end
@ -218,7 +218,7 @@ class CompetitionTeamsController < ApplicationController
else else
max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum)
if max_member_count.zero? if max_member_count.zero?
@status, @message = -1, '学生不能参加该竞赛' @status, @message = -1, '本竞赛的参赛者限定为:教师'
return return
elsif team.members.count + 1 > max_member_count elsif team.members.count + 1 > max_member_count
@status, @message = -1, '该战队成员人数已满' @status, @message = -1, '该战队成员人数已满'
@ -277,16 +277,18 @@ class CompetitionTeamsController < ApplicationController
end end
def member_and_teacher_count_valid?(is_teacher) 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_staff = @competition.competition_staffs.where(category: 'teacher').first
teacher_count = params[:teacher_ids].try(:size) || 0 teacher_count = params[:teacher_ids].try(:size) || 0
teacher_count += 1 if is_teacher teacher_count += 1 if is_teacher
# 检查老师数量 # 检查老师数量
if teacher_staff.blank? && teacher_count > 0 if teacher_staff.blank? && teacher_count > 0
@status, @message = -1, '老师不能参与该竞赛' @status, @message = -1, '本竞赛的参赛者限定为:学生'
return false return false
elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count) elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count)
@status = -1 @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 return false
end end
@ -297,11 +299,11 @@ class CompetitionTeamsController < ApplicationController
member_count += 1 unless is_teacher member_count += 1 unless is_teacher
# 检查成员数据 # 检查成员数据
if member_relations.count.zero? && member_count > 0 if member_relations.count.zero? && member_count > 0
@status, @message = -1, '学生不能参与该竞赛' @status, @message = -1, '本竞赛的参赛者限定为:教师'
return false return false
elsif min_member_count > member_count || member_count > max_member_count elsif min_member_count > member_count || member_count > max_member_count
@status = -1 @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 return false
end end
@ -327,7 +329,7 @@ class CompetitionTeamsController < ApplicationController
repeat_members = competition.team_members.where(user_id: user_ids).includes(:user).to_a repeat_members = competition.team_members.where(user_id: user_ids).includes(:user).to_a
if repeat_members.size > 0 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 return false
end end

@ -1,4 +1,5 @@
<% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% 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| %> <%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %>
<% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %> <% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %>
<% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %> <% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %>
@ -10,19 +11,19 @@
<input type="hidden" id="team_id" value="<%= @team.try(:id) %>"> <input type="hidden" id="team_id" value="<%= @team.try(:id) %>">
<input type="hidden" name="com_id" value="<%= @competition.id %>"> <input type="hidden" name="com_id" value="<%= @competition.id %>">
<% if none_edit %> <% if teacher_staff && none_edit %>
<p class="edu-txt-center color-orange">报名已截止,只能编辑导师信息</p> <p class="edu-txt-center color-orange">报名已截止,只能编辑导师信息</p>
<% end %> <% end %>
<div class="df pl20 pr20 mt10"> <div class="df pl20 pr20 mt10">
<label class="mt3"><span class="mr3 color-orange">*</span>队名:</label> <label class="mt3"><span class="mr3 color-orange">*</span>队名:</label>
<input type="text" name="name" autocomplete="off" <%= none_edit ? "disabled" : "" %> maxlength="20" value="<%= @team.try(:name) %>" class="input-flex-35" placeholder="请输入您的队名称"/> <input type="text" name="name" autocomplete="off" <%= none_edit ? "disabled" : "" %> maxlength="20" value="<%= @team.try(:name) %>" class="input-flex-35" placeholder="请输入您的队名称"/>
</div> </div>
<p style="line-height: 27px;height: 27px"><span id="team_name_notice" class="color-orange-tip ml73 none"></span></p> <p style="line-height: 27px;height: 27px"><span id="team_name_notice" class="color-orange-tip ml73 none"></span></p>
<% if teacher_staff.present? %> <% if teacher_staff.present? %>
<div class="df pl20 pr20"> <div class="df pl20 pr20">
<label class="ml10 mt3">导师:</label> <label class="ml10 mt3"><%= single_staff ? '队员' : '导师' %></label>
<div class="flex1 pr search-new"> <div class="flex1 pr search-new">
<input type="text" class="input-100-35 fl" autocomplete="off" placeholder="请您输入老师姓名进行搜索;可以后续再添加导师" id="teacher_search_input" value=""> <input type="text" class="input-100-35 fl" autocomplete="off" placeholder="请您输入老师姓名进行搜索;可以后续再添加导师" id="teacher_search_input" value="">
<input type="hidden" id="teacher_id" data-select="0" value="<%= @team.try(:id).present? ? @team.try(:teacher_id) : (@team_user.user_extensions.identity == 0 ? @team_user.id : "") %>"> <input type="hidden" id="teacher_id" data-select="0" value="<%= @team.try(:id).present? ? @team.try(:teacher_id) : (@team_user.user_extensions.identity == 0 ? @team_user.id : "") %>">
@ -41,7 +42,7 @@
<div class="df pl20 pr20"> <div class="df pl20 pr20">
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label> <label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<div class="flex1 search-new"> <div class="flex1 search-new">
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的员搜索" id="user_search_input"> <input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的员搜索" id="user_search_input">
<span class="search-span" style="background: #fff;"></span> <span class="search-span" style="background: #fff;"></span>
<input type="hidden" id="member_id" data-select="0"> <input type="hidden" id="member_id" data-select="0">
<input type="hidden" id="member_name"> <input type="hidden" id="member_name">
@ -51,7 +52,7 @@
<ul class="pointerTeacher none" id="pointerStudent"> <ul class="pointerTeacher none" id="pointerStudent">
</ul> </ul>
</div> </div>
<a class="fl ml20 white-btn edu-blueback-btn mt4 add-member-btn" style="display: none;" onclick="<%= none_edit ? '' : 'add_member()' %>">添加员</a> <a class="fl ml20 white-btn edu-blueback-btn mt4 add-member-btn" style="display: none;" onclick="<%= none_edit ? '' : 'add_member()' %>">添加员</a>
</div> </div>
<p style="line-height: 27px;height: 27px"><span id="member_notice" class="color-orange-tip ml73 none"></span></p> <p style="line-height: 27px;height: 27px"><span id="member_notice" class="color-orange-tip ml73 none"></span></p>
<% end %> <% end %>
@ -68,7 +69,7 @@
<% creator_teacher = @team.user.user_extensions.identity == 0 %> <% creator_teacher = @team.user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li"> <p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team.user.show_name %></span> <span class="t-c-1"><%= @team.user.show_name %></span>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span> <span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %></span>
<span class="t-c-3"><%= @team.user.school_name %></span> <span class="t-c-3"><%= @team.user.school_name %></span>
<span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span> <span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span> <span class="t-c-5"></span>
@ -79,7 +80,7 @@
<p class="personListLine clearfix pt5 pb5 personListMember team-teacher team-teacher-<%= teacher.user.id %>"> <p class="personListLine clearfix pt5 pb5 personListMember team-teacher team-teacher-<%= teacher.user.id %>">
<input type="hidden" name="teacher_ids[]" value="<%= teacher.user.id %>"> <input type="hidden" name="teacher_ids[]" value="<%= teacher.user.id %>">
<span class="t-c-1"><%= teacher.user.show_name %></span> <span class="t-c-1"><%= teacher.user.show_name %></span>
<span class="t-c-2">导师</span> <span class="t-c-2"><%= single_staff ? '队员' : '导师' %></span>
<span class="t-c-3"><%= teacher.user.school_name %></span> <span class="t-c-3"><%= teacher.user.school_name %></span>
<span class="t-c-4">职称:<%= teacher.user.identity %></span> <span class="t-c-4">职称:<%= teacher.user.identity %></span>
<span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span> <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>
@ -91,7 +92,7 @@
<p class="personListLine clearfix pt3 pb3 personListMember team-member"> <p class="personListLine clearfix pt3 pb3 personListMember team-member">
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>"> <input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="t-c-1"><%= team_user.user.show_name %></span> <span class="t-c-1"><%= team_user.user.show_name %></span>
<span class="t-c-2">员</span> <span class="t-c-2">员</span>
<span class="t-c-3"><%= team_user.user.school_name %></span> <span class="t-c-3"><%= team_user.user.school_name %></span>
<span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span> <span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span>
<span class="t-c-5"> <span class="t-c-5">
@ -105,7 +106,7 @@
<% creator_teacher = @team_user.user_extensions.identity == 0 %> <% creator_teacher = @team_user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li"> <p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team_user.show_name %></span> <span class="t-c-1"><%= @team_user.show_name %></span>
<span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span> <span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %></span>
<span class="t-c-3"><%= @team_user.school_name %></span> <span class="t-c-3"><%= @team_user.school_name %></span>
<span class="t-c-4"><%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %></span> <span class="t-c-4"><%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span> <span class="t-c-5"></span>
@ -167,7 +168,7 @@
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-teacher team-teacher-' + $("#teacher_id").val() + '">' + var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-teacher team-teacher-' + $("#teacher_id").val() + '">' +
' <input type="hidden" name="teacher_ids[]" value="'+$("#teacher_id").val()+'">' + ' <input type="hidden" name="teacher_ids[]" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' + ' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' + ' <span class="t-c-2"><%= single_staff ? "队员" : "导师" %></span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' + ' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</span>' + ' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' + ' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +
@ -193,7 +194,7 @@
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-member team-member-' + $("#member_id").val() + '">' + var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-member team-member-' + $("#member_id").val() + '">' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' + ' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' + ' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
' <span class="t-c-2">员</span>' + ' <span class="t-c-2">员</span>' +
' <span class="t-c-3">'+$("#member_school").val()+'</span>' + ' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' + ' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' +
' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' + ' <span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>' +

@ -1,4 +1,4 @@
<p class="pl30 color-orange-tip mt5 pb5 bor-bottom-greyE">请选择指导老师,允许修改</p> <!--<p class="pl30 color-orange-tip mt5 pb5 bor-bottom-greyE">请选择指导老师,允许修改</p>-->
<% @teachers.each do |teacher| %> <% @teachers.each do |teacher| %>
<% has_enroll = @competition.teacher_enroll_mutiple_limited && (@team.present? ? @competition.team_members.where("user_id = '#{teacher.id}' and id != #{@team.id}").count > 0 : @competition.team_members.where("user_id = '#{teacher.id}'").count > 0) %> <% has_enroll = @competition.teacher_enroll_mutiple_limited && (@team.present? ? @competition.team_members.where("user_id = '#{teacher.id}' and id != #{@team.id}").count > 0 : @competition.team_members.where("user_id = '#{teacher.id}'").count > 0) %>

Loading…
Cancel
Save