Commit 6ff873e11bcb0aaf56eccd3d9cce70e67d13c16a
1 parent
83c75a5c
Exists in
master
and in
23 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 | 41 | has_many :organizations |
| 42 | 42 | has_many :enterprises |
| 43 | 43 | has_many :people |
| 44 | + has_many :communities | |
| 44 | 45 | |
| 45 | 46 | has_many :categories |
| 46 | 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 | 7 | def content |
| 8 | 8 | users = owner.people.count |
| 9 | 9 | enterprises = owner.enterprises.count |
| 10 | + communities = owner.communities.count | |
| 10 | 11 | |
| 11 | 12 | info = [ |
| 12 | 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 | 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 | 17 | |
| 18 | 18 | env.enterprises.build(:identifier => 'mytestenterprise', :name => 'My test enterprise').save! |
| 19 | 19 | |
| 20 | + env.communities.build(:identifier => 'mytestcommunity', :name => 'mytestcommunity').save! | |
| 21 | + | |
| 20 | 22 | block = EnvironmentStatisticsBlock.new |
| 21 | 23 | env.boxes.first.blocks << block |
| 22 | 24 | |
| ... | ... | @@ -24,6 +26,7 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase |
| 24 | 26 | |
| 25 | 27 | assert_match /One enterprise/, content |
| 26 | 28 | assert_match /2 users/, content |
| 29 | + assert_match /One community/, content | |
| 27 | 30 | end |
| 28 | 31 | |
| 29 | 32 | end | ... | ... |