From 029c84328dd0f823c08155ad949800ec52fa59e5 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 24 Sep 2012 15:37:28 +0800 Subject: [PATCH] code that can not run on matt's air --- .../panel/announcement/front_end/bulletins_controller.rb | 3 ++- vendor/built_in_modules/announcement/app/models/bulletin.rb | 3 +++ .../panel/news/front_end/news_bulletins_controller.rb | 6 ++++-- vendor/built_in_modules/news/app/models/news_bulletin.rb | 4 ++++ 4 files changed, 13 insertions(+), 3 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 69f96d91..0e95657a 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 @@ -21,9 +21,10 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController @search = Bulletin.solr_search do fulltext params[:search_query] with(:frontend_search,true) + with(:available_lang, [I18n.locale.to_s]) #order_by(:average_rating) end - search_result = @search.results.collect{|result| result.id} + search_result = @search.results.collect{|result| result.id}.desc(:postdate) @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(15) else diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 8fa86938..b03b07f2 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -69,6 +69,9 @@ class Bulletin text :texts do text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text} end + string :available_lang , :multiple => true do + VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?} + end # text :text do # a = (title_translations["zh_tw"] + title_translations["en"]) # a diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 9a05d943..53df67e4 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb @@ -19,13 +19,15 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController if !params[:search_query].blank? # search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false} # search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? - + binding.pry @search = NewsBulletin.solr_search do fulltext params[:search_query] with(:frontend_search,true) + with(:available_lang, [I18n.locale.to_s]) #order_by(:average_rating) end - search_result = @search.results.collect{|result| result.id} + binding.pry + search_result = @search.results.collect{|result| result.id}.desc(:postdate) @news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(10) else date_now = Time.now diff --git a/vendor/built_in_modules/news/app/models/news_bulletin.rb b/vendor/built_in_modules/news/app/models/news_bulletin.rb index 0da0bd70..8e43fd83 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -102,6 +102,10 @@ class NewsBulletin end integer :view_count + string :available_lang , :multiple => true do + VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?} + end + boolean :frontend_search do ( !is_hidden && !is_pending && is_checked && !is_rejected ) end