From 5faa7e73c0f35fa9b7e85e76dff703524be4a305 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Wed, 11 Dec 2013 17:26:47 +0800 Subject: [PATCH] Fix links and remove unneeded codes --- .../announcement/widget/bulletins_controller.rb | 10 +--------- .../announcement/widget/bulletins/_index.html.erb | 15 ++++----------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index 9a9df527..855cdc31 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -33,15 +33,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @category_id = @part.category date_now = Time.now - if !@category_id.blank? - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - @current_category = BulletinCategory.from_id(@category_id) rescue nil - elsif !params[:tag_id].blank? - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - + if !params[:category_id].blank? && !params[:tag_id].blank? @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) # @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id]) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb index cf660e4a..86fe25d2 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb @@ -16,13 +16,13 @@ <% end %> - <% @bulletins.each do |post| %> + <% @posts.each do |post| %> <% @widget_fields.each do |wf| %> <% if wf[1] == 'title' %> - <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> + <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("category_id")) %> <% elsif wf[1] == 'date' %> <%= display_date(post.send(wf[0])) %> <% elsif wf[1] == 'category' %> @@ -52,13 +52,6 @@ <% end %> <% end %> - <% @posts.each do |post| %> - - <%= display_date(post.postdate) %> - <%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %> - - - <% end %>
<%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %>
@@ -68,14 +61,14 @@
    - <% @bulletins.each do |post| %> + <% @posts.each do |post| %>
  • <%= image_tag(post.image.url) %>
    <% @widget_fields.each do |wf| %> <% if wf[1] == 'title' %> - <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> + <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("category_id")) %> <% elsif wf[1] == 'date' %> <%= display_date(post.send(wf[0])) %> <% elsif wf[1] == 'category' %>