Commit b9d88f8825c3015bff31e6b70f7c0f26c9d6d567
Merge branch 'master' into 'categories_filter_387'
Divergência da informação do filtro de categorias Issue no repositório softwarepublico/noosfero: https://softwarepublico.gov.br/gitlab/softwarepublico/noosfero/issues/387 Issue no repositório softwarepublico/softwarepublico: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/issues/227 See merge request !16
Showing
6 changed files
with
63 additions
and
12 deletions
Show diff stats
lib/ext/search_controller.rb
| ... | ... | @@ -89,7 +89,7 @@ class SearchController |
| 89 | 89 | def get_communities_list software_list |
| 90 | 90 | filtered_community_list = [] |
| 91 | 91 | software_list.each do |software| |
| 92 | - if @all_selected || software.public_software? | |
| 92 | + if !@public_software_selected || software.public_software? | |
| 93 | 93 | filtered_community_list << software.community unless software.community.nil? |
| 94 | 94 | end |
| 95 | 95 | end | ... | ... |
lib/software_info.rb
| ... | ... | @@ -13,15 +13,15 @@ class SoftwareInfo < ActiveRecord::Base |
| 13 | 13 | DatabaseDescription |
| 14 | 14 | ] |
| 15 | 15 | |
| 16 | - scope :search_by_query, lambda {|query = ""| | |
| 16 | + scope :search_by_query, lambda { |query = ""| | |
| 17 | 17 | filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|') |
| 18 | 18 | search_fields = SoftwareInfo.pg_search_plugin_fields |
| 19 | 19 | |
| 20 | 20 | if query.empty? |
| 21 | - SoftwareInfo.all | |
| 21 | + SoftwareInfo.joins(:community).where("profiles.visible = ?", true) | |
| 22 | 22 | else |
| 23 | 23 | searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES) |
| 24 | - includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')") | |
| 24 | + includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ?", true) | |
| 25 | 25 | end |
| 26 | 26 | } |
| 27 | 27 | ... | ... |
test/functional/search_controller_test.rb
| ... | ... | @@ -214,6 +214,31 @@ class SearchControllerTest < ActionController::TestCase |
| 214 | 214 | assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community |
| 215 | 215 | end |
| 216 | 216 | |
| 217 | + should "software_infos search return only enabled softwares" do | |
| 218 | + s1 = SoftwareInfo.first | |
| 219 | + s2 = SoftwareInfo.last | |
| 220 | + | |
| 221 | + # First get them all normally | |
| 222 | + get( | |
| 223 | + :software_infos, | |
| 224 | + :query => "software" | |
| 225 | + ) | |
| 226 | + | |
| 227 | + assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
| 228 | + assert_includes assigns(:searches)[:software_infos][:results], s2.community | |
| 229 | + | |
| 230 | + s2.community.disable | |
| 231 | + | |
| 232 | + # Now it should not contain the disabled community | |
| 233 | + get( | |
| 234 | + :software_infos, | |
| 235 | + :query => "software" | |
| 236 | + ) | |
| 237 | + | |
| 238 | + assert_includes assigns(:searches)[:software_infos][:results], s1.community | |
| 239 | + assert_not_includes assigns(:searches)[:software_infos][:results], s2.community | |
| 240 | + end | |
| 241 | + | |
| 217 | 242 | private |
| 218 | 243 | |
| 219 | 244 | def create_software_categories | ... | ... |
views/blocks/categories_and_tags.html.erb
views/blocks/software_statistics.html.erb
| 1 | 1 | <div class="software-metrics-block"> |
| 2 | 2 | <ul class="metrics-list"> |
| 3 | - <li><span class="arrow-globe-icon"></span><%= pluralize(profile.hits, 'visita', 'visitas') %></li> | |
| 4 | - <li><span class="downloads-icon"></span><%= pluralize(total_downloads, 'download', 'downloads') %></li> | |
| 5 | - <li><span class="face-icon"></span><%= block.benefited_people.to_s + _(' benefited people*') %></li> | |
| 6 | - <li><span class="pig-safe-icon"></span><strong class="saved-money"><%= number_to_currency(block.saved_resources, unit: 'R$ ', separator: ',', delimiter: '.') %></strong> <%= _(' saved resources*') %></li> | |
| 3 | + <li> | |
| 4 | + <span class="arrow-globe-icon"></span> | |
| 5 | + <span id="visit-count"> | |
| 6 | + <%= pluralize(profile.hits, 'visita', 'visitas') %> | |
| 7 | + </span> | |
| 8 | + </li> | |
| 9 | + <li> | |
| 10 | + <span class="downloads-icon"></span> | |
| 11 | + <span id="downloads-count"> | |
| 12 | + <%= pluralize(total_downloads, 'download', 'downloads') %> | |
| 13 | + </span> | |
| 14 | + </li> | |
| 15 | + <li> | |
| 16 | + <span class="face-icon"></span> | |
| 17 | + <span id="benefited-people"> | |
| 18 | + <%= block.benefited_people.to_s + _(' benefited people*') %> | |
| 19 | + </span> | |
| 20 | + </li> | |
| 21 | + <li> | |
| 22 | + <span class="pig-safe-icon"></span> | |
| 23 | + <span id="saved-resources"> | |
| 24 | + <strong class="saved-money"> | |
| 25 | + <%= number_to_currency(block.saved_resources, unit: 'R$ ', | |
| 26 | + separator: ',', delimiter: '.') %> | |
| 27 | + </strong> | |
| 28 | + <%= _(' saved resources*') %> | |
| 29 | + </span> | |
| 30 | + </li> | |
| 7 | 31 | </ul> |
| 8 | 32 | |
| 9 | - <div class="admin-estimation">* <%= _("Data estimated by the software administrator.") %></div> | |
| 33 | + <div class="admin-estimation"> | |
| 34 | + * <%= _("Data estimated by the software administrator.") %> | |
| 35 | + </div> | |
| 10 | 36 | </div> | ... | ... |
views/organization_ratings_extra_fields_show_data.html.erb
| 1 | 1 | <div class="aditional-informations"> |
| 2 | 2 | <div class="comments-people-benefited"> |
| 3 | - <span>People benefited :</span> <%= user_rating.people_benefited unless user_rating.nil? %> | |
| 3 | + <span><%=_("Benefited People")%> :</span> <%= user_rating.people_benefited unless user_rating.nil? %> | |
| 4 | 4 | </div> |
| 5 | 5 | |
| 6 | 6 | <div class="comments-saved-value"> |
| 7 | - <span>Saved Value :</span> <%= user_rating.saved_value unless user_rating.nil? %> | |
| 7 | + <span><%=_("Saved Resources")%> :</span> <%= user_rating.saved_value unless user_rating.nil? %> | |
| 8 | 8 | </div> |
| 9 | 9 | </div> |
| 10 | 10 | ... | ... |