Commit 40b3903afeb2c921abf36f3c5db9cffc16e1b888

Authored by Joenio Costa
2 parents dc6e9466 ac93f276

Merge branch 'stable'

app/controllers/my_profile/profile_design_controller.rb
@@ -25,6 +25,7 @@ class ProfileDesignController < BoxOrganizerController @@ -25,6 +25,7 @@ class ProfileDesignController < BoxOrganizerController
25 blocks << DisabledEnterpriseMessageBlock 25 blocks << DisabledEnterpriseMessageBlock
26 blocks << HighlightsBlock 26 blocks << HighlightsBlock
27 blocks << FeaturedProductsBlock 27 blocks << FeaturedProductsBlock
  28 + blocks << FansBlock
28 end 29 end
29 30
30 # product block exclusive for enterprises in environments that permits it 31 # product block exclusive for enterprises in environments that permits it
app/controllers/public/profile_controller.rb
@@ -71,6 +71,10 @@ class ProfileController &lt; PublicController @@ -71,6 +71,10 @@ class ProfileController &lt; PublicController
71 end 71 end
72 end 72 end
73 73
  74 + def fans
  75 + @fans = profile.fans
  76 + end
  77 +
74 def favorite_enterprises 78 def favorite_enterprises
75 @favorite_enterprises = profile.favorite_enterprises 79 @favorite_enterprises = profile.favorite_enterprises
76 end 80 end
app/models/blog.rb
@@ -72,4 +72,8 @@ class Blog &lt; Folder @@ -72,4 +72,8 @@ class Blog &lt; Folder
72 72
73 alias :display_posts_in_current_language? :display_posts_in_current_language 73 alias :display_posts_in_current_language? :display_posts_in_current_language
74 74
  75 + def empty?
  76 + posts.empty?
  77 + end
  78 +
75 end 79 end
app/models/enterprise.rb
@@ -8,6 +8,8 @@ class Enterprise &lt; Organization @@ -8,6 +8,8 @@ class Enterprise &lt; Organization
8 has_many :inputs, :through => :products 8 has_many :inputs, :through => :products
9 has_many :production_costs, :as => :owner 9 has_many :production_costs, :as => :owner
10 10
  11 + has_and_belongs_to_many :fans, :class_name => 'Person', :join_table => 'favorite_enteprises_people'
  12 +
11 extra_data_for_index :product_categories 13 extra_data_for_index :product_categories
12 14
13 N_('Organization website'); N_('Historic and current context'); N_('Activities short description'); N_('City'); N_('State'); N_('Country'); N_('ZIP code') 15 N_('Organization website'); N_('Historic and current context'); N_('Activities short description'); N_('City'); N_('State'); N_('Country'); N_('ZIP code')
app/models/fans_block.rb 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +class FansBlock < ProfileListBlock
  2 +
  3 + def self.description
  4 + _('Fans')
  5 + end
  6 +
  7 + def default_title
  8 + n__('{#} fan', '{#} fans', profile_count)
  9 + end
  10 +
  11 + def help
  12 + _('This block presents the fans of an enterprise.')
  13 + end
  14 +
  15 + def footer
  16 + profile = self.owner
  17 + lambda do
  18 + link_to _('View all'), :profile => profile.identifier, :controller =>
  19 + 'profile', :action => 'fans'
  20 + end
  21 + end
  22 +
  23 + def profiles
  24 + owner.fans
  25 + end
  26 +
  27 + def profile_count
  28 + profiles.visible.count
  29 + end
  30 +
  31 +end
app/sweepers/profile_sweeper.rb
@@ -25,10 +25,23 @@ protected @@ -25,10 +25,23 @@ protected
25 profile.blocks.each do |block| 25 profile.blocks.each do |block|
26 expire_timeout_fragment(block.cache_key) 26 expire_timeout_fragment(block.cache_key)
27 end 27 end
  28 +
  29 + expire_blogs(profile) if profile.organization?
