dev_bj
caishi 5 years ago
commit ef86cc6b0b

@ -447,7 +447,7 @@ class CompetitionsController < ApplicationController
def new_competition
if params[:com_name] && params[:com_name].strip != ""
visits = rand(400..1000)
Competition.create(:name => params[:com_name], :start_time => params[:start_time], :end_time => params[:end_time], :visits => visits)
Competition.create(:name => params[:com_name], sub_title: params[:sub_title].to_s.strip, :start_time => params[:start_time], :end_time => params[:end_time], :visits => visits)
end
redirect_to competition_managements_path
end
@ -455,7 +455,7 @@ class CompetitionsController < ApplicationController
def edit_competition
competition = Competition.find params[:id]
if params[:com_name] && params[:com_name].strip != ""
competition.update_attributes(:name => params[:com_name], :start_time => params[:start_time], :end_time => params[:end_time])
competition.update_attributes(:name => params[:com_name], sub_title: params[:sub_title].to_s.strip, :start_time => params[:start_time], :end_time => params[:end_time])
end
redirect_to competition_managements_path
end

@ -2,7 +2,7 @@
class Competition < ActiveRecord::Base
# status 0下架 1上架
attr_accessible :end_time, :identifier, :name, :online_time, :start_time, :status, :visits, :competition_lists_count,
:min_num, :max_num, :enroll_end_time
:min_num, :max_num, :enroll_end_time, :sub_title
has_many :competition_modules, :dependent => :destroy
has_many :competition_stages, :dependent => :destroy

@ -3,11 +3,12 @@
<table class="edu-pop-table interval-td edu-txt-center clearfix color-dark" cellspacing="0" cellpadding="0">
<thead>
<th>序号</th>
<th width="22%">竞赛名称</th>
<th>开始时间</th>
<th>截止时间</th>
<th width="15%">竞赛名称</th>
<th width="10%">副标题</th>
<th width="10%">开始时间</th>
<th width="10%">截止时间</th>
<th width="18%">竞赛活动图</th>
<th>创建时间<a href="javascript:void(0)" onclick="changeTimeArray(this);" data-index=0><i class="iconfont icon-xiajiang color-green font-14 ml3"></i></a>
<th width="10%">创建时间<a href="javascript:void(0)" onclick="changeTimeArray(this);" data-index=0><i class="iconfont icon-xiajiang color-green font-14 ml3"></i></a>
</th>
<th>操作</th>
</thead>
@ -20,10 +21,14 @@
<input type="text" class="input-100-35 mt5 mb5 none editTitlevalue" id="edit_competition_name_<%= competition.id %>" placeholder="请输入竞赛名称" value="<%= competition.name %>"/>
</td>
<td>
<input type="text" placeholder="请选择开始时间" id="edit_start_time_<%= competition.id %>" class="winput-200-35 mt5 mb5 game_begin_time" value="<%= format_time competition.start_time %>"/>
<p class="break_word showSubTitlevalue" style="max-width: 263px"><%= competition.sub_title %></p>
<input type="text" class="input-100-35 mt5 mb5 none editSubTitlevalue" id="edit_competition_sub_title_<%= competition.id %>" placeholder="请输入副标题" value="<%= competition.sub_title %>"/>
</td>
<td>
<input type="text" placeholder="请选择结束时间" id="edit_end_time_<%= competition.id %>" class="winput-200-35 mt5 mb5 game_end_time" value="<%= format_time competition.end_time %>"/>
<input type="text" placeholder="请选择开始时间" id="edit_start_time_<%= competition.id %>" class="winput-150-30 mt5 mb5 game_begin_time" value="<%= format_time competition.start_time %>"/>
</td>
<td>
<input type="text" placeholder="请选择结束时间" id="edit_end_time_<%= competition.id %>" class="winput-150-30 mt5 mb5 game_end_time" value="<%= format_time competition.end_time %>"/>
</td>
<td>
<%= file_field_tag 'avatar[image]',
@ -101,9 +106,10 @@
function setCompetition() {
if($("#addLine").length == 0){
var html = '<tr id="addLine"><td></td><td>' +
'<input type="text" class="input-100-35 mt5 mb5" name="com_name" id="inputTitlevalue" placeholder="请输入竞赛名称"/>' +
'</td><td><input type="text" placeholder="请选择开始时间" autocomplete="off" readonly name="start_time" class="winput-200-35 mt5 mb5 game_begin_time"/></td>' +
'<td><input type="text" placeholder="请选择结束时间" autocomplete="off" readonly name="end_time" class="winput-200-35 mt5 mb5 game_end_time"/></td>' +
'<input type="text" class="input-100-35 mt5 mb5" name="com_name" id="inputTitlevalue" placeholder="请输入竞赛名称"/></td>' +
'<td><input type="text" class="input-100-35 mt5 mb5" name="com_sub_title" id="inputSubTitlevalue" placeholder="请输入副标题"/>' +
'</td><td><input type="text" placeholder="请选择开始时间" autocomplete="off" readonly name="start_time" class="winput-150-30 mt5 mb5 game_begin_time"/></td>' +
'<td><input type="text" placeholder="请选择结束时间" autocomplete="off" readonly name="end_time" class="winput-150-30 mt5 mb5 game_end_time"/></td>' +
'<td colspan="3" class="edu-txt-right">' +
'<a href="javascript:void(0)" class="mr10" onclick="cancelAdd();">取消</a>' +
'<a href="javascript:void(0)" class="mr10" onclick="saveAdd();" data-status="0">保存</a>' +
@ -136,7 +142,8 @@
return;
} else{
$.post("<%= new_competition_competitions_path %>",
{"com_name": $("#inputTitlevalue").val().trim(), "start_time": $("input[name='start_time']").val().trim(),
{"com_name": $("#inputTitlevalue").val().trim(), "sub_title": $("#inputSubTitlevalue").val().trim()
, "start_time": $("input[name='start_time']").val().trim(),
"end_time": $("input[name='end_time']").val().trim()});
}
}
@ -158,6 +165,8 @@
var trIndex = $(item).parents("tr");
$(trIndex).find(".editTitlevalue").removeClass("none").focus();
$(trIndex).find(".showTitlevalue").addClass("none");
$(trIndex).find(".editSubTitlevalue").removeClass("none");
$(trIndex).find(".showSubTitlevalue").addClass("none");
$(item).hide();
$(item).next().show();
$(item).next().next().show();
@ -166,6 +175,7 @@
// 保存
function update_competition(id){
var $competition = $("#edit_competition_name_"+id);
var $competitionSubTitle = $("#edit_competition_sub_title_"+id);
if($competition.val().trim() == ""){
$competition.focus();
} else {
@ -175,7 +185,11 @@
url: "/competitions/"+id+"/edit_competition",
type: "POST",
datatype: "script",
data:{com_name: $competition.val().trim(), start_time: start_time, end_time: end_time}
data:{
com_name: $competition.val().trim(),
sub_title: $competitionSubTitle.val().trim(),
start_time: start_time, end_time: end_time
}
});
}
}

@ -0,0 +1,5 @@
class AddSubTitleToCompetitions < ActiveRecord::Migration
def change
add_column :competitions, :sub_title, :string
end
end
Loading…
Cancel
Save