fix default widget query
This commit is contained in:
parent
87bc2852b3
commit
23516277f3
|
@ -12,22 +12,22 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
|
||||
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_objects = nil
|
||||
|
||||
if !params["tag_id"].blank?
|
||||
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
|
||||
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
|
||||
elsif params["category_id"].blank? #no tag no cate
|
||||
result = eval(@default_widget["query"])
|
||||
result = eval(@ori_query)
|
||||
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
|
||||
result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
||||
result.available_for_lang(I18n.locale).can_display
|
||||
end
|
||||
|
||||
def search_result
|
||||
|
|
Loading…
Reference in New Issue