fix for bugs

This commit is contained in:
Matthew K. Fu JuYuan 2012-07-24 20:58:34 +08:00
parent 834fcddc52
commit 397b444390
2 changed files with 7 additions and 3 deletions

View File

@ -21,12 +21,16 @@ namespace :data_migration do
task :add_search_widget_to_news_and_announcement => :environment do task :add_search_widget_to_news_and_announcement => :environment do
app = ModuleApp.first({:conditions=>{:title => 'news'}}) app = ModuleApp.first({:conditions=>{:title => 'news'}})
app.widgets << "bulletins_search_block" if app.widgets.include?("bulletins_search_block") app.widgets << "news_bulletins_search_block" if !app.widgets.include?("news_bulletins_search_block")
app.save! app.save!
app = ModuleApp.first({:conditions=>{:title => 'Announcement'}}) app = ModuleApp.first({:conditions=>{:title => 'Announcement'}})
app.widgets << "news_bulletins_search_block" if app.widgets.include?("news_bulletins_search_block") app.widgets << "bulletins_search_block" if !app.widgets.include?("bulletins_search_block")
app.save! app.save!
p "==DO NOT FORGET TO RUN: rake redis_search:index" p "==DO NOT FORGET TO RUN: rake redis_search:index"
end end
task :add_search_func => :environment do
ModuleApp.create!(:key=>'search',:title => 'search',:enable_frontend=> true,:app_pages=>["full_search","optional_search"])
end
end end

View File

@ -14,7 +14,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
search = Redis::Search.query("Bulletin", params[:search_query], :conditions =>search_cond) search = Redis::Search.query("Bulletin", params[:search_query], :conditions =>search_cond)
search_result = search.collect{|t| t["id"]} search_result = search.collect{|t| t["id"]}
@news_bulletins = Bulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(10) @bulletins = Bulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(10)
else else
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?