[Git][noosfero/noosfero][master] 2 commits: Change visibility to admins

Marcos Ronaldo Pereira Junior gitlab at mg.gitlab.com
Fri Apr 1 15:54:05 BRT 2016


Marcos Ronaldo Pereira Junior pushed to branch master at Noosfero / noosfero


Commits:
caf5954c by Thiago Ribeiro at 2016-04-01T14:33:22-03:00
Change visibility to admins

- Admins now can be see secret profiles
- Secret profiles are hachured in searches
- closes #176

Signed-off-by: Artur Bersan de Faria <arturbersan at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
Signed-off-by: Sabryna Sousa  <sabryna.sousa1323 at gmail.com>

- - - - -
6d94d28c by Marcos Ronaldo Pereira Junior at 2016-04-01T18:53:22+00:00
Merge branch 'admin_visible_profile' into 'master'

Change visibility to admins

- Admins now can be see secret profiles
- closes #176

Signed-off-by: Sabryna Souza <sabryna.sousa1323 at gmail.com>
Signed-off-by: Artur Bersan de Faria <arturbersan at gmail.com>

See merge request !828
- - - - -


5 changed files:

- app/controllers/public/search_controller.rb
- app/helpers/profile_image_helper.rb
- public/stylesheets/blocks/profile-list.scss
- test/functional/search_controller_test.rb
- test/unit/profile_image_helper_test.rb


Changes:

=====================================
app/controllers/public/search_controller.rb
=====================================
--- 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


=====================================
app/helpers/profile_image_helper.rb
=====================================
--- 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


=====================================
public/stylesheets/blocks/profile-list.scss
=====================================
--- 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;


=====================================
test/functional/search_controller_test.rb
=====================================
--- 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)


=====================================
test/unit/profile_image_helper_test.rb
=====================================
--- 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



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/5da12ce195320e5c6492d84d8ea815726007f362...6d94d28cc4c6fbdeec68653bba7a89d98f09d12c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160401/9d010889/attachment-0001.html>


More information about the Noosfero-dev mailing list