Commit cc3950d2bc580c0f45fa561f0ac4cf1c4770d229
Merge branch 'software_community_secret_237' into 'master'
Comunidade de Software sem Opção de Privacidade Secreta Issue no repositório softwarepublico/noosfero: https://softwarepublico.gov.br/gitlab/softwarepublico/noosfero/issues/389 Issue no repositório softwarepublico/softwarepublico: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/issues/237 See merge request !13
Showing
3 changed files
with
24 additions
and
1 deletions
Show diff stats
lib/ext/search_controller.rb
| @@ -61,6 +61,7 @@ class SearchController | @@ -61,6 +61,7 @@ class SearchController | ||
| 61 | 61 | ||
| 62 | def get_filtered_software_list | 62 | def get_filtered_software_list |
| 63 | params[:query] ||= "" | 63 | params[:query] ||= "" |
| 64 | + visible_communities = visible_profiles(Community) | ||
| 64 | 65 | ||
| 65 | filtered_software_list = SoftwareInfo.search_by_query(params[:query]) | 66 | filtered_software_list = SoftwareInfo.search_by_query(params[:query]) |
| 66 | 67 | ||
| @@ -70,6 +71,7 @@ class SearchController | @@ -70,6 +71,7 @@ class SearchController | ||
| 70 | @public_software_selected = false | 71 | @public_software_selected = false |
| 71 | end | 72 | end |
| 72 | 73 | ||
| 74 | + filtered_software_list.select!{ |software| visible_communities.include?(software.community) } | ||
| 73 | category_ids = get_filter_category_ids | 75 | category_ids = get_filter_category_ids |
| 74 | 76 | ||
| 75 | unless category_ids.empty? | 77 | unless category_ids.empty? |
test/functional/search_controller_test.rb
| @@ -214,6 +214,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -214,6 +214,7 @@ class SearchControllerTest < ActionController::TestCase | ||
| 214 | assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | 214 | assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community |
| 215 | end | 215 | end |
| 216 | 216 | ||
| 217 | +<<<<<<< 5ffa5a412be43c8ca9d1a07ed84a55503bb1a3fd | ||
| 217 | should "software_infos search return only enabled softwares" do | 218 | should "software_infos search return only enabled softwares" do |
| 218 | s1 = SoftwareInfo.first | 219 | s1 = SoftwareInfo.first |
| 219 | s2 = SoftwareInfo.last | 220 | s2 = SoftwareInfo.last |
| @@ -239,6 +240,23 @@ class SearchControllerTest < ActionController::TestCase | @@ -239,6 +240,23 @@ class SearchControllerTest < ActionController::TestCase | ||
| 239 | assert_not_includes assigns(:searches)[:software_infos][:results], s2.community | 240 | assert_not_includes assigns(:searches)[:software_infos][:results], s2.community |
| 240 | end | 241 | end |
| 241 | 242 | ||
| 243 | + should "software_infos search not return software with secret community" do | ||
| 244 | + software_one = create_software_info("Software ABC", :acronym => "SFO", :finality => "Help") | ||
| 245 | + software_two = create_software_info("Python", :acronym => "SFT", :finality => "Task") | ||
| 246 | + software_three = create_software_info("Software DEF", :acronym => "SFW", :finality => "Java") | ||
| 247 | + | ||
| 248 | + software_one.community.secret = true | ||
| 249 | + software_one.community.save! | ||
| 250 | + | ||
| 251 | + get( | ||
| 252 | + :software_infos, | ||
| 253 | + ) | ||
| 254 | + | ||
| 255 | + assert_includes assigns(:searches)[:software_infos][:results], software_two.community | ||
| 256 | + assert_includes assigns(:searches)[:software_infos][:results], software_three.community | ||
| 257 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | ||
| 258 | + end | ||
| 259 | + | ||
| 242 | private | 260 | private |
| 243 | 261 | ||
| 244 | def create_software_categories | 262 | def create_software_categories |
views/profile_editor/edit_software_community.html.erb
| @@ -32,6 +32,9 @@ | @@ -32,6 +32,9 @@ | ||
| 32 | </div> | 32 | </div> |
| 33 | <% else %> | 33 | <% else %> |
| 34 | <div> | 34 | <div> |
| 35 | + <%= labelled_check_box _("Secret — hide the community and all its contents for non members and other people can't join this community unless they are invited to."), 'profile_data[secret]', true, profile.secret, :class => "profile-secret-box" %> | ||
| 36 | + </div> | ||
| 37 | + <div> | ||
| 35 | <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> | 38 | <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> |
| 36 | </div> | 39 | </div> |
| 37 | <div> | 40 | <div> |
| @@ -84,4 +87,4 @@ | @@ -84,4 +87,4 @@ | ||
| 84 | <% end %> | 87 | <% end %> |
| 85 | <% end %> | 88 | <% end %> |
| 86 | <% end %> | 89 | <% end %> |
| 87 | -<% end %> | ||
| 88 | \ No newline at end of file | 90 | \ No newline at end of file |
| 91 | +<% end %> |