From 9e432a5a93858235396e82ca0a7a52a34e6c59fd Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 8 Nov 2013 12:55:15 +0800 Subject: [PATCH] fixed announcement rendering.. --- .../front_end/bulletins_controller.rb | 40 ++++++++++--------- .../widget/bulletins_controller.rb | 6 +-- .../front_end/bulletins/index.html.erb | 1 - .../bulletins/search_result.html.erb | 3 +- .../widget/bulletins/index.html.erb | 4 +- 5 files changed, 27 insertions(+), 27 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 407a5e44f..b6e15a753 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,19 +9,30 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def search_result + if params[:search_query] == "" + @bulletins = get_bulletins_for_index + + else @search = Bulletin.solr_search do fulltext params[:search_query] with(:frontend_search,true) with(:available_lang).any_of([I18n.locale.to_s]) end - + # @bulletins = Bulletin.where(:category_id.in => params[:category_id]).and(:is_rejected=>false).and(:is_pending=>false) search_result = @search.results.collect{|result| result.id} @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num) + end end def index - @item = Page.find(params[:page_id]) rescue nil + + end + + def get_bulletins_for_index + + @item = Page.find(params[:page_id]) rescue nil + if @item if @item.frontend_data_count @page_num = @item.frontend_data_count @@ -30,33 +41,24 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end @frontend_style = @item.frontend_style end - @item = Page.find(params[:page_id]) rescue nil - if !params[:search_query].blank? - @search = Bulletin.solr_search do - fulltext params[:search_query] - with(:frontend_search,true) - with(:available_lang).any_of([I18n.locale.to_s]) - end - search_result = @search.results.collect{|result| result.id} - - @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num) - else + date_now = Time.now if !params[:category_id].blank? && !params[:tag_id].blank? - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id => params[:category_id], :tagged_ids => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) + @bulletins = 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) + # @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id]) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil + debugger elsif !params[:category_id].blank? - @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) + @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) else @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) end # delayed_impressionist(@tag) if @tag - end - - end + @bulletins + end def show @item = Page.find(params[:page_id]) rescue nil 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 45bb60cc3..ad86e7e0d 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 @@ -39,7 +39,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @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 - @categories = get_categories_for_index + @categories = @module_app.categories.enabled end @@ -62,7 +62,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @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 - @categories = get_categories_for_index + @categories = @module_app.categories.enabled end @@ -139,7 +139,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController def bulletins_side_bar @tags_and_class = @module_app.sorted_tags_for_cloud - @categories = get_categories_for_index + @categories = @module_app.categories.enabled end def bulletins_search_block 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 072f163a1..2438fd3b2 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 @@ -1,7 +1,6 @@ <% # encoding: utf-8 %> <%= flash_messages %> -

<%= @page.title rescue nil %>

diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/search_result.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/search_result.html.erb index 5f1892ef4..b7f27c009 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/search_result.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/search_result.html.erb @@ -1,7 +1,6 @@ <% # encoding: utf-8 %> <%= flash_messages %> -

<%= @page.title rescue nil %>

@@ -23,7 +22,7 @@ <% @bulletins.each do |post| %> - 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 a8c8c7587..a2f961381 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 @@ -1,6 +1,6 @@ <%= stylesheet_link_tag "default_widget" %> - - + +
<%= render 'index' %>
<%= post.bulletin_category.title rescue nil %><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> + <%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> <%= display_date_time(post.postdate) %>