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
when 'status'
a = Array.new
objects.each do |bulletin|
objects.each do |object|
value.each do |v|
case 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
a << object if object[v]
end
end
objects = a.uniq
when 'categories'
a = Array.new
objects.each do |bulletin|
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
objects.each do |object|
a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s)
end
objects = a.uniq
when 'tags'
a = Array.new
objects.each do |bulletin|
bulletin.tags.each do |tag|
a << bulletin if value.include?(tag.id.to_s)
objects.each do |object|
object.tags.each do |tag|
a << object if value.include?(tag.id.to_s)
end
end
objects = a.uniq