From 2c8940e3502c5a8557f25508c840ede274ff63d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Jan 2012 14:04:52 +0800 Subject: [PATCH] announcement widget page --- .../panel/announcement/front_end/bulletins_controller.rb | 6 +++++- vendor/built_in_modules/announcement/app/models/bulletin.rb | 6 ++++-- .../panel/announcement/front_end/bulletins/index.html.erb | 4 ---- .../panel/announcement/front_end/bulletins/show.html.erb | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index f5a3da9c2..537a7e195 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -9,7 +9,11 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController # GET /bulletins.xml def index - @bulletins = Bulletin.desc("postdate") + + date_now = Time.now + + @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate) + get_categorys end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 9c545a13a..33f475c4f 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -61,11 +61,13 @@ class Bulletin def self.widget_datas - date_now = Date.today + date_now = Time.now # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) - where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) + # where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) # any_of({ :title => "test" },{:deadline => nil, :title => "123"}) + any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).limit(5) + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index ce18ae2dd..d6340a85d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -7,18 +7,14 @@ - - <% @bulletins.each do |post| %> - -
<%= t('bulletin.status') %> <%= t('bulletin.postdate') %><%= t('bulletin.deadline') %> <%= t('bulletin.category') %> <%= t('bulletin.title') %>
<%= post.postdate %><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %> <%= post.bulletin_category.i18n_variable[I18n.locale] %> <%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 87d08897a..353d630af 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -50,7 +50,7 @@
  • <%= t('announcement.最後修改時間') %> - <%= @bulletin.updated_at %> + <%= @bulletin.updated_at.strftime("%Y-%m-%d %H:%I:%S") %>