Commit c4ad7b14d76ce7c579d9053c358a6b961992793b
Committed by
Luciano Prestes
1 parent
6f4ed994
Exists in
master
and in
5 other branches
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,7 +12,14 @@ class SearchController | ||
12 | def software_infos | 12 | def software_infos |
13 | @titles[:software_infos] = "Software Infos" | 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 | results = results.paginate(:per_page => 24, :page => params[:page]) | 23 | results = results.paginate(:per_page => 24, :page => params[:page]) |
17 | @searches[@asset] = {:results => results} | 24 | @searches[@asset] = {:results => results} |
18 | @search = results | 25 | @search = results |
@@ -28,7 +35,7 @@ class SearchController | @@ -28,7 +35,7 @@ class SearchController | ||
28 | communities_list = [] | 35 | communities_list = [] |
29 | unfiltered_list.each do |profile| | 36 | unfiltered_list.each do |profile| |
30 | if profile.class == Community and yield(profile) | 37 | if profile.class == Community and yield(profile) |
31 | - communities_list << profile | 38 | + communities_list << profile |
32 | end | 39 | end |
33 | end | 40 | end |
34 | communities_list | 41 | communities_list |