From 48d94d5e15f77eca01c6f7374cd8e1b6723a8b76 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 20 Feb 2012 18:19:26 +0800 Subject: [PATCH] Fix bug widget when no bulletins or web_links, put link in bulletins --- .../announcement/app/models/announcement_tag.rb | 1 + .../panel/announcement/widget/bulletins/_bulletins.html.erb | 2 +- .../widget/bulletins/bulletins_and_web_links.js.erb | 4 ++-- .../announcement/widget/bulletins/reload_web_links.js.erb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb index 9656db7d..9cb29038 100644 --- a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb +++ b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb @@ -4,6 +4,7 @@ class AnnouncementTag < Tag def get_visible_bulletins(sort = :name) + date_now = Time.now self.bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort) end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb index 29fce0b1..de1cef79 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb @@ -1,6 +1,6 @@ <% @bulletins.each do |bulletin| %>
  • - <%= bulletin.title[I18n.locale] %> + <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin) %>
  • <% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb index 017bb1fa..9439ce4d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb @@ -1,3 +1,3 @@ $('#bulletins_web_links_tags').html("<%= j render :partial => 'tag', :collection => @tags %>") -$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' %>") -$('#bulletins_web_links_web_links').html("<%= j render 'web_links' %>") \ No newline at end of file +$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' if @bulletins %>") +$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>") \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/reload_web_links.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/reload_web_links.js.erb index 55f1bc96..d5abd76b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/reload_web_links.js.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/reload_web_links.js.erb @@ -1 +1 @@ -$('#bulletins_web_links_web_links').html("<%= j render 'web_links' id @web_links %>") \ No newline at end of file +$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>") \ No newline at end of file