Commit c4ad7b14d76ce7c579d9053c358a6b961992793b

Authored by Gabriela Navarro
Committed by Luciano Prestes
1 parent 6f4ed994

Filter the softwares by the category

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
Showing 1 changed file with 9 additions and 2 deletions   Show diff stats
lib/ext/search_controller.rb
... ... @@ -12,7 +12,14 @@ class SearchController
12 12 def software_infos
13 13 @titles[:software_infos] = "Software Infos"
14 14  
15   - results = filter_communities_list{|community| community.software?}
  15 + if params[:filter].blank?
  16 + results = filter_communities_list{|community| community.software?}
  17 + else
  18 + integer_filters = []
  19 + params[:filter].split(",").each{|f| integer_filters << f.to_i}
  20 + results = filter_communities_list{|community| community.software? && !(community.category_ids & integer_filters).blank?}
  21 + end
  22 +
16 23 results = results.paginate(:per_page => 24, :page => params[:page])
17 24 @searches[@asset] = {:results => results}
18 25 @search = results
... ... @@ -28,7 +35,7 @@ class SearchController
28 35 communities_list = []
29 36 unfiltered_list.each do |profile|
30 37 if profile.class == Community and yield(profile)
31   - communities_list << profile
  38 + communities_list << profile
32 39 end
33 40 end
34 41 communities_list
... ...