Commit 6ff873e11bcb0aaf56eccd3d9cce70e67d13c16a
1 parent
83c75a5c
Exists in
master
and in
28 other branches
ActionItem153: listing communities as well
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1278 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
7 additions
and
1 deletions
Show diff stats
app/models/environment.rb
@@ -41,6 +41,7 @@ class Environment < ActiveRecord::Base | @@ -41,6 +41,7 @@ class Environment < ActiveRecord::Base | ||
41 | has_many :organizations | 41 | has_many :organizations |
42 | has_many :enterprises | 42 | has_many :enterprises |
43 | has_many :people | 43 | has_many :people |
44 | + has_many :communities | ||
44 | 45 | ||
45 | has_many :categories | 46 | has_many :categories |
46 | has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color' | 47 | has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color' |
app/models/environment_statistics_block.rb
@@ -7,10 +7,12 @@ class EnvironmentStatisticsBlock < Block | @@ -7,10 +7,12 @@ class EnvironmentStatisticsBlock < Block | ||
7 | def content | 7 | def content |
8 | users = owner.people.count | 8 | users = owner.people.count |
9 | enterprises = owner.enterprises.count | 9 | enterprises = owner.enterprises.count |
10 | + communities = owner.communities.count | ||
10 | 11 | ||
11 | info = [ | 12 | info = [ |
12 | n_('One user', '%{num} users', users) % { :num => users }, | 13 | n_('One user', '%{num} users', users) % { :num => users }, |
13 | - n_('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises} | 14 | + n_('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }, |
15 | + n_('One community', '%{num} communities', communities) % { :num => communities }, | ||
14 | ] | 16 | ] |
15 | 17 | ||
16 | content_tag('h3', _('Statistics for %s') % owner.name, :class => 'block-title' ) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) | 18 | content_tag('h3', _('Statistics for %s') % owner.name, :class => 'block-title' ) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) |
test/unit/environment_statistics_block_test.rb
@@ -17,6 +17,8 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | @@ -17,6 +17,8 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | ||
17 | 17 | ||
18 | env.enterprises.build(:identifier => 'mytestenterprise', :name => 'My test enterprise').save! | 18 | env.enterprises.build(:identifier => 'mytestenterprise', :name => 'My test enterprise').save! |
19 | 19 | ||
20 | + env.communities.build(:identifier => 'mytestcommunity', :name => 'mytestcommunity').save! | ||
21 | + | ||
20 | block = EnvironmentStatisticsBlock.new | 22 | block = EnvironmentStatisticsBlock.new |
21 | env.boxes.first.blocks << block | 23 | env.boxes.first.blocks << block |
22 | 24 | ||
@@ -24,6 +26,7 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | @@ -24,6 +26,7 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | ||
24 | 26 | ||
25 | assert_match /One enterprise/, content | 27 | assert_match /One enterprise/, content |
26 | assert_match /2 users/, content | 28 | assert_match /2 users/, content |
29 | + assert_match /One community/, content | ||
27 | end | 30 | end |
28 | 31 | ||
29 | end | 32 | end |