28 end 30 end
29 31
30 def expire_statistics_block_cache(profile) 32 def expire_statistics_block_cache(profile)
31 blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } 33 blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) }
32 blocks.map(&:cache_key).each{|ck|expire_timeout_fragment(ck)} 34 blocks.map(&:cache_key).each{|ck|expire_timeout_fragment(ck)}
33 end 35 end
  36 +
  37 + def expire_blogs(profile)
  38 + profile.blogs.select{|b| !b.empty?}.each do |blog|
  39 + pages = blog.posts.count / blog.posts_per_page + 1
  40 + ([nil] + (1..pages).to_a).each do |i|
  41 + expire_timeout_fragment(blog.cache_key({:npage => i}))
  42 + expire_timeout_fragment(blog.cache_key({:npage => i}, profile))
  43 + end
  44 + end
  45 + end
  46 +
34 end 47 end
app/views/content_viewer/blog_page.rhtml
@@ -9,5 +9,5 @@ @@ -9,5 +9,5 @@
9 </div> 9 </div>
10 <hr class="pre-posts"/> 10 <hr class="pre-posts"/>
11 <div class="blog-posts"> 11 <div class="blog-posts">
12 - <%= (@posts.compact.empty? ? content_tag('em', _('(no posts)')) : list_posts(@posts, @page.visualization_format)) %> 12 + <%= (@page.empty? ? content_tag('em', _('(no posts)')) : list_posts(@posts, @page.visualization_format)) %>
13 </div> 13 </div>
app/views/favorite_enterprises/add.rhtml
@@ -7,6 +7,6 @@ @@ -7,6 +7,6 @@
7 <% form_tag do %> 7 <% form_tag do %>
8 <%= hidden_field_tag(:confirmation, 1) %> 8 <%= hidden_field_tag(:confirmation, 1) %>
9 9
10 - <%= submit_button(:ok, __("Yes, I want to add %s as a favorite enterprise") % @favorite_enterprise.name) %> 10 + <%= submit_button(:ok, __("Yes, I am sure"), :title => _("I want to add %s as a favorite enterprise") % @favorite_enterprise.name) %>
11 <%= button(:cancel, _("No, I don't want"), :action => 'index') %> 11 <%= button(:cancel, _("No, I don't want"), :action => 'index') %>
12 <% end %> 12 <% end %>
app/views/profile/fans.rhtml 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +<div class="common-profile-list-block">
  2 +
  3 +<h1><%= __("%s's fans") % profile.name %></h1>
  4 +
  5 +<ul class='profile-list'>
  6 +<% @fans.each do |person| %>
  7 + <li><%= profile_image_link(person)%></li>
  8 +<% end %>
  9 +</ul>
  10 +
  11 +<% button_bar do %>
  12 + <%= button :back, _('Go back'), { :controller => 'profile' }%>
  13 +<% end %>
  14 +
  15 +</div><!-- fim class="common-profile-list-block" -->
  16 +
debian/changelog
  1 +noosfero (0.30.2) unstable; urgency=low
  2 +
  3 + * Bugfix Version release.
  4 +
  5 + -- Joenio Costa <joenio@colivre.coop.br> Wed, 11 May 2011 21:48:31 -0300
  6 +
1 noosfero (0.30.1) unstable; urgency=low 7 noosfero (0.30.1) unstable; urgency=low
2 8
3 * Bugfix Version release. 9 * Bugfix Version release.
lib/feed_updater.rb
@@ -39,11 +39,12 @@ class FeedUpdater @@ -39,11 +39,12 @@ class FeedUpdater
39 ['TERM', 'INT'].each do |signal| 39 ['TERM', 'INT'].each do |signal|
40 Signal.trap(signal) do 40 Signal.trap(signal) do
41 stop 41 stop
42 - RAILS_DEFAULT_LOGGER.info("Feed updater exiting gracefully ...") 42 + puts "Feed updater exiting gracefully ..."
43 end 43 end
44 end 44 end
  45 + puts "Feed updater started."
