diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb
index 6101709..9abee36 100644
--- a/app/controllers/my_profile/profile_design_controller.rb
+++ b/app/controllers/my_profile/profile_design_controller.rb
@@ -5,7 +5,7 @@ class ProfileDesignController < BoxOrganizerController
protect 'edit_profile_design', :profile
def available_blocks
- blocks = [ ArticleBlock, TagsBlock, RecentDocumentsBlock, ProfileInfoBlock, LinkListBlock ]
+ blocks = [ ArticleBlock, TagsBlock, RecentDocumentsBlock, ProfileInfoBlock, LinkListBlock, MyNetworkBlock ]
# blocks exclusive for organizations
if profile.has_members?
@@ -16,7 +16,6 @@ class ProfileDesignController < BoxOrganizerController
if profile.person?
blocks << FriendsBlock
blocks << FavoriteEnterprisesBlock
- blocks << MyNetworkBlock
end
# product block exclusive for enterprises in environments that permits it
diff --git a/app/models/my_network_block.rb b/app/models/my_network_block.rb
index 9bae64c..1c37987 100644
--- a/app/models/my_network_block.rb
+++ b/app/models/my_network_block.rb
@@ -15,18 +15,13 @@ class MyNetworkBlock < Block
end
def content
- block_title(title) +
- content_tag(
- 'ul',
- content_tag('li', link_to(n_( 'One article published', '%s articles published', owner.articles.count) %
- content_tag('b', owner.articles.count), owner.public_profile_url.merge(:action => 'sitemap') )) +
- content_tag('li', link_to(n__('One friend', '%s friends', owner.friends.count) %
- content_tag('b', owner.friends.count), owner.public_profile_url.merge(:action => 'friends'))) +
- content_tag('li', link_to(n__('One community', '%s communities', owner.communities.size) %
- content_tag('b', owner.communities.size), owner.public_profile_url.merge(:action => 'communities'))) +
- content_tag('li', link_to(n_('One tag', '%s tags', owner.tags.size) %
- content_tag('b', owner.tags.size), owner.public_profile_url.merge(:action => 'tags')))
- )
+ block = self
+ lambda do
+ render :file => 'blocks/my_network', :locals => {
+ :title => block.title,
+ :owner => block.owner
+ }
+ end
end
end
diff --git a/app/views/blocks/my_network.rhtml b/app/views/blocks/my_network.rhtml
new file mode 100644
index 0000000..46ae190
--- /dev/null
+++ b/app/views/blocks/my_network.rhtml
@@ -0,0 +1,15 @@
+<%= block_title(title) %>
+
+<%= render :file => 'blocks/my_network/' + owner.class.name.underscore, :locals => { :owner => owner } %>
+
+
+ - <%= link_to(__('Homepage'), owner.url, :class => 'url') %>
+ - <%= link_to(_('View profile'), owner.public_profile_url) %>
+ <% if !user.nil? and owner.organization? and user.has_permission?('edit_profile', profile) %>
+ - <%= link_to _('Control panel'), :controller => 'profile_editor' %>
+ <% end %>
+
+
+
+ <%= render :file => 'blocks/profile_info_actions/' + owner.class.name.underscore %>
+
diff --git a/app/views/blocks/my_network/community.rhtml b/app/views/blocks/my_network/community.rhtml
new file mode 100644
index 0000000..e3b68d8
--- /dev/null
+++ b/app/views/blocks/my_network/community.rhtml
@@ -0,0 +1,8 @@
+
+ - <%= link_to(n_( 'One article published', '%s articles published', owner.articles.count) %
+ content_tag('b', owner.articles.count), owner.public_profile_url.merge(:action => 'sitemap') ) %>
+ - <%= link_to(n_( 'One member', '%s members', owner.members.count) %
+ content_tag('b', owner.members.count), owner.public_profile_url.merge(:action => 'members') ) %>
+ - <%= link_to(n_('One tag', '%s tags', owner.tags.size) %
+ content_tag('b', owner.tags.size), owner.public_profile_url.merge(:action => 'tags')) %>
+
diff --git a/app/views/blocks/my_network/enterprise.rhtml b/app/views/blocks/my_network/enterprise.rhtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/views/blocks/my_network/enterprise.rhtml
diff --git a/app/views/blocks/my_network/organization.rhtml b/app/views/blocks/my_network/organization.rhtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/views/blocks/my_network/organization.rhtml
diff --git a/app/views/blocks/my_network/person.rhtml b/app/views/blocks/my_network/person.rhtml
new file mode 100644
index 0000000..8a79188
--- /dev/null
+++ b/app/views/blocks/my_network/person.rhtml
@@ -0,0 +1,10 @@
+
+ - <%= link_to(n_( 'One article published', '%s articles published', owner.articles.count) %
+ content_tag('b', owner.articles.count), owner.public_profile_url.merge(:action => 'sitemap') ) %>
+ - <%= link_to(n__('One friend', '%s friends', owner.friends.count) %
+ content_tag('b', owner.friends.count), owner.public_profile_url.merge(:action => 'friends')) %>
+ - <%= link_to(n__('One community', '%s communities', owner.communities.size) %
+ content_tag('b', owner.communities.size), owner.public_profile_url.merge(:action => 'communities')) %>
+ - <%= link_to(n_('One tag', '%s tags', owner.tags.size) %
+ content_tag('b', owner.tags.size), owner.public_profile_url.merge(:action => 'tags')) %>
+
diff --git a/app/views/blocks/profile_info.rhtml b/app/views/blocks/profile_info.rhtml
index aee81f5..1a15b00 100644
--- a/app/views/blocks/profile_info.rhtml
+++ b/app/views/blocks/profile_info.rhtml
@@ -14,7 +14,6 @@
-
- <%= link_to __('Homepage'), block.owner.url, :class => 'url' %>
- <%= link_to _('View profile'), block.owner.public_profile_url %>
@@ -37,7 +36,7 @@
<% end %>
- <%= render :file => 'blocks/profile_info_actions/' + block.owner.class.name.underscore %>
+ <%= render :file => 'blocks/profile_info_actions/' + block.owner.class.name.underscore %>
diff --git a/public/designs/themes/zen3/stylesheets/blocks/my-network-block.css b/public/designs/themes/zen3/stylesheets/blocks/my-network-block.css
index 080413d..160bc3b 100644
--- a/public/designs/themes/zen3/stylesheets/blocks/my-network-block.css
+++ b/public/designs/themes/zen3/stylesheets/blocks/my-network-block.css
@@ -22,3 +22,16 @@
color: #600;
}
+
+.my-network-block .my-network-actions ul {
+ text-align: center;
+}
+
+.my-network-actions ul {
+ padding: 0;
+ padding-bottom: 10px;
+}
+
+.my-network-actions li {
+ list-style: none;
+}
diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb
index 25da40c..6e38d65 100644
--- a/test/functional/profile_controller_test.rb
+++ b/test/functional/profile_controller_test.rb
@@ -143,19 +143,33 @@ class ProfileControllerTest < Test::Unit::TestCase
should 'show a link to own control panel' do
login_as(@profile.identifier)
get :index, :profile => @profile.identifier
- assert_tag :tag => 'ul', :attributes => { :class => 'profile-info-data' }, :descendant => { :tag => 'a', :content => 'Control panel' }
+ assert_tag :tag => 'a', :content => 'Control panel'
+ end
+
+ should 'show a link to own control panel in my-network-block if is a group' do
+ login_as(@profile.identifier)
+ community = Community.create!(:name => 'my test community')
+ community.blocks.each{|i| i.destroy}
+ community.boxes[0].blocks << MyNetworkBlock.new
+ community.add_admin(@profile)
+ get :index, :profile => community.identifier
+ assert_tag :tag => 'a', :content => 'Control panel'
end
should 'not show a link to others control panel' do
login_as(@profile.identifier)
other = create_user('person_1').person
+ other.blocks.each{|i| i.destroy}
+ other.boxes[0].blocks << ProfileInfoBlock.new
get :index, :profile => other.identifier
assert_no_tag :tag => 'ul', :attributes => { :class => 'profile-info-data' }, :descendant => { :tag => 'a', :content => 'Control panel' }
end
- should 'show a link to control panel if user has profile_editor permission' do
+ should 'show a link to control panel if user has profile_editor permission and is a group' do
login_as(@profile.identifier)
- get :index, :profile => @profile.identifier
+ community = Community.create!(:name => 'my test community')
+ community.add_admin(@profile)
+ get :index, :profile => community.identifier
assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{@profile.identifier}" }, :content => 'Control panel'
end
@@ -251,8 +265,9 @@ class ProfileControllerTest < Test::Unit::TestCase
end
should 'display "Site map" link for profiles' do
- get :index, :profile => 'ze'
- assert_tag :tag => 'a', :content => "Site map", :attributes => { :href => '/profile/ze/sitemap' }
+ profile = create_user('testmapuser').person
+ get :index, :profile => profile.identifier
+ assert_tag :tag => 'a', :content => "Site map", :attributes => { :href => '/profile/testmapuser/sitemap' }
end
should 'list top level articles in sitemap' do
diff --git a/test/unit/my_network_block_test.rb b/test/unit/my_network_block_test.rb
index 10f6ed3..999ef75 100644
--- a/test/unit/my_network_block_test.rb
+++ b/test/unit/my_network_block_test.rb
@@ -19,62 +19,12 @@ class MyNetworkBlockTest < ActiveSupport::TestCase
assert_not_equal Block.new.default_title, MyNetworkBlock.new.default_title
end
- should 'count articles' do
- mock_articles = mock
- owner.stubs(:articles).returns(mock_articles)
- owner.stubs(:tags).returns({}) # don't let tags call articles
- mock_articles.stubs(:count).returns(5)
-
- assert_tag_in_string block.content, :tag => 'li', :descendant => {
- :tag => 'a',
- :descendant => { :tag => 'b', :content => '5' },
- :content => ' articles published',
- :attributes => { :href => /\/profile\/testuser\/sitemap$/ }
- }
- end
-
- should 'count friends' do
- mock_friends = mock
- owner.stubs(:friends).returns(mock_friends)
- mock_friends.stubs(:count).returns(8)
-
- assert_tag_in_string block.content, :tag => 'li', :descendant => {
- :tag => 'a',
- :descendant => { :tag => 'b', :content => '8' },
- :content => ' friends',
- :attributes => { :href => /\profile\/testuser\/friends/ }
- }
- end
-
- should 'count communities' do
- mock_communities = mock
- owner.stubs(:communities).returns(mock_communities)
- mock_communities.stubs(:size).returns(23)
-
- assert_tag_in_string block.content, :tag => 'li', :descendant => {
- :tag => 'a',
- :descendant => { :tag => 'b', :content => '23' },
- :content => ' communities',
- :attributes => { :href => /\profile\/testuser\/communities/ }
- }
- end
-
- should 'count tags' do
- mock_tags = mock
- owner.stubs(:tags).returns(mock_tags)
- mock_tags.stubs(:size).returns(436)
-
- assert_tag_in_string block.content, :tag => 'li', :descendant => {
- :tag => 'a',
- :descendant => { :tag => 'b', :content => '436' },
- :content => ' tags',
- :attributes => { :href => /\profile\/testuser\/tags/ }
- }
- end
-
- should 'display its title' do
- block.stubs(:title).returns('My Network')
- assert_tag_in_string block.content, :content => 'My Network'
+ should 'display my-profile' do
+ self.expects(:render).with(:file => 'blocks/my_network', :locals => {
+ :title => 'My network',
+ :owner => owner
+ })
+ instance_eval(& block.content)
end
end
--
libgit2 0.21.2