Fix filter category in news

This commit is contained in:
Christophe Vilayphiou 2012-05-02 17:55:02 +08:00
parent b8cd7097b0
commit 45e21f9569
1 changed files with 7 additions and 14 deletions

View File

@ -62,30 +62,23 @@ class OrbitBackendController< ApplicationController
case key case key
when 'status' when 'status'
a = Array.new a = Array.new
objects.each do |bulletin| objects.each do |object|
value.each do |v| value.each do |v|
case v a << object if object[v]
when 'pending'
a << bulletin if bulletin.is_checked.nil?
when 'rejected'
a << bulletin if bulletin.is_checked.eql?(false)
else
a << bulletin if bulletin[v]
end
end end
end end
objects = a.uniq objects = a.uniq
when 'categories' when 'categories'
a = Array.new a = Array.new
objects.each do |bulletin| objects.each do |object|
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s) a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s)
end end
objects = a.uniq objects = a.uniq
when 'tags' when 'tags'
a = Array.new a = Array.new
objects.each do |bulletin| objects.each do |object|
bulletin.tags.each do |tag| object.tags.each do |tag|
a << bulletin if value.include?(tag.id.to_s) a << object if value.include?(tag.id.to_s)
end end
end end
objects = a.uniq objects = a.uniq