Commit fba92e059456df3e3e3e9b4aa6491c37a1055d74
Exists in
master
and in
5 other branches
Merge branch 'software-catalog'
Showing
10 changed files
with
149 additions
and
45 deletions
Show diff stats
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
@@ -2,6 +2,8 @@ require_dependency 'search_helper' | @@ -2,6 +2,8 @@ require_dependency 'search_helper' | ||
2 | 2 | ||
3 | module SearchHelper | 3 | module SearchHelper |
4 | 4 | ||
5 | - COMMON_PROFILE_LIST_BLOCK << :software_infos | 5 | + COMMON_PROFILE_LIST_BLOCK ||= [] |
6 | + COMMON_PROFILE_LIST_BLOCK << :software_infos | ||
7 | + COMMON_PROFILE_LIST_BLOCK << :institutions | ||
6 | 8 | ||
7 | -end | ||
8 | \ 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[compact] | ||
4 | + | ||
5 | + def self.default_search_display | ||
6 | + 'compact' | ||
7 | + end | ||
3 | 8 | ||
4 | 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 |
5 | attr_accessible :demonstration_url, :acronym, :objectives, :features, :license_info | 10 | attr_accessible :demonstration_url, :acronym, :objectives, :features, :license_info |
@@ -50,10 +55,6 @@ class SoftwareInfo < ActiveRecord::Base | @@ -50,10 +55,6 @@ class SoftwareInfo < ActiveRecord::Base | ||
50 | } | 55 | } |
51 | } | 56 | } |
52 | 57 | ||
53 | - def self.default_search_display | ||
54 | - 'compact' | ||
55 | - end | ||
56 | - | ||
57 | def validate_name_lenght | 58 | def validate_name_lenght |
58 | if self.community.name.size > 100 | 59 | if self.community.name.size > 100 |
59 | self.errors.add(:base, _("Name is too long (maximum is %{count} characters)")) | 60 | self.errors.add(:base, _("Name is too long (maximum is %{count} characters)")) |
lib/softwares_block.rb
@@ -31,7 +31,7 @@ class SoftwaresBlock < CommunitiesBlock | @@ -31,7 +31,7 @@ class SoftwaresBlock < CommunitiesBlock | ||
31 | end | 31 | end |
32 | when Environment | 32 | when Environment |
33 | lambda do |context| | 33 | lambda do |context| |
34 | - link_to s_('softwares|View all'), :controller => 'search', :action => 'communities', :type => 'Software' | 34 | + link_to s_('softwares|View all'), :controller => 'search', :action => 'software_infos' |
35 | end | 35 | end |
36 | else | 36 | else |
37 | '' | 37 | '' |
public/style.css
@@ -197,4 +197,36 @@ | @@ -197,4 +197,36 @@ | ||
197 | 197 | ||
198 | .improve_input_size { | 198 | .improve_input_size { |
199 | width: 315px !important; | 199 | width: 315px !important; |
200 | +} | ||
201 | + | ||
202 | +.search-community-content-block span { | ||
203 | + width: auto; | ||
204 | +} | ||
205 | + | ||
206 | +#catalog-list ul li { | ||
207 | + display: inline; | ||
208 | + margin-right: 5px; | ||
209 | + font-size: 14px; | ||
210 | + padding: 5px; | ||
211 | + } | ||
212 | + | ||
213 | +#catalog-list ul li span { | ||
214 | + cursor: pointer; | ||
215 | + margin-left: 5px; | ||
216 | +} | ||
217 | + | ||
218 | +.catalog-remove-item { | ||
219 | + padding: 3px; | ||
220 | + border: solid 1px #999; | ||
221 | + border-radius: 3px; | ||
222 | +} | ||
223 | + | ||
224 | +.category_box { | ||
225 | + font-size: 11px; | ||
226 | + border:1px solid #e9e8ed; | ||
227 | + border-radius:8px; | ||
228 | + background-color:#e9e8ed; | ||
229 | + padding:3px 6px; | ||
230 | + margin:10px 3px; | ||
231 | + color: blue; | ||
200 | } | 232 | } |
201 | \ No newline at end of file | 233 | \ No newline at end of file |
test/functional/search_controller_test.rb
@@ -58,4 +58,15 @@ class SearchControllerTest < ActionController::TestCase | @@ -58,4 +58,15 @@ class SearchControllerTest < 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/_catalog_filter.html.erb
1 | -<!-- Remove CSS when design team send corrections --> | ||
2 | -<style type="text/css"> | ||
3 | - #catalog-list ul li { | ||
4 | - display: inline; | ||
5 | - margin-right: 5px; | ||
6 | - font-size: 14px; | ||
7 | - padding: 5px; | ||
8 | - } | ||
9 | - | ||
10 | - #catalog-list ul li span { | ||
11 | - display: none; | ||
12 | - cursor: pointer; | ||
13 | - } | ||
14 | - | ||
15 | - #catalog-list ul li:hover span { | ||
16 | - display: inline-block; | ||
17 | - } | ||
18 | - | ||
19 | - .catalog-remove-item { | ||
20 | - padding: 3px; | ||
21 | - border: solid 1px #999; | ||
22 | - border-radius: 3px; | ||
23 | - background: #d4d4d4; | ||
24 | - } | ||
25 | - | ||
26 | - .category_box { | ||
27 | - font-size: 11px !important; | ||
28 | - border:1px solid #e9e8ed; | ||
29 | - border-radius:8px; | ||
30 | - background-color:#e9e8ed; | ||
31 | - padding:3px 6px; | ||
32 | - margin:10px 3px; | ||
33 | - color: blue; | ||
34 | - } | ||
35 | -</style> | ||
36 | - | ||
37 | <div> | 1 | <div> |
38 | <div id="catalog-list"> | 2 | <div id="catalog-list"> |
39 | <ul> | 3 | <ul> |
@@ -46,6 +10,7 @@ | @@ -46,6 +10,7 @@ | ||
46 | </div> | 10 | </div> |
47 | 11 | ||
48 | <div id="catalog-filter"> | 12 | <div id="catalog-filter"> |
49 | - <%= text_field(:software, :catalog, :id=>"software-catalog") %> | 13 | + <span><%= _("Categories filter") %>:</span> |
14 | + <%= text_field(:software, :catalog, :id=>"software-catalog", :placeholder=>_("Type a category name here")) %> | ||
50 | </div> | 15 | </div> |
51 | </div> | 16 | </div> |
52 | \ No newline at end of file | 17 | \ No newline at end of file |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +<% software = community.software_info %> | ||
2 | +<li class="search-profile-item"> | ||
3 | + <div class="search-enterprise-item"> | ||
4 | + <div class="search-enterprise-item-column-left"> | ||
5 | + <%= profile_image_link community, :portrait, 'div', community.send(@filter + '_label') + show_date(community.created_at) %> | ||
6 | + </div> | ||
7 | + | ||
8 | + <div class="search-enterprise-item-column-right"> | ||
9 | + | ||
10 | + <div class="search-community-content-block"> | ||
11 | + <span> | ||
12 | + <% link_name = software.acronym.blank? ? community.name : "#{software.acronym} - #{community.name}" %> | ||
13 | + <%= link_to_homepage(link_name, community.identifier, :class => "search-result-title") %> | ||
14 | + </span> | ||
15 | + | ||
16 | + <p> | ||
17 | + <% body_stripped = strip_tags(software.finality) %> | ||
18 | + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> | ||
19 | + </p> | ||
20 | + </div> | ||
21 | + | ||
22 | + <div class="search-community-content-block"> | ||
23 | + <span> | ||
24 | + <%= _("Software licence") %>: | ||
25 | + <%= link_to(software.license_info.version, software.license_info.link, :target=>"blank", :class => "search-result-title") %> | ||
26 | + </span> | ||
27 | + </div> | ||
28 | + | ||
29 | + <div class="search-community-content-block"> | ||
30 | + <span> | ||
31 | + <%= _("Link software repository") %>: | ||
32 | + <%= link_to(software.repository_link, software.repository_link, :target=>"blank", :class => "search-result-title") %> | ||
33 | + </span> | ||
34 | + </div> | ||
35 | + | ||
36 | + <div class="search-community-content-block"> | ||
37 | + <span> | ||
38 | + <%= _("Software Categories") %> | ||
39 | + </span> | ||
40 | + | ||
41 | + <% if not community.categories.empty? %> | ||
42 | + <ul> | ||
43 | + <% community.categories.each do |category| %> | ||
44 | + <li> <%= category.name %> </li> | ||
45 | + <% end %> | ||
46 | + </ul> | ||
47 | + <% else %> | ||
48 | + <p> | ||
49 | + <span><%= _("This software doesn't has categories") %></span> | ||
50 | + </p> | ||
51 | + <% end %> | ||
52 | + </div> | ||
53 | + </div> | ||
54 | + | ||
55 | + <hr class="clearfix" /> | ||
56 | + </div> | ||
57 | +</li> |
@@ -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 %> |