Commit a8887fbb830f0b9a8e702a259e66bca1c07319f2
Committed by
Thiago Ribeiro
Exists in
master
and in
3 other branches
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
23 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
@@ -239,6 +239,23 @@ class SearchControllerTest < ActionController::TestCase | @@ -239,6 +239,23 @@ class SearchControllerTest < ActionController::TestCase | ||
239 | assert_not_includes assigns(:searches)[:software_infos][:results], s2.community | 239 | assert_not_includes assigns(:searches)[:software_infos][:results], s2.community |
240 | end | 240 | end |
241 | 241 | ||
242 | + should "software_infos search not return software with secret community" do | ||
243 | + software_one = create_software_info("Software ABC", :acronym => "SFO", :finality => "Help") | ||
244 | + software_two = create_software_info("Python", :acronym => "SFT", :finality => "Task") | ||
245 | + software_three = create_software_info("Software DEF", :acronym => "SFW", :finality => "Java") | ||
246 | + | ||
247 | + software_one.community.secret = true | ||
248 | + software_one.community.save! | ||
249 | + | ||
250 | + get( | ||
251 | + :software_infos, | ||
252 | + ) | ||
253 | + | ||
254 | + assert_includes assigns(:searches)[:software_infos][:results], software_two.community | ||
255 | + assert_includes assigns(:searches)[:software_infos][:results], software_three.community | ||
256 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | ||
257 | + end | ||
258 | + | ||
242 | private | 259 | private |
243 | 260 | ||
244 | def create_software_categories | 261 | 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 %> |