fix default widget query
This commit is contained in:
parent
87bc2852b3
commit
23516277f3
|
@ -13,21 +13,21 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
def query_for_default_widget
|
def query_for_default_widget
|
||||||
|
|
||||||
@ori_class_name = @default_widget["query"].split('.')[0]
|
@ori_class_name = @default_widget["query"].split('.')[0]
|
||||||
|
@ori_query = @default_widget["query"]
|
||||||
result = nil
|
result = nil
|
||||||
result_objects = nil
|
result_objects = nil
|
||||||
|
|
||||||
if !params["tag_id"].blank?
|
if !params["tag_id"].blank?
|
||||||
if params["category_id"].blank? #has tag no cate
|
if params["category_id"].blank? #has tag no cate
|
||||||
result = @ori_class_name.constantize.where(:tagged_ids.in => params["tag_id"])
|
result = eval("#{@ori_query}.where(:tagged_ids.in => params['tag_id'])")
|
||||||
else #has tag and cate
|
else #has tag and cate
|
||||||
result = eval("#{@ori_class_name}.where(:#{get_category_field_name}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])")
|
result = eval("#{@ori_query}.where(:#{get_category_field_name}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])")
|
||||||
end
|
end
|
||||||
elsif params["category_id"].blank? #no tag no cate
|
elsif params["category_id"].blank? #no tag no cate
|
||||||
result = eval(@default_widget["query"])
|
result = eval(@ori_query)
|
||||||
else #no tag has cate
|
else #no tag has cate
|
||||||
result = eval("#{@ori_class_name}.where(:#{get_category_field_name}.in=>params['category_id'])")
|
result = eval("#{@ori_query}.where(:#{get_category_field_name}.in=>params['category_id'])")
|
||||||
end
|
end
|
||||||
result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
result.available_for_lang(I18n.locale).can_display
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_result
|
def search_result
|
||||||
|
|
Loading…
Reference in New Issue