Commit 4d39d7f97266813f2a5ccfbca6fa9ed565c9913b
1 parent
c15a029c
Exists in
master
and in
28 other branches
ActionItem616: added explanation and allowed friends
added a table explaining the effects of being a private or public profile and allowed friend to see private profiles git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2399 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
62 additions
and
13 deletions
Show diff stats
app/models/article.rb
| @@ -150,7 +150,7 @@ class Article < ActiveRecord::Base | @@ -150,7 +150,7 @@ class Article < ActiveRecord::Base | ||
| 150 | if user.nil? | 150 | if user.nil? |
| 151 | false | 151 | false |
| 152 | else | 152 | else |
| 153 | - (user == self.profile) || user.memberships.include?(self.profile) | 153 | + (user == self.profile) || user.memberships.include?(self.profile) || (profile.kind_of?(Person) && profile.friends.include?(user)) |
| 154 | end | 154 | end |
| 155 | end | 155 | end |
| 156 | end | 156 | end |
app/models/person.rb
| @@ -93,4 +93,12 @@ class Person < Profile | @@ -93,4 +93,12 @@ class Person < Profile | ||
| 93 | ['%s@%s' % [self.identifier, self.environment.default_hostname ] ] | 93 | ['%s@%s' % [self.identifier, self.environment.default_hostname ] ] |
| 94 | end | 94 | end |
| 95 | 95 | ||
| 96 | + def display_info_to?(user) | ||
| 97 | + if friends.include?(user) | ||
| 98 | + true | ||
| 99 | + else | ||
| 100 | + super | ||
| 101 | + end | ||
| 102 | + end | ||
| 103 | + | ||
| 96 | end | 104 | end |
app/views/profile_editor/edit.rhtml
| @@ -24,17 +24,40 @@ | @@ -24,17 +24,40 @@ | ||
| 24 | <%= _('Private') %> | 24 | <%= _('Private') %> |
| 25 | </div> | 25 | </div> |
| 26 | </p> | 26 | </p> |
| 27 | - <p> | ||
| 28 | - <%= _("This profile's content is:") %> | ||
| 29 | - <div> | ||
| 30 | - <%= radio_button 'profile_data', 'public_content', 'true' %> | ||
| 31 | - <%= _('Public') %> | ||
| 32 | - </div> | ||
| 33 | - <div> | ||
| 34 | - <%= radio_button 'profile_data', 'public_content', 'false' %> | ||
| 35 | - <%= _('Private') %> | ||
| 36 | - </div> | ||
| 37 | - </p> | 27 | + |
| 28 | + <% if profile.kind_of?(Person) %> | ||
| 29 | + <table> | ||
| 30 | + <tr><th></th><th><%= _('Public') %></th><th><%= _('Private') %></th></tr> | ||
| 31 | + <tr> | ||
| 32 | + <td> <%= _('Activate Intranet access (restricted area only for me)') %> </td><td><%= _('Yes') %></td><td><%= _('Yes') %></td> | ||
| 33 | + </tr> | ||
| 34 | + <tr> | ||
| 35 | + <td> <%= _('Show my website to all internet users') %> </td><td><%= _('Yes') %></td><td><%= _('No') %></td> | ||
| 36 | + </tr> | ||
| 37 | + <tr> | ||
| 38 | + <td> <%= _('Show my website to my contacts (persons)') %> </td><td><%= _('Yes') %></td><td><%= _('Yes') %></td> | ||
| 39 | + </tr> | ||
| 40 | + <tr> | ||
| 41 | + <td> <%= _('Include my contact in directory of people') %> </td><td><%= _('Yes') %></td><td><%= _('No') %></td> | ||
| 42 | + </tr> | ||
| 43 | + </table> | ||
| 44 | + <% else %> | ||
| 45 | + <table> | ||
| 46 | + <tr><th></th><th><%= _('Public') %></th><th><%= _('Private') %></th></tr> | ||
| 47 | + <tr> | ||
| 48 | + <td> <%= _('Activate Intranet access (restricted area only for members)') %> </td><td><%= _('Yes') %></td><td><%= _('Yes') %></td> | ||
| 49 | + </tr> | ||
| 50 | + <tr> | ||
| 51 | + <td> <%= _('Show website of this group to all internet users') %> </td><td><%= _('Yes') %></td><td><%= _('No') %></td> | ||
| 52 | + </tr> | ||
| 53 | + <tr> | ||
| 54 | + <td> <%= _('Show my website to members') %> </td><td><%= _('Yes') %></td><td><%= _('Yes') %></td> | ||
| 55 | + </tr> | ||
| 56 | + <tr> | ||
| 57 | + <td> <%= _('Include this group directory of groups') %> </td><td><%= _('Yes') %></td><td><%= _('No') %></td> | ||
| 58 | + </tr> | ||
| 59 | + </table> | ||
| 60 | + <% end %> | ||
| 38 | 61 | ||
| 39 | <%= select_categories(:profile_data, _('Select the categories of your interest'), 1) %> | 62 | <%= select_categories(:profile_data, _('Select the categories of your interest'), 1) %> |
| 40 | 63 |
test/unit/article_test.rb
| @@ -401,8 +401,17 @@ class ArticleTest < Test::Unit::TestCase | @@ -401,8 +401,17 @@ class ArticleTest < Test::Unit::TestCase | ||
| 401 | article.reload | 401 | article.reload |
| 402 | 402 | ||
| 403 | assert !article.public_article | 403 | assert !article.public_article |
| 404 | + end | ||
| 404 | 405 | ||
| 406 | + should 'allow friends of private person see the article' do | ||
| 407 | + person = create_user('test_user').person | ||
| 408 | + article = Article.create!(:name => 'test article', :profile => person, :public_article => false) | ||
| 409 | + friend = create_user('test_friend').person | ||
| 410 | + person.add_friend(friend) | ||
| 411 | + person.save! | ||
| 412 | + friend.save! | ||
| 405 | 413 | ||
| 414 | + assert article.display_to?(friend) | ||
| 406 | end | 415 | end |
| 407 | 416 | ||
| 408 | end | 417 | end |
test/unit/person_test.rb
| @@ -268,5 +268,15 @@ class PersonTest < Test::Unit::TestCase | @@ -268,5 +268,15 @@ class PersonTest < Test::Unit::TestCase | ||
| 268 | 268 | ||
| 269 | assert_equal ['testuser@somedomain.com'], person.email_addresses | 269 | assert_equal ['testuser@somedomain.com'], person.email_addresses |
| 270 | end | 270 | end |
| 271 | + | ||
| 272 | + should 'show profile info to friend' do | ||
| 273 | + person = create_user('test_user').person | ||
| 274 | + person.public_profile = false | ||
| 275 | + person.save! | ||
| 276 | + friend = create_user('test_friend').person | ||
| 277 | + person.add_friend(friend) | ||
| 278 | + | ||
| 279 | + assert person.display_info_to?(friend) | ||
| 280 | + end | ||
| 271 | 281 | ||
| 272 | end | 282 | end |
test/unit/profile_test.rb
| @@ -817,5 +817,4 @@ class ProfileTest < Test::Unit::TestCase | @@ -817,5 +817,4 @@ class ProfileTest < Test::Unit::TestCase | ||
| 817 | assert !profile.valid? | 817 | assert !profile.valid? |
| 818 | assert profile.errors.invalid?(:identifier) | 818 | assert profile.errors.invalid?(:identifier) |
| 819 | end | 819 | end |
| 820 | - | ||
| 821 | end | 820 | end |