Commit 14293f6a70e144230be45ab05665255a036383c9

Authored by David Silva
1 parent 49381d9f

Add catalog of institutions

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
lib/ext/search_controller.rb
@@ -9,6 +9,16 @@ class SearchController @@ -9,6 +9,16 @@ class SearchController
9 @search = results 9 @search = results
10 end 10 end
11 11
  12 + def institutions
  13 + @titles[:institutions] = _("Institution Catalog")
  14 + @category_filters = []
  15 + results = filter_communities_list{|community| community.institution?}
  16 + results = results.paginate(:per_page => 24, :page => params[:page])
  17 + @searches[@asset] = {:results => results}
  18 + @search = results
  19 + end
  20 +
  21 +
12 def software_infos 22 def software_infos
13 @titles[:software_infos] = _("Software Catalog") 23 @titles[:software_infos] = _("Software Catalog")
14 @category_filters = [] 24 @category_filters = []
@@ -40,4 +50,4 @@ class SearchController @@ -40,4 +50,4 @@ class SearchController
40 end 50 end
41 communities_list 51 communities_list
42 end 52 end
43 -end  
44 \ No newline at end of file 53 \ No newline at end of file
  54 +end
lib/ext/search_helper.rb
@@ -4,5 +4,6 @@ module SearchHelper @@ -4,5 +4,6 @@ module SearchHelper
4 4
5 COMMON_PROFILE_LIST_BLOCK ||= [] 5 COMMON_PROFILE_LIST_BLOCK ||= []
6 COMMON_PROFILE_LIST_BLOCK << :software_infos 6 COMMON_PROFILE_LIST_BLOCK << :software_infos
  7 + COMMON_PROFILE_LIST_BLOCK << :institutions
7 8
8 -end  
9 \ No newline at end of file 9 \ No newline at end of file
  10 +end
lib/institution.rb
1 class Institution < ActiveRecord::Base 1 class Institution < ActiveRecord::Base
  2 +
  3 + SEARCH_FILTERS = []
  4 + SEARCH_DISPLAYS = %w[compact]
  5 +
  6 + def self.default_search_display
  7 + 'compact'
  8 + end
  9 +
2 belongs_to :governmental_power 10 belongs_to :governmental_power
3 belongs_to :governmental_sphere 11 belongs_to :governmental_sphere
4 belongs_to :juridical_nature 12 belongs_to :juridical_nature
lib/software_info.rb
1 class SoftwareInfo < ActiveRecord::Base 1 class SoftwareInfo < ActiveRecord::Base
2 SEARCH_FILTERS = [] 2 SEARCH_FILTERS = []
3 - SEARCH_DISPLAYS = %w[full] 3 + SEARCH_DISPLAYS = %w[compact]
4 4
5 def self.default_search_display 5 def self.default_search_display
6 - 'full' 6 + 'compact'
7 end 7 end
8 8
9 attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform 9 attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform
test/functional/search_controller_test.rb
@@ -58,4 +58,15 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -58,4 +58,15 @@ class SearchControllerTest &lt; ActionController::TestCase
58 assert_not_includes assigns(:searches)[:software_infos][:results], software_without_category.community 58 assert_not_includes assigns(:searches)[:software_infos][:results], software_without_category.community
59 end 59 end
60 60
  61 + should "institutions_search don't have community or software" do
  62 + community = create_community("New Community")
  63 + software = create_software_info("New Software")
  64 + institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
  65 +
  66 + get :institutions, :query => "New"
  67 +
  68 + assert_includes assigns(:searches)[:institutions][:results], institution.community
  69 + assert_not_includes assigns(:searches)[:institutions][:results], community
  70 + assert_not_includes assigns(:searches)[:institutions][:results], software.community
  71 + end
61 end 72 end
views/search/institutions.html.erb 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +<%= search_page_title( @titles[@asset], @category ) %>
  2 +
  3 +<%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % @asset.to_s.singularize } %>
  4 +
  5 +<%= render :partial => 'results_header' %>
  6 +
  7 +<%= display_results(@searches, @asset) %>
  8 +<% if params[:display] != 'map' %>
  9 + <%= pagination_links @searches[@asset][:results] %>
  10 +<% end %>
  11 +
  12 +<div style="clear: both"></div>
  13 +
  14 +<% if @asset == :product %>
  15 + <%= javascript_tag do %>
  16 + jQuery('.search-product-price-details').altBeautify();
  17 + <% end %>
  18 +<% end %>