45 run 46 run
46 - RAILS_DEFAULT_LOGGER.info("Feed updater exited.") 47 + puts "Feed updater exited."
47 end 48 end
48 49
49 def run 50 def run
lib/noosfero.rb
1 module Noosfero 1 module Noosfero
2 PROJECT = 'noosfero' 2 PROJECT = 'noosfero'
3 - VERSION = '0.30.1' 3 + VERSION = '0.30.2'
4 4
5 def self.pattern_for_controllers_in_directory(dir) 5 def self.pattern_for_controllers_in_directory(dir)
6 disjunction = controllers_in_directory(dir).join('|') 6 disjunction = controllers_in_directory(dir).join('|')
public/500.html
@@ -52,8 +52,8 @@ @@ -52,8 +52,8 @@
52 <li><a href='/'>Go to the site home page</a></li> 52 <li><a href='/'>Go to the site home page</a></li>
53 </ul> 53 </ul>
54 </div> 54 </div>
55 -  
56 - 55 +
  56 +
57 <div id='es' style='display: none' class='message'> 57 <div id='es' style='display: none' class='message'>
58 <h1>Temporary system problem</h1> 58 <h1>Temporary system problem</h1>
59 <p> 59 <p>
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 <a href="javascript: display_error_message('en')">English</a> 120 <a href="javascript: display_error_message('en')">English</a>
121 121
122 <a href="javascript: display_error_message('eo')">Esperanto</a> 122 <a href="javascript: display_error_message('eo')">Esperanto</a>
123 - 123 +
124 <a href="javascript: display_error_message('es')">Español</a> 124 <a href="javascript: display_error_message('es')">Español</a>
125 125
126 <a href="javascript: display_error_message('fr')">Français</a> 126 <a href="javascript: display_error_message('fr')">Français</a>
public/500.html.erb
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 &nbsp; 16 &nbsp;
17 </div> 17 </div>
18 </div> 18 </div>
19 - <%- Noosfero.each_locale do |language_code,language_name| -%> 19 + <% Noosfero.each_locale do |language_code,language_name| %>
20 <% FastGettext.set_locale language_code %> 20 <% FastGettext.set_locale language_code %>
21 <div id='<%= language_code %>' style='display: none' class='message'> 21 <div id='<%= language_code %>' style='display: none' class='message'>
22 <h1><%= _('Temporary system problem') %></h1> 22 <h1><%= _('Temporary system problem') %></h1>
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 </div> 30 </div>
31 <% end %> 31 <% end %>
32 <div id='languages'> 32 <div id='languages'>
33 - <%- Noosfero.each_locale do |language_code,language_name| -%> 33 + <% Noosfero.each_locale do |language_code,language_name| %>
34 <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a> 34 <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a>
35 <% end %> 35 <% end %>
36 </div> 36 </div>
public/503.html
@@ -40,8 +40,8 @@ @@ -40,8 +40,8 @@
40 This system is under maintainance. It should be back in a few moments. 40 This system is under maintainance. It should be back in a few moments.
41 </p> 41 </p>
42 </div> 42 </div>
43 -  
44 - 43 +
  44 +
45 <div id='es' style='display: none' class='message'> 45 <div id='es' style='display: none' class='message'>
46 <h1>System maintainance</h1> 46 <h1>System maintainance</h1>
47 <p> 47 <p>
@@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
88 <a href="javascript: display_error_message('en')">English</a> 88 <a href="javascript: display_error_message('en')">English</a>
89 89
90 <a href="javascript: display_error_message('eo')">Esperanto</a> 90 <a href="javascript: display_error_message('eo')">Esperanto</a>
91 - 91 +
92 <a href="javascript: display_error_message('es')">Español</a> 92 <a href="javascript: display_error_message('es')">Español</a>
93 93
94 <a href="javascript: display_error_message('fr')">Français</a> 94 <a href="javascript: display_error_message('fr')">Français</a>
public/503.html.erb
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 &nbsp; 16 &nbsp;
17 </div> 17 </div>
18 </div> 18 </div>
19 - <%- Noosfero.each_locale do |language_code,language_name| -%> 19 + <% Noosfero.each_locale do |language_code,language_name| %>
20 <% FastGettext.set_locale language_code %> 20 <% FastGettext.set_locale language_code %>
21 <div id='<%= language_code %>' style='display: none' class='message'> 21 <div id='<%= language_code %>' style='display: none' class='message'>
22 <h1><%= _('System maintainance') %></h1> 22 <h1><%= _('System maintainance') %></h1>
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 </div> 26 </div>
27 <% end %> 27 <% end %>
28 <div id='languages'> 28 <div id='languages'>
29 - <%- Noosfero.each_locale do |language_code,language_name| -%> 29 + <% Noosfero.each_locale do |language_code,language_name| %>
30 <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a> 30 <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a>
31 <% end %> 31 <% end %>
32 </div> 32 </div>
public/designs/themes/base/style.css
@@ -915,14 +915,17 @@ X.sep { @@ -915,14 +915,17 @@ X.sep {
915 height: 225px; 915 height: 225px;
916 } 916 }
917 917
918 -#content .search-results-type-article li { 918 +#content .search-results-type-article li,
  919 +#content .search-results-type-event li {
