From 4d39d7f97266813f2a5ccfbca6fa9ed565c9913b Mon Sep 17 00:00:00 2001
From: MoisesMachado
Date: Fri, 15 Aug 2008 14:03:11 +0000
Subject: [PATCH] ActionItem616: added explanation and allowed friends
---
app/models/article.rb | 2 +-
app/models/person.rb | 8 ++++++++
app/views/profile_editor/edit.rhtml | 45 ++++++++++++++++++++++++++++++++++-----------
test/unit/article_test.rb | 9 +++++++++
test/unit/person_test.rb | 10 ++++++++++
test/unit/profile_test.rb | 1 -
6 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/app/models/article.rb b/app/models/article.rb
index f62769c..4cb47a4 100644
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -150,7 +150,7 @@ class Article < ActiveRecord::Base
if user.nil?
false
else
- (user == self.profile) || user.memberships.include?(self.profile)
+ (user == self.profile) || user.memberships.include?(self.profile) || (profile.kind_of?(Person) && profile.friends.include?(user))
end
end
end
diff --git a/app/models/person.rb b/app/models/person.rb
index 78ac739..61a7da0 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -93,4 +93,12 @@ class Person < Profile
['%s@%s' % [self.identifier, self.environment.default_hostname ] ]
end
+ def display_info_to?(user)
+ if friends.include?(user)
+ true
+ else
+ super
+ end
+ end
+
end
diff --git a/app/views/profile_editor/edit.rhtml b/app/views/profile_editor/edit.rhtml
index fdfe34d..e174caf 100644
--- a/app/views/profile_editor/edit.rhtml
+++ b/app/views/profile_editor/edit.rhtml
@@ -24,17 +24,40 @@
<%= _('Private') %>
-
- <%= _("This profile's content is:") %>
-
- <%= radio_button 'profile_data', 'public_content', 'true' %>
- <%= _('Public') %>
-
-
- <%= radio_button 'profile_data', 'public_content', 'false' %>
- <%= _('Private') %>
-
-
+
+ <% if profile.kind_of?(Person) %>
+
+ | <%= _('Public') %> | <%= _('Private') %> |
+
+ <%= _('Activate Intranet access (restricted area only for me)') %> | <%= _('Yes') %> | <%= _('Yes') %> |
+
+
+ <%= _('Show my website to all internet users') %> | <%= _('Yes') %> | <%= _('No') %> |
+
+
+ <%= _('Show my website to my contacts (persons)') %> | <%= _('Yes') %> | <%= _('Yes') %> |
+
+
+ <%= _('Include my contact in directory of people') %> | <%= _('Yes') %> | <%= _('No') %> |
+
+
+ <% else %>
+
+ | <%= _('Public') %> | <%= _('Private') %> |
+
+ <%= _('Activate Intranet access (restricted area only for members)') %> | <%= _('Yes') %> | <%= _('Yes') %> |
+
+
+ <%= _('Show website of this group to all internet users') %> | <%= _('Yes') %> | <%= _('No') %> |
+
+
+ <%= _('Show my website to members') %> | <%= _('Yes') %> | <%= _('Yes') %> |
+
+
+ <%= _('Include this group directory of groups') %> | <%= _('Yes') %> | <%= _('No') %> |
+
+
+ <% end %>
<%= select_categories(:profile_data, _('Select the categories of your interest'), 1) %>
diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb
index 07bba13..fd41e39 100644
--- a/test/unit/article_test.rb
+++ b/test/unit/article_test.rb
@@ -401,8 +401,17 @@ class ArticleTest < Test::Unit::TestCase
article.reload
assert !article.public_article
+ end
+ should 'allow friends of private person see the article' do
+ person = create_user('test_user').person
+ article = Article.create!(:name => 'test article', :profile => person, :public_article => false)
+ friend = create_user('test_friend').person
+ person.add_friend(friend)
+ person.save!
+ friend.save!
+ assert article.display_to?(friend)
end
end
diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb
index 712d736..739519f 100644
--- a/test/unit/person_test.rb
+++ b/test/unit/person_test.rb
@@ -268,5 +268,15 @@ class PersonTest < Test::Unit::TestCase
assert_equal ['testuser@somedomain.com'], person.email_addresses
end
+
+ should 'show profile info to friend' do
+ person = create_user('test_user').person
+ person.public_profile = false
+ person.save!
+ friend = create_user('test_friend').person
+ person.add_friend(friend)
+
+ assert person.display_info_to?(friend)
+ end
end
diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb
index c0f369c..da7c11c 100644
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -817,5 +817,4 @@ class ProfileTest < Test::Unit::TestCase
assert !profile.valid?
assert profile.errors.invalid?(:identifier)
end
-
end
--
libgit2 0.21.2