From a5db2382e765508c6a28f2e0f3e1c2156fc9aaf6 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 23 Apr 2012 18:20:12 +0800 Subject: [PATCH] Fix ad image date selector --- app/controllers/admin/ad_images_controller.rb | 2 ++ app/models/ad_image.rb | 4 ++-- app/views/admin/ad_images/_form.html.erb | 4 ++-- .../panel/announcement/back_end/fact_checks/setting.html.erb | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 3fb681da..d2039ab5 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -19,6 +19,8 @@ class Admin::AdImagesController < ApplicationController def new @ad_image =AdImage.new + @ad_image.post_date = Date.today + @ad_image.unpost_date = Date.today + 30 #render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil} end diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 3eb63511..f20a5582 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -28,12 +28,12 @@ class AdImage attr_reader :parse_post_date,:parse_unpost_date def parse_post_date=(att) - self.post_date = (Date.parse att rescue nil) + self.post_date = (Date.parse att.gsub(/\s+/, "") rescue nil) end def parse_unpost_date=(att) - self.unpost_date = (Date.parse att rescue nil) + self.unpost_date = (Date.parse att.gsub(/\s+/, "") rescue nil) end def display? diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index c19b2cf4..0fe04b28 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -23,8 +23,8 @@
- <%= f.hidden_field :parse_post_date %> - <%= f.hidden_field :parse_unpost_date%> + <%= f.hidden_field :parse_post_date,:value => @ad_image.post_date.strftime('%Y / %m / %d') %> + <%= f.hidden_field :parse_unpost_date,:value => @ad_image.unpost_date.strftime('%Y / %m / %d')%>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb index 7303b705..6b8ba483 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb @@ -3,8 +3,8 @@ <% end %> <% content_for :page_specific_javascript do %> <%= javascript_include_tag "bootstrap" %> - <%= javascript_include_tag "inc/permission-checkbox" %> - <%= javascript_include_tag "inc/search" %> + <%#= javascript_include_tag "inc/permission-checkbox" %> + <%#= javascript_include_tag "inc/search" %> <% end %> <%#= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %> <%= form_tag('', :remote => true) %>