From 134b63946586f0888b90306655d8dfffd0cace3d Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Mon, 9 Sep 2013 17:35:22 +0800 Subject: [PATCH] fix announcement language --- app/controllers/default_widget_controller.rb | 18 +++++++----------- vendor/built_in_modules/announcement/init.rb | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 5ee604d59..25a8dc58d 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -12,24 +12,20 @@ class DefaultWidgetController< OrbitWidgetController def query_for_default_widget @ori_class_name = @default_widget["query"].split('.')[0] - @ori_query = @default_widget["query"] - result = nil - result_objects = nil - result = eval(@ori_query) + @result = eval(@default_widget["query"]) if !params["tag_id"].blank? if params["category_id"].blank? #has tag no cate - result.selector[:tagged_ids] = { "$in" => params['tag_id'] } + @result.selector[:tagged_ids] = { "$in" => params['tag_id'] } else #has tag and cate - result.selector[get_category_field_name] = { "$in" => params['category_id'].collect{|t| BSON::ObjectId(t)}} - result.selector[:tagged_ids] = { "$in" => params['tag_id'] } + @result.selector[get_category_field_name] = { "$in" => params['category_id'].collect{|t| BSON::ObjectId(t)}} + @result.selector[:tagged_ids] = { "$in" => params['tag_id'] } end elsif params["category_id"].blank? #no tag no cate - else #no tag has cate - result.selector[get_category_field_name] = { "$in" => params['category_id'].collect{|t| BSON::ObjectId(t)}} + + @result.selector[get_category_field_name] = { "$in" => params['category_id'].collect{|t| BSON::ObjectId(t)}} end - - eval("result.#{@default_widget[:sorting_query]}") + eval("@result.#{@default_widget[:sorting_query]}") end def search_result diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index 61191b9d9..86b66bb2f 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -30,7 +30,7 @@ module Announcement widgets do default_widget do sorting 'desc(:postdate)' - query 'Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' + query 'Bulletin.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' enable ["typeA","typeB_style3","typeC"] image :image field :postdate