919 padding: 5px 0px; 920 padding: 5px 0px;
920 } 921 }
921 922
922 -.search-results-type-article a { 923 +.search-results-type-article a,
  924 +.search-results-type-event a {
923 text-decoration: none; 925 text-decoration: none;
924 } 926 }
925 -.search-results-type-article a:hover { 927 +.search-results-type-article a:hover,
  928 +.search-results-type-event a:hover {
926 text-decoration: underline; 929 text-decoration: underline;
927 } 930 }
928 931
public/stylesheets/application.css
@@ -4531,13 +4531,15 @@ h1#agenda-title { @@ -4531,13 +4531,15 @@ h1#agenda-title {
4531 padding: 2px 0px 4px 0px; 4531 padding: 2px 0px 4px 0px;
4532 } 4532 }
4533 4533
4534 -.controller-search #content .search-results-type-article li { 4534 +.controller-search #content .search-results-type-article li,
  4535 +.controller-search #content .search-results-type-event li {
4535 padding: 0px 0px 4px 20px; 4536 padding: 0px 0px 4px 20px;
4536 background-repeat: no-repeat; 4537 background-repeat: no-repeat;
4537 border-color: transparent; 4538 border-color: transparent;
4538 } 4539 }
4539 4540
4540 -.controller-search #content .search-results-type-article li:hover { 4541 +.controller-search #content .search-results-type-article li:hover,
  4542 +.controller-search #content .search-results-type-event li:hover {
