diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index f2420f0..f3ae44a 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -244,7 +244,11 @@ class SearchController < PublicController def visible_profiles(klass, *extra_relations) relations = [:image, :domains, :environment, :preferred_domain] relations += extra_relations - @environment.send(klass.name.underscore.pluralize).visible.includes(relations) + if current_user && current_user.person.is_admin? + @environment.send(klass.name.underscore.pluralize).includes(relations) + else + @environment.send(klass.name.underscore.pluralize).visible.includes(relations) + end end def per_page diff --git a/app/helpers/profile_image_helper.rb b/app/helpers/profile_image_helper.rb index 867aee8..563af12 100644 --- a/app/helpers/profile_image_helper.rb +++ b/app/helpers/profile_image_helper.rb @@ -114,7 +114,12 @@ module ProfileImageHelper end extra_info_tag = '' - img_class = 'profile-image' + + if profile.secret? + img_class = 'profile-image secret-profile' + else + img_class = 'profile-image' + end if extra_info.is_a? Hash extra_info_tag = content_tag( 'span', extra_info[:value], :class => 'extra_info '+extra_info[:class]) @@ -137,4 +142,4 @@ module ProfileImageHelper :title => profile.name ), :class => 'vcard'), :class => 'common-profile-list-block') end -end \ No newline at end of file +end diff --git a/public/stylesheets/blocks/profile-list.scss b/public/stylesheets/blocks/profile-list.scss index 18a9e6e..b2292b7 100644 --- a/public/stylesheets/blocks/profile-list.scss +++ b/public/stylesheets/blocks/profile-list.scss @@ -83,6 +83,12 @@ vertical-align: middle; height: 64px; } +.common-profile-list-block .secret-profile { + background: url(../images/hachure.png); + opacity: 0.25; + filter: alpha(opacity=5); + zoom: 1; +} .common-profile-list-block img { border: none; max-width: 50px; diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index d2e06b2..92b7d61 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -541,6 +541,16 @@ class SearchControllerTest < ActionController::TestCase assert_equal [c2,c1,c3] , assigns(:searches)[:communities][:results] end + should "only admin can view invisible people" do + # assuming that all filters behave the same! + p1 = fast_create(Person, :visible => false) + admin = create_user('admin').person; + Environment.default.add_admin admin + login_as("admin") + get :people, :order => 'more_recent' + assert_includes assigns(:searches)[:people][:results], p1 + end + should "only include visible people in more_recent filter" do # assuming that all filters behave the same! p1 = fast_create(Person, :visible => false) diff --git a/test/unit/profile_image_helper_test.rb b/test/unit/profile_image_helper_test.rb index a1a8e25..9d27cf3 100644 --- a/test/unit/profile_image_helper_test.rb +++ b/test/unit/profile_image_helper_test.rb @@ -135,4 +135,16 @@ class ProfileImageHelperTest < ActionView::TestCase NOOSFERO_CONF.stubs(:[]).with('gravatar').returns('nicevatar') assert_equal gravatar_default, 'nicevatar' end -end \ No newline at end of file + + should "secret-profile css applied in the secret profile image" do + @plugins = mock + @plugins.stubs(:dispatch_first).returns(false) + env = Environment.default + stubs(:environment).returns(env) + stubs(:profile).returns(profile) + profile = fast_create(Community, :environment_id => env.id, :secret => true) + info = {:value =>_('New'), :class => 'new-profile'} + html = profile_image_link(profile, size=:portrait, tag='li', extra_info = info) + assert_tag_in_string html, :tag => 'span', :attributes => { :class => 'profile-image secret-profile new-profile' } + end +end -- libgit2 0.21.2