Commit 40b3903afeb2c921abf36f3c5db9cffc16e1b888
Exists in
master
and in
29 other branches
Merge branch 'stable'
Showing
23 changed files
with
156 additions
and
23 deletions
Show diff stats
app/controllers/my_profile/profile_design_controller.rb
... | ... | @@ -25,6 +25,7 @@ class ProfileDesignController < BoxOrganizerController |
25 | 25 | blocks << DisabledEnterpriseMessageBlock |
26 | 26 | blocks << HighlightsBlock |
27 | 27 | blocks << FeaturedProductsBlock |
28 | + blocks << FansBlock | |
28 | 29 | end |
29 | 30 | |
30 | 31 | # product block exclusive for enterprises in environments that permits it | ... | ... |
app/controllers/public/profile_controller.rb
app/models/blog.rb
app/models/enterprise.rb
... | ... | @@ -8,6 +8,8 @@ class Enterprise < Organization |
8 | 8 | has_many :inputs, :through => :products |
9 | 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 | 13 | extra_data_for_index :product_categories |
12 | 14 | |
13 | 15 | N_('Organization website'); N_('Historic and current context'); N_('Activities short description'); N_('City'); N_('State'); N_('Country'); N_('ZIP code') | ... | ... |
... | ... | @@ -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 | 25 | profile.blocks.each do |block| |
26 | 26 | expire_timeout_fragment(block.cache_key) |
27 | 27 | end |
28 | + | |
29 | + expire_blogs(profile) if profile.organization? | |
28 | 30 | end |
29 | 31 | |
30 | 32 | def expire_statistics_block_cache(profile) |
31 | 33 | blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } |
32 | 34 | blocks.map(&:cache_key).each{|ck|expire_timeout_fragment(ck)} |
33 | 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 | 47 | end | ... | ... |
app/views/content_viewer/blog_page.rhtml
... | ... | @@ -9,5 +9,5 @@ |
9 | 9 | </div> |
10 | 10 | <hr class="pre-posts"/> |
11 | 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 | 13 | </div> | ... | ... |
app/views/favorite_enterprises/add.rhtml
... | ... | @@ -7,6 +7,6 @@ |
7 | 7 | <% form_tag do %> |
8 | 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 | 11 | <%= button(:cancel, _("No, I don't want"), :action => 'index') %> |
12 | 12 | <% end %> | ... | ... |
... | ... | @@ -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
lib/feed_updater.rb
... | ... | @@ -39,11 +39,12 @@ class FeedUpdater |
39 | 39 | ['TERM', 'INT'].each do |signal| |
40 | 40 | Signal.trap(signal) do |
41 | 41 | stop |
42 | - RAILS_DEFAULT_LOGGER.info("Feed updater exiting gracefully ...") | |
42 | + puts "Feed updater exiting gracefully ..." | |
43 | 43 | end |
44 | 44 | end |
45 | + puts "Feed updater started." | |
45 | 46 | run |
46 | - RAILS_DEFAULT_LOGGER.info("Feed updater exited.") | |
47 | + puts "Feed updater exited." | |
47 | 48 | end |
48 | 49 | |
49 | 50 | def run | ... | ... |
lib/noosfero.rb
public/500.html
... | ... | @@ -52,8 +52,8 @@ |
52 | 52 | <li><a href='/'>Go to the site home page</a></li> |
53 | 53 | </ul> |
54 | 54 | </div> |
55 | - | |
56 | - | |
55 | + | |
56 | + | |
57 | 57 | <div id='es' style='display: none' class='message'> |
58 | 58 | <h1>Temporary system problem</h1> |
59 | 59 | <p> |
... | ... | @@ -120,7 +120,7 @@ |
120 | 120 | <a href="javascript: display_error_message('en')">English</a> |
121 | 121 | |
122 | 122 | <a href="javascript: display_error_message('eo')">Esperanto</a> |
123 | - | |
123 | + | |
124 | 124 | <a href="javascript: display_error_message('es')">Español</a> |
125 | 125 | |
126 | 126 | <a href="javascript: display_error_message('fr')">Français</a> | ... | ... |
public/500.html.erb
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | |
17 | 17 | </div> |
18 | 18 | </div> |
19 | - <%- Noosfero.each_locale do |language_code,language_name| -%> | |
19 | + <% Noosfero.each_locale do |language_code,language_name| %> | |
20 | 20 | <% FastGettext.set_locale language_code %> |
21 | 21 | <div id='<%= language_code %>' style='display: none' class='message'> |
22 | 22 | <h1><%= _('Temporary system problem') %></h1> |
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | </div> |
31 | 31 | <% end %> |
32 | 32 | <div id='languages'> |
33 | - <%- Noosfero.each_locale do |language_code,language_name| -%> | |
33 | + <% Noosfero.each_locale do |language_code,language_name| %> | |
34 | 34 | <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a> |
35 | 35 | <% end %> |
36 | 36 | </div> | ... | ... |
public/503.html
... | ... | @@ -40,8 +40,8 @@ |
40 | 40 | This system is under maintainance. It should be back in a few moments. |
41 | 41 | </p> |
42 | 42 | </div> |
43 | - | |
44 | - | |
43 | + | |
44 | + | |
45 | 45 | <div id='es' style='display: none' class='message'> |
46 | 46 | <h1>System maintainance</h1> |
47 | 47 | <p> |
... | ... | @@ -88,7 +88,7 @@ |
88 | 88 | <a href="javascript: display_error_message('en')">English</a> |
89 | 89 | |
90 | 90 | <a href="javascript: display_error_message('eo')">Esperanto</a> |
91 | - | |
91 | + | |
92 | 92 | <a href="javascript: display_error_message('es')">Español</a> |
93 | 93 | |
94 | 94 | <a href="javascript: display_error_message('fr')">Français</a> | ... | ... |
public/503.html.erb
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | |
17 | 17 | </div> |
18 | 18 | </div> |
19 | - <%- Noosfero.each_locale do |language_code,language_name| -%> | |
19 | + <% Noosfero.each_locale do |language_code,language_name| %> | |
20 | 20 | <% FastGettext.set_locale language_code %> |
21 | 21 | <div id='<%= language_code %>' style='display: none' class='message'> |
22 | 22 | <h1><%= _('System maintainance') %></h1> |
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | </div> |
27 | 27 | <% end %> |
28 | 28 | <div id='languages'> |
29 | - <%- Noosfero.each_locale do |language_code,language_name| -%> | |
29 | + <% Noosfero.each_locale do |language_code,language_name| %> | |
30 | 30 | <a href="javascript: display_error_message('<%= language_code %>')"><%= language_name %></a> |
31 | 31 | <% end %> |
32 | 32 | </div> | ... | ... |
public/designs/themes/base/style.css
... | ... | @@ -915,14 +915,17 @@ X.sep { |
915 | 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 | 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 | 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 | 929 | text-decoration: underline; |
927 | 930 | } |
928 | 931 | ... | ... |
public/stylesheets/application.css
... | ... | @@ -4531,13 +4531,15 @@ h1#agenda-title { |
4531 | 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 | 4536 | padding: 0px 0px 4px 20px; |
4536 | 4537 | background-repeat: no-repeat; |
4537 | 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 | 4543 | background-color: transparent; |
4542 | 4544 | } |
4543 | 4545 | ... | ... |
script/feed-updater
... | ... | @@ -12,20 +12,22 @@ require 'optparse' |
12 | 12 | NOOSFERO_ROOT = File.expand_path(File.dirname(__FILE__) + '/../') |
13 | 13 | |
14 | 14 | options = { |
15 | + :app_name => 'feed-updater.default', | |
15 | 16 | :dir_mode => :normal, |
16 | 17 | :dir => File.dirname(__FILE__) + '/../tmp/pids', |
17 | 18 | :multiple => false, |
18 | 19 | :backtrace => true, |
20 | + :log_output => true, | |
19 | 21 | :monitor => false |
20 | 22 | } |
21 | 23 | |
22 | 24 | OptionParser.new do |opts| |
23 | 25 | opts.on("-i", "--identifier=i", "Id") do |i| |
24 | - options[:identifier] = i | |
26 | + options[:app_name] = "feed-updater.#{i}" | |
25 | 27 | end |
26 | 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 | 31 | require NOOSFERO_ROOT + '/config/environment' |
30 | 32 | FeedUpdater.new.start |
31 | 33 | end | ... | ... |
test/functional/profile_design_controller_test.rb
... | ... | @@ -10,7 +10,7 @@ class ProfileDesignControllerTest < Test::Unit::TestCase |
10 | 10 | PERSON_BLOCKS_WITH_MEMBERS = PERSON_BLOCKS + [MembersBlock] |
11 | 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 | 14 | ENTERPRISE_BLOCKS_WITH_PRODUCTS_ENABLE = ENTERPRISE_BLOCKS + [ProductsBlock] |
15 | 15 | |
16 | 16 | attr_reader :holder | ... | ... |
test/unit/blog_test.rb
... | ... | @@ -211,4 +211,11 @@ class BlogTest < ActiveSupport::TestCase |
211 | 211 | assert !folder.accept_uploads? |
212 | 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 | 221 | end | ... | ... |
test/unit/enterprise_test.rb
... | ... | @@ -49,6 +49,15 @@ class EnterpriseTest < Test::Unit::TestCase |
49 | 49 | end |
50 | 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 | 61 | should 'remove products when removing enterprise' do |
53 | 62 | e = fast_create(Enterprise, :name => "My enterprise", :identifier => 'myenterprise') |
54 | 63 | e.products.create!(:name => 'One product', :product_category => @product_category) | ... | ... |
... | ... | @@ -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 | + | ... | ... |