4541 background-color: transparent; 4543 background-color: transparent;
4542 } 4544 }
4543 4545
script/feed-updater
@@ -12,20 +12,22 @@ require &#39;optparse&#39; @@ -12,20 +12,22 @@ require &#39;optparse&#39;
12 NOOSFERO_ROOT = File.expand_path(File.dirname(__FILE__) + '/../') 12 NOOSFERO_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
13 13
14 options = { 14 options = {
  15 + :app_name => 'feed-updater.default',
15 :dir_mode => :normal, 16 :dir_mode => :normal,
16 :dir => File.dirname(__FILE__) + '/../tmp/pids', 17 :dir => File.dirname(__FILE__) + '/../tmp/pids',
17 :multiple => false, 18 :multiple => false,
18 :backtrace => true, 19 :backtrace => true,
  20 + :log_output => true,
19 :monitor => false 21 :monitor => false
20 } 22 }
21 23
22 OptionParser.new do |opts| 24 OptionParser.new do |opts|
23 opts.on("-i", "--identifier=i", "Id") do |i| 25 opts.on("-i", "--identifier=i", "Id") do |i|
24 - options[:identifier] = i 26 + options[:app_name] = "feed-updater.#{i}"
25 end 27 end
26 end.parse!(ARGV) 28 end.parse!(ARGV)
27 29
28 -Daemons.run_proc("feed-updater.#{options[:identifier]}", options) do 30 +Daemons.run_proc(options[:app_name], options) do
29 require NOOSFERO_ROOT + '/config/environment' 31 require NOOSFERO_ROOT + '/config/environment'
30 FeedUpdater.new.start 32 FeedUpdater.new.start
31 end 33 end
test/functional/profile_design_controller_test.rb
@@ -10,7 +10,7 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase @@ -10,7 +10,7 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
10 PERSON_BLOCKS_WITH_MEMBERS = PERSON_BLOCKS + [MembersBlock] 10 PERSON_BLOCKS_WITH_MEMBERS = PERSON_BLOCKS + [MembersBlock]
11 PERSON_BLOCKS_WITH_BLOG = PERSON_BLOCKS + [BlogArchivesBlock] 11 PERSON_BLOCKS_WITH_BLOG = PERSON_BLOCKS + [BlogArchivesBlock]
12 12
13 - ENTERPRISE_BLOCKS = COMMOM_BLOCKS + [DisabledEnterpriseMessageBlock, HighlightsBlock, FeaturedProductsBlock] 13 + ENTERPRISE_BLOCKS = COMMOM_BLOCKS + [DisabledEnterpriseMessageBlock, HighlightsBlock, FeaturedProductsBlock, FansBlock]
14 ENTERPRISE_BLOCKS_WITH_PRODUCTS_ENABLE = ENTERPRISE_BLOCKS + [ProductsBlock] 14 ENTERPRISE_BLOCKS_WITH_PRODUCTS_ENABLE = ENTERPRISE_BLOCKS + [ProductsBlock]
15 15
16 attr_reader :holder 16 attr_reader :holder
test/unit/blog_test.rb
@@ -211,4 +211,11 @@ class BlogTest &lt; ActiveSupport::TestCase @@ -211,4 +211,11 @@ class BlogTest &lt; ActiveSupport::TestCase
211 assert !folder.accept_uploads? 211 assert !folder.accept_uploads?
212 end 212 end
213 213
  214 + should 'know when blog has or when has no posts' do
  215 + blog = fast_create(Blog)
  216 + assert blog.empty?
  217 + fast_create(TextileArticle, :parent_id => blog.id)
  218 + assert ! blog.empty?
  219 + end
  220 +
214 end 221 end
test/unit/enterprise_test.rb
@@ -49,6 +49,15 @@ class EnterpriseTest &lt; Test::Unit::TestCase @@ -49,6 +49,15 @@ class EnterpriseTest &lt; Test::Unit::TestCase
49 end 49 end
50 end 50 end
51 51
  52 + should 'have fans' do
  53 + p = fast_create(Person)
  54 + e = fast_create(Enterprise)
  55 +
  56 + p.favorite_enterprises << e
  57 +
  58 + assert_includes Enterprise.find(e.id).fans, p
  59 + end
  60 +
52 should 'remove products when removing enterprise' do 61 should 'remove products when removing enterprise' do
53 e = fast_create(Enterprise, :name => "My enterprise", :identifier => 'myenterprise') 62 e = fast_create(Enterprise, :name => "My enterprise", :identifier => 'myenterprise')
54 e.products.create!(:name => 'One product', :product_category => @product_category) 63 e.products.create!(:name => 'One product', :product_category => @product_category)
test/unit/fans_block_test.rb 0 → 100644
@@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class FansBlockTest < ActiveSupport::TestCase
  4 +
  5 + should 'inherit from ProfileListBlock' do
  6 + assert_kind_of ProfileListBlock, FansBlock.new
  7 + end
  8 +
  9 + should 'declare its default title' do
  10 + FansBlock.any_instance.stubs(:profile_count).returns(0)
  11 + assert_not_equal ProfileListBlock.new.default_title, FansBlock.new.default_title
  12 + end
  13 +
  14 + should 'describe itself' do
  15 + assert_not_equal ProfileListBlock.description, FansBlock.description
  16 + end
  17 +
  18 + should 'list owner fans' do
  19 +
  20 + block = FansBlock.new
  21 +
  22 + owner = mock
  23 + block.expects(:owner).returns(owner)
  24 +
  25 + list = []
  26 + owner.expects(:fans).returns(list)
  27 +
  28 + assert_same list, block.profiles
  29 + end
  30 +
  31 +end
  32 +