check deadline for news

This commit is contained in:
Matthew K. Fu JuYuan 2012-08-14 13:49:24 +08:00
parent e57b429398
commit 77224bcc8f
3 changed files with 19 additions and 5 deletions

View File

@ -205,10 +205,9 @@ class Bulletin
protected protected
def check_deadline def check_deadline
if(!self.deadline.nil? and (self.deadline<= self.postdate )) if(!self.deadline.nil? and (self.deadline < self.postdate ))
self.deadline = nil self.deadline = nil
end end
end end
def update_avliable_language def update_avliable_language

View File

@ -267,7 +267,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
# @news_bulletin.image_del = nil # @news_bulletin.image_del = nil
# params[:news_bulletin][:image_del] = nil # params[:news_bulletin][:image_del] = nil
# end # end
delete_out_invalid_date_from_params
respond_to do |format| respond_to do |format|
if @news_bulletin.update_attributes(params[:news_bulletin]) if @news_bulletin.update_attributes(params[:news_bulletin])
if(is_manager? || is_admin?) if(is_manager? || is_admin?)
@ -335,7 +335,14 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
end end
protected protected
def delete_out_invalid_date_from_params()
if(params[:news_bulletin]["deadline(1i)"].blank? or params[:news_bulletin]["deadline(2i)"].blank? or params[:news_bulletin]["deadline(3i)"].blank?)
params[:news_bulletin].delete("deadline(1i)")
params[:news_bulletin].delete("deadline(2i)")
params[:news_bulletin].delete("deadline(3i)")
end
end
# def get_categories_for_index(id = nil) # def get_categories_for_index(id = nil)
# @news_bulletin_categories = [] # @news_bulletin_categories = []

View File

@ -61,6 +61,7 @@ class NewsBulletin
validates :title, :at_least_one => true validates :title, :at_least_one => true
before_save :check_deadline
before_save :update_avliable_language before_save :update_avliable_language
after_save :save_news_bulletin_links after_save :save_news_bulletin_links
@ -248,4 +249,11 @@ class NewsBulletin
end end
end end
def check_deadline
if(!self.deadline.nil? and (self.deadline < self.postdate ))
self.deadline = nil
end
end
end end