fix announcement language

This commit is contained in:
Matt K. Fu 2013-09-09 17:35:22 +08:00
parent 45136f915d
commit 134b639465
2 changed files with 8 additions and 12 deletions

View File

@ -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

View File

@ -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