Commit 69cc2e431d4a1b76d97692355f5d1baffc965d63
1 parent
99872db5
Exists in
staging
and in
42 other branches
ActionItem543: changing default title of blocks
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2184 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
32 changed files
with
112 additions
and
40 deletions
Show diff stats
app/models/article_block.rb
app/models/block.rb
... | ... | @@ -47,7 +47,7 @@ class Block < ActiveRecord::Base |
47 | 47 | |
48 | 48 | # Is this block editable? (Default to <tt>false</tt>) |
49 | 49 | def editable? |
50 | - false | |
50 | + true | |
51 | 51 | end |
52 | 52 | |
53 | 53 | # must always return false, except on MainBlock clas. |
... | ... | @@ -63,4 +63,16 @@ class Block < ActiveRecord::Base |
63 | 63 | self.class.name.underscore.gsub('_', '-') |
64 | 64 | end |
65 | 65 | |
66 | + def default_title | |
67 | + '' | |
68 | + end | |
69 | + | |
70 | + def title | |
71 | + if self[:title].blank? | |
72 | + self.default_title | |
73 | + else | |
74 | + self[:title] | |
75 | + end | |
76 | + end | |
77 | + | |
66 | 78 | end | ... | ... |
app/models/communities_block.rb
app/models/enterprises_block.rb
app/models/environment_statistics_block.rb
... | ... | @@ -4,6 +4,10 @@ class EnvironmentStatisticsBlock < Block |
4 | 4 | _('Statistical overview of your environment.') |
5 | 5 | end |
6 | 6 | |
7 | + def default_title | |
8 | + _('Statistics for %s') % owner.name | |
9 | + end | |
10 | + | |
7 | 11 | def content |
8 | 12 | users = owner.people.count |
9 | 13 | enterprises = owner.enterprises.count |
... | ... | @@ -15,7 +19,7 @@ class EnvironmentStatisticsBlock < Block |
15 | 19 | n_('One community', '%{num} communities', communities) % { :num => communities }, |
16 | 20 | ] |
17 | 21 | |
18 | - block_title(_('Statistics for %s') % owner.name) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) | |
22 | + block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) | |
19 | 23 | end |
20 | 24 | |
21 | 25 | end | ... | ... |
app/models/favorite_enterprises_block.rb
app/models/friends_block.rb
app/models/main_block.rb
app/models/members_block.rb
app/models/people_block.rb
app/models/products_block.rb
... | ... | @@ -4,8 +4,12 @@ class ProductsBlock < Block |
4 | 4 | include ActionView::Helpers::UrlHelper |
5 | 5 | include ActionController::UrlWriter |
6 | 6 | |
7 | + def default_title | |
8 | + _('Products') | |
9 | + end | |
10 | + | |
7 | 11 | def content |
8 | - block_title(_('Products')) + | |
12 | + block_title(title) + | |
9 | 13 | content_tag( |
10 | 14 | 'ul', |
11 | 15 | products.map {|product| content_tag('li', link_to(product.name, product.url, :style => 'background-image:url(%s)' % ( product.image ? product.image.public_filename(:minor) : '/images/icons-app/product-default-pic-minor.png' )), :class => 'product' )} |
... | ... | @@ -37,8 +41,4 @@ class ProductsBlock < Block |
37 | 41 | end |
38 | 42 | end |
39 | 43 | |
40 | - def editable? | |
41 | - true | |
42 | - end | |
43 | - | |
44 | 44 | end | ... | ... |
app/models/profile_info_block.rb
app/models/profile_list_block.rb
app/models/recent_documents_block.rb
... | ... | @@ -4,13 +4,17 @@ class RecentDocumentsBlock < Block |
4 | 4 | _('List of recent content') |
5 | 5 | end |
6 | 6 | |
7 | + def default_title | |
8 | + _('Recent content') | |
9 | + end | |
10 | + | |
7 | 11 | settings_items :limit |
8 | 12 | |
9 | 13 | include ActionController::UrlWriter |
10 | 14 | def content |
11 | 15 | docs = self.limit.nil? ? owner.recent_documents : owner.recent_documents(self.limit) |
12 | 16 | |
13 | - block_title(_('Recent content')) + | |
17 | + block_title(title) + | |
14 | 18 | content_tag('ul', docs.map {|item| content_tag('li', link_to(item.title, item.url))}.join("\n")) |
15 | 19 | |
16 | 20 | end | ... | ... |
app/models/tags_block.rb
... | ... | @@ -8,6 +8,10 @@ class TagsBlock < Block |
8 | 8 | _('Block listing content count by tag') |
9 | 9 | end |
10 | 10 | |
11 | + def default_title | |
12 | + _('tags') | |
13 | + end | |
14 | + | |
11 | 15 | def help |
12 | 16 | _('The tag is created when you add some one to your article. <p/> |
13 | 17 | Try to add some tags to some articles and see your tag cloud to grow.') |
... | ... | @@ -17,7 +21,7 @@ class TagsBlock < Block |
17 | 21 | tags = owner.tags |
18 | 22 | return '' if tags.empty? |
19 | 23 | |
20 | - block_title( _('tags') ) + | |
24 | + block_title(title) + | |
21 | 25 | "\n<div class='tag_cloud'>\n"+ |
22 | 26 | tag_cloud( owner.tags, :id, |
23 | 27 | owner.generate_url(:controller => 'profile', :action => 'tag'), | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +<!-- empty --> | ... | ... |
app/views/box_organizer/edit.rhtml
test/unit/article_block_test.rb
test/unit/block_test.rb
... | ... | @@ -32,8 +32,20 @@ class BlockTest < Test::Unit::TestCase |
32 | 32 | assert_nil Block.new.footer |
33 | 33 | end |
34 | 34 | |
35 | - should 'not be editable by default' do | |
36 | - assert !Block.new.editable? | |
35 | + should 'provide an empty default title' do | |
36 | + assert_equal '', Block.new.default_title | |
37 | 37 | end |
38 | 38 | |
39 | + should 'be editable by default' do | |
40 | + assert Block.new.editable? | |
41 | + end | |
42 | + | |
43 | + should 'have default titles' do | |
44 | + b = Block.new | |
45 | + b.expects(:default_title).returns('my title') | |
46 | + assert_equal 'my title', b.title | |
47 | + end | |
48 | + | |
49 | + | |
50 | + | |
39 | 51 | end | ... | ... |
test/unit/communities_block_test.rb
... | ... | @@ -6,8 +6,8 @@ class CommunitiesBlockTest < Test::Unit::TestCase |
6 | 6 | assert_kind_of ProfileListBlock, CommunitiesBlock.new |
7 | 7 | end |
8 | 8 | |
9 | - should 'declare its title' do | |
10 | - assert_not_equal ProfileListBlock.new.title, CommunitiesBlock.new.title | |
9 | + should 'declare its default title' do | |
10 | + assert_not_equal ProfileListBlock.new.default_title, CommunitiesBlock.new.default_title | |
11 | 11 | end |
12 | 12 | |
13 | 13 | should 'describe itself' do | ... | ... |
test/unit/enterprises_block_test.rb
... | ... | @@ -6,8 +6,8 @@ class EnterprisesBlockTest < Test::Unit::TestCase |
6 | 6 | assert_kind_of ProfileListBlock, EnterprisesBlock.new |
7 | 7 | end |
8 | 8 | |
9 | - should 'declare its title' do | |
10 | - assert_not_equal ProfileListBlock.new.title, EnterprisesBlock.new.title | |
9 | + should 'declare its default title' do | |
10 | + assert_not_equal ProfileListBlock.new.default_title, EnterprisesBlock.new.default_title | |
11 | 11 | end |
12 | 12 | |
13 | 13 | should 'describe itself' do | ... | ... |
test/unit/environment_statistics_block_test.rb
... | ... | @@ -10,6 +10,15 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase |
10 | 10 | assert_not_equal Block.description, EnvironmentStatisticsBlock.description |
11 | 11 | end |
12 | 12 | |
13 | + should 'provide a default title' do | |
14 | + owner = mock | |
15 | + owner.expects(:name).returns('my environment') | |
16 | + | |
17 | + block = EnvironmentStatisticsBlock.new | |
18 | + block.expects(:owner).returns(owner) | |
19 | + assert_equal 'Statistics for my environment', block.title | |
20 | + end | |
21 | + | |
13 | 22 | should 'generate statistics' do |
14 | 23 | env = Environment.create!(:name => "My test environment") |
15 | 24 | user1 = create_user('testuser1', :environment_id => env.id) | ... | ... |
test/unit/favorite_enterprises_block_test.rb
... | ... | @@ -6,8 +6,8 @@ class FavoriteEnterprisesBlockTest < ActiveSupport::TestCase |
6 | 6 | assert_kind_of ProfileListBlock, FavoriteEnterprisesBlock.new |
7 | 7 | end |
8 | 8 | |
9 | - should 'declare its title' do | |
10 | - assert_not_equal ProfileListBlock.new.title, FavoriteEnterprisesBlock.new.title | |
9 | + should 'declare its default title' do | |
10 | + assert_not_equal ProfileListBlock.new.default_title, FavoriteEnterprisesBlock.new.default_title | |
11 | 11 | end |
12 | 12 | |
13 | 13 | should 'describe itself' do | ... | ... |
test/unit/friends_block_test.rb
... | ... | @@ -6,8 +6,8 @@ class FriendsBlockTest < ActiveSupport::TestCase |
6 | 6 | assert_not_equal ProfileListBlock.description, FriendsBlock.description |
7 | 7 | end |
8 | 8 | |
9 | - should 'declare its title' do | |
10 | - assert_not_equal ProfileListBlock.new.title, FriendsBlock.new.title | |
9 | + should 'declare its default title' do | |
10 | + assert_not_equal ProfileListBlock.new.default_title, FriendsBlock.new.default_title | |
11 | 11 | end |
12 | 12 | |
13 | 13 | should 'use its own finder' do | ... | ... |
test/unit/main_block_test.rb
test/unit/members_block_test.rb
... | ... | @@ -10,6 +10,10 @@ class MembersBlockTest < Test::Unit::TestCase |
10 | 10 | assert_not_equal ProfileListBlock.description, MembersBlock.description |
11 | 11 | end |
12 | 12 | |
13 | + should 'provide a default title' do | |
14 | + assert_not_equal ProfileListBlock.new.default_title, MembersBlock.new.default_title | |
15 | + end | |
16 | + | |
13 | 17 | should 'link to "all members" page' do |
14 | 18 | profile = create_user('mytestuser').person |
15 | 19 | block = MembersBlock.new | ... | ... |
test/unit/people_block_test.rb
... | ... | @@ -6,8 +6,8 @@ class PeopleBlockTest < ActiveSupport::TestCase |
6 | 6 | assert_kind_of ProfileListBlock, PeopleBlock.new |
7 | 7 | end |
8 | 8 | |
9 | - should 'declare its title' do | |
10 | - assert_not_equal ProfileListBlock.new.title, PeopleBlock.new.title | |
9 | + should 'declare its default title' do | |
10 | + assert_not_equal ProfileListBlock.new.default_title, PeopleBlock.new.default_title | |
11 | 11 | end |
12 | 12 | |
13 | 13 | should 'describe itself' do | ... | ... |
test/unit/products_block_test.rb
... | ... | @@ -11,6 +11,10 @@ class ProductsBlockTest < ActiveSupport::TestCase |
11 | 11 | assert_kind_of Block, block |
12 | 12 | end |
13 | 13 | |
14 | + should 'provide default title' do | |
15 | + assert_not_equal Block.new.default_title, ProductsBlock.new.default_title | |
16 | + end | |
17 | + | |
14 | 18 | should "list owner products" do |
15 | 19 | |
16 | 20 | enterprise = Enterprise.create!(:name => 'testenterprise', :identifier => 'testenterprise') |
... | ... | @@ -99,8 +103,4 @@ class ProductsBlockTest < ActiveSupport::TestCase |
99 | 103 | assert_equal [1, 2], block.product_ids |
100 | 104 | end |
101 | 105 | |
102 | - should 'be editable' do | |
103 | - assert ProductsBlock.new.editable? | |
104 | - end | |
105 | - | |
106 | 106 | end | ... | ... |
test/unit/profile_info_block_test.rb
... | ... | @@ -20,5 +20,9 @@ class ProfileInfoBlockTest < Test::Unit::TestCase |
20 | 20 | self.expects(:render).with(:file => 'blocks/profile_info', :locals => { :block => block}) |
21 | 21 | instance_eval(& block.content) |
22 | 22 | end |
23 | + | |
24 | + should 'not be editable' do | |
25 | + assert !ProfileInfoBlock.new.editable? | |
26 | + end | |
23 | 27 | |
24 | 28 | end | ... | ... |
test/unit/profile_list_block_test.rb
... | ... | @@ -6,6 +6,10 @@ class ProfileListBlockTest < Test::Unit::TestCase |
6 | 6 | assert_not_equal Block.description, ProfileListBlock.description |
7 | 7 | end |
8 | 8 | |
9 | + should 'provide a default title' do | |
10 | + assert_not_equal Block.new.default_title, ProfileListBlock.new.default_title | |
11 | + end | |
12 | + | |
9 | 13 | should 'accept a limit of people to be displayed (and default to 6)' do |
10 | 14 | block = ProfileListBlock.new |
11 | 15 | assert_equal 6, block.limit | ... | ... |
test/unit/recent_documents_block_test.rb
... | ... | @@ -18,6 +18,10 @@ class RecentDocumentsBlockTest < Test::Unit::TestCase |
18 | 18 | assert_not_equal Block.description, RecentDocumentsBlock.description |
19 | 19 | end |
20 | 20 | |
21 | + should 'provide a default title' do | |
22 | + assert_not_equal Block.new.default_title, RecentDocumentsBlock.new.default_title | |
23 | + end | |
24 | + | |
21 | 25 | should 'output list with links to recent documents' do |
22 | 26 | output = block.content |
23 | 27 | ... | ... |
test/unit/tags_block_test.rb
... | ... | @@ -17,6 +17,10 @@ class TagsBlockTest < Test::Unit::TestCase |
17 | 17 | assert_not_equal Block.description, TagsBlock.description |
18 | 18 | end |
19 | 19 | |
20 | + should 'provide a default title' do | |
21 | + assert_not_equal Block.new.default_title, TagsBlock.new.default_title | |
22 | + end | |
23 | + | |
20 | 24 | should 'generate links to tags' do |
21 | 25 | assert_match /profile\/testinguser\/tag\/first-tag/, block.content |
22 | 26 | assert_match /profile\/testinguser\/tag\/second-tag/, block.content | ... | ... |