fix date select cause error back to the time of Jesus

This commit is contained in:
Matthew K. Fu JuYuan 2012-06-28 15:19:51 +08:00
parent 58a11ff569
commit 6c4c1046bc
1 changed files with 20 additions and 7 deletions

View File

@ -76,7 +76,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# GET /bulletins/new # GET /bulletins/new
# GET /bulletins/new.xml # GET /bulletins/new.xml
def new def new
@bulletin = Bulletin.new @bulletin = Bulletin.new(:postdate => DateTime.now)
@link_url = panel_announcement_back_end_bulletins_path @link_url = panel_announcement_back_end_bulletins_path
@ -137,7 +137,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
else else
@bulletin = Bulletin.new(params[:bulletin]) @bulletin = Bulletin.new(params[:bulletin])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil) @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id @bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id @bulletin.update_user_id = current_user.id
@ -216,7 +216,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1 # PUT /bulletins/1
# PUT /bulletins/1.xml # PUT /bulletins/1.xml
def update def update
if params[:bulletin_link] if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id]) @bulletin_link = BulletinLink.find(params[:id])
@ -246,9 +245,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
else else
@bulletin = Bulletin.find(params[:id]) @bulletin = Bulletin.find(params[:id])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.update_user_id = current_user.id
# @bulletin.image.clear if params[:bulletin][:image_del] == '1' # @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1' # if params[:bulletin][:image_del] == '1'
@ -257,8 +254,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# params[:bulletin][:image_del] = nil # params[:bulletin][:image_del] = nil
# end # end
delete_out_invalid_date_from_params
respond_to do |format| respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) if @bulletin.update_attributes(params[:bulletin])
# if (@bulletin.deadline < @bulletin.postdate rescue nil)
# @bulletin.deadline = nil
# @bulletin.update_user_id = current_user.id
# @bulletin.save!
# end
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }
@ -316,6 +319,16 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
protected protected
def delete_out_invalid_date_from_params()
if(params[:bulletin]["deadline(1i)"].empty? or params[:bulletin]["deadline(2i)"].empty? orparams[:bulletin]["deadline(3i)"].empty?)
params[:bulletin].delete("deadline(1i)")
params[:bulletin].delete("deadline(2i)")
params[:bulletin].delete("deadline(3i)")
params[:bulletin].delete("deadline(4i)")
params[:bulletin].delete("deadline(5i)")
end
end
def get_categorys(id = nil) def get_categorys(id = nil)
@bulletin_categorys = [] @bulletin_categorys = []
#@unit_list_for_anc = UnitListForAnc.all #@unit_list_for_anc = UnitListForAnc.all