Commit 75e83af7cab6c22622b01af7b4a8bb01411e2c44

Authored by Joenio Costa
2 parents 22d3d9d3 beb5c6e4

Merge branch 'rails235' into AI3037-block_filter_user

Conflicts:
	public/stylesheets/application.css
	test/functional/environment_design_controller_test.rb
	test/unit/block_test.rb
Showing 195 changed files with 3987 additions and 579 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 195 files displayed.

@@ -7,6 +7,7 @@ Developers @@ -7,6 +7,7 @@ Developers
7 ========== 7 ==========
8 8
9 Alan Freihof Tygel <alantygel@gmail.com> 9 Alan Freihof Tygel <alantygel@gmail.com>
  10 +alcampelo <alcampelo@alcampelo.(none)>
10 Alessandro Palmeira <alessandro.palmeira@gmail.com> 11 Alessandro Palmeira <alessandro.palmeira@gmail.com>
11 Alessandro Palmeira + Caio C. Salgado <alessandro.palmeira@gmail.com> 12 Alessandro Palmeira + Caio C. Salgado <alessandro.palmeira@gmail.com>
12 Alessandro Palmeira + Caio Salgado <alessandro.palmeira@gmail.com> 13 Alessandro Palmeira + Caio Salgado <alessandro.palmeira@gmail.com>
@@ -38,6 +39,7 @@ Alessandro Palmeira + João M. M. Silva &lt;alessandro.palmeira@gmail.com&gt; @@ -38,6 +39,7 @@ Alessandro Palmeira + João M. M. Silva &lt;alessandro.palmeira@gmail.com&gt;
38 Alessandro Palmeira + Paulo Meirelles <alessandro.palmeira@gmail.com> 39 Alessandro Palmeira + Paulo Meirelles <alessandro.palmeira@gmail.com>
39 Alessandro Palmeira + Paulo Meirelles + João M. M. da Silva <alessandro.palmeira@gmail.com> 40 Alessandro Palmeira + Paulo Meirelles + João M. M. da Silva <alessandro.palmeira@gmail.com>
40 Alessandro Palmeira + Rafael Manzo <alessandro.palmeira@gmail.com> 41 Alessandro Palmeira + Rafael Manzo <alessandro.palmeira@gmail.com>
  42 +Ana Losnak <analosnak@gmail.com>
41 Antonio Terceiro + Carlos Morais <terceiro@colivre.coop.br> 43 Antonio Terceiro + Carlos Morais <terceiro@colivre.coop.br>
42 Antonio Terceiro + Paulo Meirelles <terceiro@colivre.coop.br> 44 Antonio Terceiro + Paulo Meirelles <terceiro@colivre.coop.br>
43 Antonio Terceiro <terceiro@colivre.coop.br> 45 Antonio Terceiro <terceiro@colivre.coop.br>
@@ -85,6 +87,7 @@ Daniel Alves + Rafael Manzo &lt;rr.manzo@gmail.com&gt; @@ -85,6 +87,7 @@ Daniel Alves + Rafael Manzo &lt;rr.manzo@gmail.com&gt;
85 Daniela Soares Feitosa <danielafeitosa@colivre.coop.br> 87 Daniela Soares Feitosa <danielafeitosa@colivre.coop.br>
86 Daniel Bucher <daniel.bucher88@gmail.com> 88 Daniel Bucher <daniel.bucher88@gmail.com>
87 Daniel Cunha <daniel@colivre.coop.br> 89 Daniel Cunha <daniel@colivre.coop.br>
  90 +David Carlos <ddavidcarlos1392@gmail.com>
88 diegoamc <diegoamc90@gmail.com> 91 diegoamc <diegoamc90@gmail.com>
89 Diego Araújo + Alessandro Palmeira <diegoamc90@gmail.com> 92 Diego Araújo + Alessandro Palmeira <diegoamc90@gmail.com>
90 Diego Araújo + Alessandro Palmeira + João M. M. da Silva <diegoamc90@gmail.com> 93 Diego Araújo + Alessandro Palmeira + João M. M. da Silva <diegoamc90@gmail.com>
@@ -114,12 +117,16 @@ Diego Martinez &lt;diegoamc90@gmail.com&gt; @@ -114,12 +117,16 @@ Diego Martinez &lt;diegoamc90@gmail.com&gt;
114 Diego Martinez <diego@diego-K55A.(none)> 117 Diego Martinez <diego@diego-K55A.(none)>
115 Diego + Renan <renanteruoc@gmail.com> 118 Diego + Renan <renanteruoc@gmail.com>
116 Eduardo Tourinho Edington <eduardo.edington@serpro.gov.br> 119 Eduardo Tourinho Edington <eduardo.edington@serpro.gov.br>
  120 +Fabio Teixeira <fabio1079@gmail.com>
117 Fernanda Lopes <nanda.listas+psl@gmail.com> 121 Fernanda Lopes <nanda.listas+psl@gmail.com>
118 Francisco Marcelo A. Lima Júnior <francisco.lima-junior@serpro.gov.br> 122 Francisco Marcelo A. Lima Júnior <francisco.lima-junior@serpro.gov.br>
119 Francisco Marcelo de Araujo Lima Junior <79350259591@serpro-1457614.(none)> 123 Francisco Marcelo de Araujo Lima Junior <79350259591@serpro-1457614.(none)>
120 Francisco Marcelo de Araújo Lima Júnior <francisco.lima-junior@serpro.gov.br> 124 Francisco Marcelo de Araújo Lima Júnior <francisco.lima-junior@serpro.gov.br>
121 Francisco Marcelo de Araújo Lima Júnior <maljunior@gmail.com> 125 Francisco Marcelo de Araújo Lima Júnior <maljunior@gmail.com>
  126 +Gabriela Navarro <navarro1703@gmail.com>
122 Grazieno Pellegrino <grazieno@gmail.com> 127 Grazieno Pellegrino <grazieno@gmail.com>
  128 +Gust <darksshades@hotmail.com>
  129 +Hugo Melo <hugo@riseup.net>
123 Isaac Canan <isaac@intelletto.com.br> 130 Isaac Canan <isaac@intelletto.com.br>
124 Italo Valcy <italo@dcc.ufba.br> 131 Italo Valcy <italo@dcc.ufba.br>
125 Jefferson Fernandes + Diego Araujo + Rafael Manzo <jeffs.fernandes@gmail.com> 132 Jefferson Fernandes + Diego Araujo + Rafael Manzo <jeffs.fernandes@gmail.com>
@@ -202,6 +209,7 @@ Renan Teruo + Diego Araujo &lt;renanteruoc@gmail.com&gt; @@ -202,6 +209,7 @@ Renan Teruo + Diego Araujo &lt;renanteruoc@gmail.com&gt;
202 Renan Teruo + Diego Araújo <renanteruoc@gmail.com> 209 Renan Teruo + Diego Araújo <renanteruoc@gmail.com>
203 Renan Teruo + Paulo Meirelles <renanteruoc@gmail.com> 210 Renan Teruo + Paulo Meirelles <renanteruoc@gmail.com>
204 Renan Teruo + Rafael Manzo <renanteruoc@gmail.com> 211 Renan Teruo + Rafael Manzo <renanteruoc@gmail.com>
  212 +Rodrigo Souto + Ana Losnak + Daniel Bucher + Caio Almeida + Leandro Nunes + Daniela Feitosa + Mariel Zasso <noosfero-br@listas.softwarelivre.org>
205 Rodrigo Souto <diguliu@gmail.com> 213 Rodrigo Souto <diguliu@gmail.com>
206 Rodrigo Souto <rodrigo@colivre.coop.br> 214 Rodrigo Souto <rodrigo@colivre.coop.br>
207 Ronny Kursawe <kursawe.ronny@googlemail.com> 215 Ronny Kursawe <kursawe.ronny@googlemail.com>
app/controllers/admin/environment_design_controller.rb
@@ -3,6 +3,8 @@ class EnvironmentDesignController &lt; BoxOrganizerController @@ -3,6 +3,8 @@ class EnvironmentDesignController &lt; BoxOrganizerController
3 protect 'edit_environment_design', :environment 3 protect 'edit_environment_design', :environment
4 4
5 def available_blocks 5 def available_blocks
  6 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  7 + # the Noosfero core soon, see ActionItem3045
6 @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ] 8 @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ]
7 @available_blocks += plugins.dispatch(:extra_blocks, :type => Environment) 9 @available_blocks += plugins.dispatch(:extra_blocks, :type => Environment)
8 end 10 end
app/controllers/admin/users_controller.rb
@@ -45,6 +45,20 @@ class UsersController &lt; AdminController @@ -45,6 +45,20 @@ class UsersController &lt; AdminController
45 redirect_to :action => :index, :q => params[:q], :filter => params[:filter] 45 redirect_to :action => :index, :q => params[:q], :filter => params[:filter]
46 end 46 end
47 47
  48 +
  49 + def destroy_user
  50 + if request.post?
  51 + person = environment.people.find_by_id(params[:id])
  52 + if person && person.destroy
  53 + session[:notice] = _('The profile was deleted.')
  54 + else
  55 + session[:notice] = _('Could not remove profile')
  56 + end
  57 + end
  58 + redirect_to :action => :index, :q => params[:q], :filter => params[:filter]
  59 + end
  60 +
  61 +
48 def download 62 def download
49 respond_to do |format| 63 respond_to do |format|
50 format.html 64 format.html
app/controllers/box_organizer_controller.rb
@@ -99,6 +99,12 @@ class BoxOrganizerController &lt; ApplicationController @@ -99,6 +99,12 @@ class BoxOrganizerController &lt; ApplicationController
99 end 99 end
100 end 100 end
101 101
  102 + def clone_block
  103 + block = Block.find(params[:id])
  104 + block.duplicate
  105 + redirect_to :action => 'index'
  106 + end
  107 +
102 protected :boxes_editor? 108 protected :boxes_editor?
103 109
104 end 110 end
app/controllers/my_profile/cms_controller.rb
@@ -24,10 +24,16 @@ class CmsController &lt; MyProfileController @@ -24,10 +24,16 @@ class CmsController &lt; MyProfileController
24 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) 24 (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
25 end 25 end
26 26
27 - protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files] do |c, user, profile| 27 + protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files, :new] do |c, user, profile|
28 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) 28 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))
29 end 29 end
30 30
  31 + protect_if :only => :new do |c, user, profile|
  32 + article = profile.articles.find_by_id(c.params[:parent_id])
  33 + (!article.nil? && (article.allow_create?(user) || article.parent.allow_create?(user))) ||
  34 + (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)))
  35 + end
  36 +
31 protect_if :only => [:destroy, :publish] do |c, user, profile| 37 protect_if :only => [:destroy, :publish] do |c, user, profile|
32 profile.articles.find(c.params[:id]).allow_post_content?(user) 38 profile.articles.find(c.params[:id]).allow_post_content?(user)
33 end 39 end
@@ -221,11 +227,10 @@ class CmsController &lt; MyProfileController @@ -221,11 +227,10 @@ class CmsController &lt; MyProfileController
221 227
222 def update_categories 228 def update_categories
223 @object = params[:id] ? @profile.articles.find(params[:id]) : Article.new 229 @object = params[:id] ? @profile.articles.find(params[:id]) : Article.new
  230 + @categories = @toplevel_categories = environment.top_level_categories
224 if params[:category_id] 231 if params[:category_id]
225 @current_category = Category.find(params[:category_id]) 232 @current_category = Category.find(params[:category_id])
226 @categories = @current_category.children 233 @categories = @current_category.children
227 - else  
228 - @categories = environment.top_level_categories.select{|i| !i.children.empty?}  
229 end 234 end
230 render :partial => 'shared/select_categories', :locals => {:object_name => 'article', :multiple => true}, :layout => false 235 render :partial => 'shared/select_categories', :locals => {:object_name => 'article', :multiple => true}, :layout => false
231 end 236 end
app/controllers/my_profile/profile_design_controller.rb
@@ -55,10 +55,4 @@ class ProfileDesignController &lt; BoxOrganizerController @@ -55,10 +55,4 @@ class ProfileDesignController &lt; BoxOrganizerController
55 blocks 55 blocks
56 end 56 end
57 57
58 - def clone  
59 - block = Block.find(params[:id])  
60 - block.duplicate  
61 - redirect_to :action => 'index'  
62 - end  
63 -  
64 end 58 end
app/controllers/my_profile/profile_editor_controller.rb
@@ -55,11 +55,10 @@ class ProfileEditorController &lt; MyProfileController @@ -55,11 +55,10 @@ class ProfileEditorController &lt; MyProfileController
55 55
56 def update_categories 56 def update_categories
57 @object = profile 57 @object = profile
  58 + @categories = @toplevel_categories = environment.top_level_categories
58 if params[:category_id] 59 if params[:category_id]
59 @current_category = Category.find(params[:category_id]) 60 @current_category = Category.find(params[:category_id])
60 @categories = @current_category.children 61 @categories = @current_category.children
61 - else  
62 - @categories = environment.top_level_categories.select{|i| !i.children.empty?}  
63 end 62 end
64 render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false 63 render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false
65 end 64 end
app/controllers/public/account_controller.rb
@@ -69,6 +69,8 @@ class AccountController &lt; ApplicationController @@ -69,6 +69,8 @@ class AccountController &lt; ApplicationController
69 session[:notice] = _("This environment doesn't allow user registration.") 69 session[:notice] = _("This environment doesn't allow user registration.")
70 end 70 end
71 71
  72 + store_location(request.referer) unless params[:return_to] or session[:return_to]
  73 +
72 @block_bot = !!session[:may_be_a_bot] 74 @block_bot = !!session[:may_be_a_bot]
73 @invitation_code = params[:invitation_code] 75 @invitation_code = params[:invitation_code]
74 begin 76 begin
@@ -77,6 +79,7 @@ class AccountController &lt; ApplicationController @@ -77,6 +79,7 @@ class AccountController &lt; ApplicationController
77 @user.environment = environment 79 @user.environment = environment
78 @terms_of_use = environment.terms_of_use 80 @terms_of_use = environment.terms_of_use
79 @user.person_data = params[:profile_data] 81 @user.person_data = params[:profile_data]
  82 + @user.return_to = session[:return_to]
80 @person = Person.new(params[:profile_data]) 83 @person = Person.new(params[:profile_data])
81 @person.environment = @user.environment 84 @person.environment = @user.environment
82 if request.post? 85 if request.post?
@@ -98,7 +101,7 @@ class AccountController &lt; ApplicationController @@ -98,7 +101,7 @@ class AccountController &lt; ApplicationController
98 end 101 end
99 if @user.activated? 102 if @user.activated?
100 self.current_user = @user 103 self.current_user = @user
101 - redirect_to '/' 104 + go_to_signup_initial_page
102 else 105 else
103 @register_pending = true 106 @register_pending = true
104 end 107 end
@@ -368,32 +371,29 @@ class AccountController &lt; ApplicationController @@ -368,32 +371,29 @@ class AccountController &lt; ApplicationController
368 end 371 end
369 372
370 def go_to_initial_page 373 def go_to_initial_page
  374 + if params[:redirection]
  375 + session[:return_to] = @user.return_to
  376 + @user.return_to = nil
  377 + @user.save
  378 + end
  379 +
371 if params[:return_to] 380 if params[:return_to]
372 redirect_to params[:return_to] 381 redirect_to params[:return_to]
373 elsif environment.enabled?('allow_change_of_redirection_after_login') 382 elsif environment.enabled?('allow_change_of_redirection_after_login')
374 - case user.preferred_login_redirection  
375 - when 'keep_on_same_page'  
376 - redirect_back_or_default(user.admin_url)  
377 - when 'site_homepage'  
378 - redirect_to :controller => :home  
379 - when 'user_profile_page'  
380 - redirect_to user.public_profile_url  
381 - when 'user_homepage'  
382 - redirect_to user.url  
383 - when 'user_control_panel'  
384 - redirect_to user.admin_url  
385 - else  
386 - redirect_back_or_default(user.admin_url)  
387 - end 383 + check_redirection_options(user, user.preferred_login_redirection, user.admin_url)
388 else 384 else
389 if environment == current_user.environment 385 if environment == current_user.environment
390 - redirect_back_or_default(user.admin_url) 386 + check_redirection_options(user, environment.redirection_after_login, user.admin_url)
391 else 387 else
392 redirect_back_or_default(:controller => 'home') 388 redirect_back_or_default(:controller => 'home')
393 end 389 end
394 end 390 end
395 end 391 end
396 392
  393 + def go_to_signup_initial_page
  394 + check_redirection_options(user, user.environment.redirection_after_signup, user.url)
  395 + end
  396 +
397 def redirect_if_logged_in 397 def redirect_if_logged_in
398 if logged_in? 398 if logged_in?
399 go_to_initial_page 399 go_to_initial_page
@@ -409,4 +409,22 @@ class AccountController &lt; ApplicationController @@ -409,4 +409,22 @@ class AccountController &lt; ApplicationController
409 user 409 user
410 end 410 end
411 411
  412 + protected
  413 +
  414 + def check_redirection_options(user, condition, default)
  415 + case condition
  416 + when 'keep_on_same_page'
  417 + redirect_back_or_default(user.admin_url)
  418 + when 'site_homepage'
  419 + redirect_to :controller => :home
  420 + when 'user_profile_page'
  421 + redirect_to user.public_profile_url
  422 + when 'user_homepage'
  423 + redirect_to user.url
  424 + when 'user_control_panel'
  425 + redirect_to user.admin_url
  426 + else
  427 + redirect_back_or_default(default)
  428 + end
  429 + end
412 end 430 end
app/controllers/public/profile_controller.rb
@@ -304,14 +304,6 @@ class ProfileController &lt; PublicController @@ -304,14 +304,6 @@ class ProfileController &lt; PublicController
304 end 304 end
305 end 305 end
306 306
307 - def profile_info  
308 - begin  
309 - @block = profile.blocks.find(params[:block_id])  
310 - rescue  
311 - render :text => _('Profile information could not be loaded')  
312 - end  
313 - end  
314 -  
315 def report_abuse 307 def report_abuse
316 @abuse_report = AbuseReport.new 308 @abuse_report = AbuseReport.new
317 render :layout => false 309 render :layout => false
app/controllers/themes_controller.rb
@@ -12,7 +12,7 @@ class ThemesController &lt; ApplicationController @@ -12,7 +12,7 @@ class ThemesController &lt; ApplicationController
12 12
13 def index 13 def index
14 @environment = environment 14 @environment = environment
15 - @themes = environment.themes + Theme.approved_themes(target) 15 + @themes = (environment.themes + Theme.approved_themes(target)).sort_by { |t| t.name }
16 16
17 @current_theme = target.theme 17 @current_theme = target.theme
18 18
app/helpers/application_helper.rb
@@ -608,49 +608,18 @@ module ApplicationHelper @@ -608,49 +608,18 @@ module ApplicationHelper
608 end 608 end
609 609
610 attr_reader :environment 610 attr_reader :environment
  611 +
611 def select_categories(object_name, title=nil, title_size=4) 612 def select_categories(object_name, title=nil, title_size=4)
612 return nil if environment.enabled?(:disable_categories) 613 return nil if environment.enabled?(:disable_categories)
613 if title.nil? 614 if title.nil?
614 title = _('Categories') 615 title = _('Categories')
615 end 616 end
616 617
617 - object = instance_variable_get("@#{object_name}")  
618 -  
619 - result = content_tag 'h'+title_size.to_s(), title  
620 - result << javascript_tag( 'function open_close_cat( link ) {  
621 - var div = link.parentNode.getElementsByTagName("div")[0];  
622 - var end = function(){  
623 - if ( div.style.display == "none" ) {  
624 - this.link.className="button icon-button icon-down"  
625 - } else {  
626 - this.link.className="button icon-button icon-up-red"  
627 - }  
628 - }  
629 - Effect.toggle( div, "slide", { link:link, div:div, afterFinish:end } )  
630 - }')  
631 - environment.top_level_categories.select{|i| !i.children.empty?}.each do |toplevel|  
632 - next unless object.accept_category?(toplevel)  
633 - # FIXME  
634 - ([toplevel] + toplevel.children_for_menu).each do |cat|  
635 - if cat.top_level?  
636 - result << '<div class="categorie_box">'.html_safe  
637 - result << icon_button( :down, _('open'), '#', :onclick => 'open_close_cat(this); return false' )  
638 - result << content_tag('h5', toplevel.name)  
639 - result << '<div style="display:none"><ul class="categories">'.html_safe  
640 - else  
641 - checkbox_id = "#{object_name}_#{cat.full_name.downcase.gsub(/\s+|\//, '_')}"  
642 - result << content_tag('li', labelled_check_box(  
643 - cat.full_name_without_leading(1, " &rarr; "),  
644 - "#{object_name}[category_ids][]", cat.id,  
645 - object.category_ids.include?(cat.id), :id => checkbox_id,  
646 - :onchange => 'this.parentNode.className=(this.checked?"cat_checked":"")' ),  
647 - :class => ( object.category_ids.include?(cat.id) ? 'cat_checked' : '' ) ) + "\n"  
648 - end  
649 - end  
650 - result << '</ul></div></div>'.html_safe  
651 - end 618 + @object = instance_variable_get("@#{object_name}")
  619 + @categories = environment.top_level_categories
652 620
653 - content_tag('div', result) 621 + @current_categories = environment.top_level_categories.select{|i| !i.children.empty?}
  622 + render :partial => 'shared/select_categories_top', :locals => {:object_name => object_name, :title => title, :title_size => title_size, :multiple => true, :categories_selected => @object.categories }, :layout => false
654 end 623 end
655 624
656 def theme_option(opt = nil) 625 def theme_option(opt = nil)
@@ -920,12 +889,11 @@ module ApplicationHelper @@ -920,12 +889,11 @@ module ApplicationHelper
920 889
921 def page_title 890 def page_title
922 (@page ? @page.title + ' - ' : '') + 891 (@page ? @page.title + ' - ' : '') +
923 - (profile ? profile.short_name + ' - ' : '') +  
924 (@topic ? @topic.title + ' - ' : '') + 892 (@topic ? @topic.title + ' - ' : '') +
925 (@section ? @section.title + ' - ' : '') + 893 (@section ? @section.title + ' - ' : '') +
926 (@toc ? _('Online Manual') + ' - ' : '') + 894 (@toc ? _('Online Manual') + ' - ' : '') +
927 (@controller.controller_name == 'chat' ? _('Chat') + ' - ' : '') + 895 (@controller.controller_name == 'chat' ? _('Chat') + ' - ' : '') +
928 - environment.name + 896 + (profile ? profile.short_name : environment.name) +
929 (@category ? " - #{@category.full_name}" : '') 897 (@category ? " - #{@category.full_name}" : '')
930 end 898 end
931 899
app/helpers/article_helper.rb
@@ -49,8 +49,14 @@ module ArticleHelper @@ -49,8 +49,14 @@ module ArticleHelper
49 'div', 49 'div',
50 check_box(:article, :display_versions) + 50 check_box(:article, :display_versions) +
51 content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions') 51 content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions')
52 - ) : '') 52 + ) : '') +
53 53
  54 + (article.forum? && article.profile.community? ?
  55 + content_tag(
  56 + 'div',
  57 + check_box(:article, :allows_members_to_create_topics) +
  58 + content_tag('label', _('Allow members to create topics'), :for => 'article_allows_members_to_create_topics')
  59 + ) : '')
54 ) 60 )
55 end 61 end
56 62
app/helpers/boxes_helper.rb
@@ -223,7 +223,7 @@ module BoxesHelper @@ -223,7 +223,7 @@ module BoxesHelper
223 223
224 if !block.main? 224 if !block.main?
225 buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post', :confirm => _('Are you sure you want to remove this block?')}) 225 buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post', :confirm => _('Are you sure you want to remove this block?')})
226 - buttons << icon_button(:clone, _('Clone'), { :action => 'clone', :id => block.id }, { :method => 'post' }) 226 + buttons << icon_button(:clone, _('Clone'), { :action => 'clone_block', :id => block.id }, { :method => 'post' })
227 end 227 end
228 228
229 if block.respond_to?(:help) 229 if block.respond_to?(:help)
app/helpers/cache_counter_helper.rb 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +module CacheCounterHelper
  2 + def update_cache_counter(name, object, value)
  3 + if object.present?
  4 + object.class.update_counters(object.id, name => value)
  5 + end
  6 + end
  7 +end
app/helpers/categories_helper.rb
@@ -48,4 +48,12 @@ module CategoriesHelper @@ -48,4 +48,12 @@ module CategoriesHelper
48 labelled_form_field(_('Type of category'), select_tag('type', options_for_select(TYPES, value))) 48 labelled_form_field(_('Type of category'), select_tag('type', options_for_select(TYPES, value)))
49 end 49 end
50 50
  51 + #FIXME make this test
  52 + def selected_category_link(cat)
  53 + content_tag('div', button_to_function_without_text(:remove, _('Remove'), nil) {|page| page["selected-category-#{cat.id}"].remove} +
  54 + link_to_function(cat.full_name(' &rarr; '), nil, :id => "remove-selected-category-#{cat.id}-button", :class => 'select-subcategory-link') {|page| page["selected-category-#{cat.id}"].remove},
  55 + :class => 'selected-category'
  56 + )
  57 + end
  58 +
51 end 59 end
app/helpers/comment_helper.rb
@@ -2,7 +2,6 @@ module CommentHelper @@ -2,7 +2,6 @@ module CommentHelper
2 2
3 def article_title(article, args = {}) 3 def article_title(article, args = {})
4 title = article.title 4 title = article.title
5 - title = article.display_title if article.kind_of?(UploadedFile) && article.image?  
6 title = content_tag('h1', h(title), :class => 'title') 5 title = content_tag('h1', h(title), :class => 'title')
7 if article.belongs_to_blog? 6 if article.belongs_to_blog?
8 unless args[:no_link] 7 unless args[:no_link]
@@ -22,6 +21,12 @@ module CommentHelper @@ -22,6 +21,12 @@ module CommentHelper
22 title 21 title
23 end 22 end
24 23
  24 + def comment_extra_contents(comment)
  25 + @plugins.dispatch(:comment_extra_contents, comment).collect do |extra_content|
  26 + extra_content.kind_of?(Proc) ? self.instance_eval(&extra_content) : extra_content
  27 + end.join('\n')
  28 + end
  29 +
25 def comment_actions(comment) 30 def comment_actions(comment)
26 url = url_for(:profile => profile.identifier, :controller => :comment, :action => :check_actions, :id => comment.id) 31 url = url_for(:profile => profile.identifier, :controller => :comment, :action => :check_actions, :id => comment.id)
27 links = links_for_comment_actions(comment) 32 links = links_for_comment_actions(comment)
app/helpers/content_viewer_helper.rb
@@ -14,8 +14,7 @@ module ContentViewerHelper @@ -14,8 +14,7 @@ module ContentViewerHelper
14 end 14 end
15 15
16 def article_title(article, args = {}) 16 def article_title(article, args = {})
17 - title = article.display_title if article.kind_of?(UploadedFile) && article.image?  
18 - title = article.title if title.blank? 17 + title = article.title
19 title = content_tag('h1', h(title), :class => 'title') 18 title = content_tag('h1', h(title), :class => 'title')
20 if article.belongs_to_blog? || article.belongs_to_forum? 19 if article.belongs_to_blog? || article.belongs_to_forum?
21 unless args[:no_link] 20 unless args[:no_link]
@@ -52,15 +51,6 @@ module ContentViewerHelper @@ -52,15 +51,6 @@ module ContentViewerHelper
52 end 51 end
53 end 52 end
54 53
55 - def addthis_facebook_url(article)  
56 - "http://www.facebook.com/sharer.php?s=100&p[title]=%{title}&p[summary]=%{summary}&p[url]=%{url}&p[images][0]=%{image}" % {  
57 - :title => CGI.escape(article.title),  
58 - :url => CGI.escape(url_for(article.url)),  
59 - :summary => CGI.escape(truncate(strip_tags(article.body.to_s), :length => 300)),  
60 - :image => CGI.escape(article.body_images_paths.first.to_s)  
61 - }  
62 - end  
63 -  
64 def addthis_image_tag 54 def addthis_image_tag
65 if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif')) 55 if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif'))
66 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '') 56 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '')
app/helpers/layout_helper.rb
@@ -90,5 +90,8 @@ module LayoutHelper @@ -90,5 +90,8 @@ module LayoutHelper
90 end 90 end
91 end 91 end
92 92
  93 + def meta_description_tag(article=nil)
  94 + article ? truncate(strip_tags(article.body.to_s), :length => 200) : environment.name
  95 + end
93 end 96 end
94 97
app/helpers/macros_helper.rb
@@ -20,14 +20,16 @@ module MacrosHelper @@ -20,14 +20,16 @@ module MacrosHelper
20 jQuery('<div>'+#{macro_configuration_dialog(macro).to_json}+'</div>').dialog({ 20 jQuery('<div>'+#{macro_configuration_dialog(macro).to_json}+'</div>').dialog({
21 title: #{macro_title(macro).to_json}, 21 title: #{macro_title(macro).to_json},
22 modal: true, 22 modal: true,
23 - buttons: [  
24 - {text: #{_('Ok').to_json}, click: function(){ 23 + buttons: {
  24 + #{_('Ok').to_json}: function(){
25 tinyMCE.activeEditor.execCommand('mceInsertContent', false, 25 tinyMCE.activeEditor.execCommand('mceInsertContent', false,
26 (function(dialog){ #{macro_generator(macro)} })(this)); 26 (function(dialog){ #{macro_generator(macro)} })(this));
27 jQuery(this).dialog('close'); 27 jQuery(this).dialog('close');
28 - }},  
29 - {text: #{_('Cancel').to_json}, click: function(){jQuery(this).dialog('close');}}  
30 - ] 28 + },
  29 + #{_('Cancel').to_json}: function(){
  30 + jQuery(this).dialog('close');
  31 + }
  32 + }
31 }); 33 });
32 }" 34 }"
33 end 35 end
@@ -57,7 +59,11 @@ module MacrosHelper @@ -57,7 +59,11 @@ module MacrosHelper
57 59
58 def macro_generator(macro) 60 def macro_generator(macro)
59 if macro.configuration[:generator] 61 if macro.configuration[:generator]
60 - macro.configuration[:generator] 62 + if macro.configuration[:generator].respond_to?(:call)
  63 + macro.configuration[:generator].call(macro)
  64 + else
  65 + macro.configuration[:generator]
  66 + end
61 else 67 else
62 macro_default_generator(macro) 68 macro_default_generator(macro)
63 end 69 end
@@ -66,8 +72,7 @@ module MacrosHelper @@ -66,8 +72,7 @@ module MacrosHelper
66 72
67 def macro_default_generator(macro) 73 def macro_default_generator(macro)
68 code = "var params = {};" 74 code = "var params = {};"
69 - configuration = macro_configuration(macro)  
70 - configuration[:params].map do |field| 75 + macro.configuration[:params].map do |field|
71 code += "params.#{field[:name]} = jQuery('*[name=#{field[:name]}]', dialog).val();" 76 code += "params.#{field[:name]} = jQuery('*[name=#{field[:name]}]', dialog).val();"
72 end 77 end
73 code + " 78 code + "
app/helpers/person_notifier_helper.rb 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +module PersonNotifierHelper
  2 +
  3 + include ApplicationHelper
  4 +
  5 + private
  6 +
  7 + def path_to_image(source)
  8 + top_url + source
  9 + end
  10 +
  11 + def top_url
  12 + top_url = @profile.environment ? @profile.environment.top_url : ''
  13 + end
  14 +
  15 +end
app/models/block.rb
@@ -155,7 +155,7 @@ class Block &lt; ActiveRecord::Base @@ -155,7 +155,7 @@ class Block &lt; ActiveRecord::Base
155 end 155 end
156 156
157 alias :active_record_cache_key :cache_key 157 alias :active_record_cache_key :cache_key
158 - def cache_key(language='en') 158 + def cache_key(language='en', user=nil)
159 active_record_cache_key+'-'+language 159 active_record_cache_key+'-'+language
160 end 160 end
161 161
app/models/box.rb
@@ -26,6 +26,8 @@ class Box &lt; ActiveRecord::Base @@ -26,6 +26,8 @@ class Box &lt; ActiveRecord::Base
26 CategoriesBlock, 26 CategoriesBlock,
27 CommunitiesBlock, 27 CommunitiesBlock,
28 EnterprisesBlock, 28 EnterprisesBlock,
  29 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  30 + # the Noosfero core soon, see ActionItem3045
29 EnvironmentStatisticsBlock, 31 EnvironmentStatisticsBlock,
30 FansBlock, 32 FansBlock,
31 FavoriteEnterprisesBlock, 33 FavoriteEnterprisesBlock,
@@ -52,6 +54,8 @@ class Box &lt; ActiveRecord::Base @@ -52,6 +54,8 @@ class Box &lt; ActiveRecord::Base
52 CommunitiesBlock, 54 CommunitiesBlock,
53 DisabledEnterpriseMessageBlock, 55 DisabledEnterpriseMessageBlock,
54 EnterprisesBlock, 56 EnterprisesBlock,
  57 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  58 + # the Noosfero core soon, see ActionItem3045
55 EnvironmentStatisticsBlock, 59 EnvironmentStatisticsBlock,
56 FansBlock, 60 FansBlock,
57 FavoriteEnterprisesBlock, 61 FavoriteEnterprisesBlock,
app/models/comment.rb
@@ -172,7 +172,7 @@ class Comment &lt; ActiveRecord::Base @@ -172,7 +172,7 @@ class Comment &lt; ActiveRecord::Base
172 def mail(comment) 172 def mail(comment)
173 profile = comment.article.profile 173 profile = comment.article.profile
174 recipients comment.notification_emails 174 recipients comment.notification_emails
175 - from "#{profile.environment.name} <#{profile.environment.contact_email}>" 175 + from "#{profile.environment.name} <#{profile.environment.noreply_email}>"
176 subject _("[%s] you got a new comment!") % [profile.environment.name] 176 subject _("[%s] you got a new comment!") % [profile.environment.name]
177 body :recipient => profile.nickname || profile.name, 177 body :recipient => profile.nickname || profile.name,
178 :sender => comment.author_name, 178 :sender => comment.author_name,
@@ -187,7 +187,7 @@ class Comment &lt; ActiveRecord::Base @@ -187,7 +187,7 @@ class Comment &lt; ActiveRecord::Base
187 def mail_to_followers(comment, emails) 187 def mail_to_followers(comment, emails)
188 profile = comment.article.profile 188 profile = comment.article.profile
189 bcc emails 189 bcc emails
190 - from "#{profile.environment.name} <#{profile.environment.contact_email}>" 190 + from "#{profile.environment.name} <#{profile.environment.noreply_email}>"
191 subject _("[%s] %s commented on a content of %s") % [profile.environment.name, comment.author_name, profile.short_name] 191 subject _("[%s] %s commented on a content of %s") % [profile.environment.name, comment.author_name, profile.short_name]
192 body :recipient => profile.nickname || profile.name, 192 body :recipient => profile.nickname || profile.name,
193 :sender => comment.author_name, 193 :sender => comment.author_name,
app/models/contact.rb
@@ -26,7 +26,7 @@ class Contact &lt; ActiveRecord::Base #WithoutTable @@ -26,7 +26,7 @@ class Contact &lt; ActiveRecord::Base #WithoutTable
26 content_type 'text/html' 26 content_type 'text/html'
27 emails = contact.dest.notification_emails 27 emails = contact.dest.notification_emails
28 recipients emails 28 recipients emails
29 - from "#{contact.name} <#{contact.dest.environment.contact_email}>" 29 + from "#{contact.name} <#{contact.dest.environment.noreply_email}>"
30 reply_to contact.email 30 reply_to contact.email
31 if contact.sender 31 if contact.sender
32 headers 'X-Noosfero-Sender' => contact.sender.identifier 32 headers 'X-Noosfero-Sender' => contact.sender.identifier
app/models/environment.rb
@@ -145,6 +145,18 @@ class Environment &lt; ActiveRecord::Base @@ -145,6 +145,18 @@ class Environment &lt; ActiveRecord::Base
145 end 145 end
146 validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true 146 validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true
147 147
  148 + def self.signup_redirection_options
  149 + {
  150 + 'keep_on_same_page' => _('Stays on the same page the user was before signup.'),
  151 + 'site_homepage' => _('Redirects the user to the environment homepage.'),
  152 + 'user_profile_page' => _('Redirects the user to his profile page.'),
  153 + 'user_homepage' => _('Redirects the user to his homepage.'),
  154 + 'user_control_panel' => _('Redirects the user to his control panel.')
  155 + }
  156 + end
  157 + validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true
  158 +
  159 +
148 # ################################################# 160 # #################################################
149 # Relationships and applied behaviour 161 # Relationships and applied behaviour
150 # ################################################# 162 # #################################################
@@ -161,6 +173,8 @@ class Environment &lt; ActiveRecord::Base @@ -161,6 +173,8 @@ class Environment &lt; ActiveRecord::Base
161 173
162 # "left" area 174 # "left" area
163 env.boxes[1].blocks << LoginBlock.new 175 env.boxes[1].blocks << LoginBlock.new
  176 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  177 + # the Noosfero core soon, see ActionItem3045
164 env.boxes[1].blocks << EnvironmentStatisticsBlock.new 178 env.boxes[1].blocks << EnvironmentStatisticsBlock.new
165 env.boxes[1].blocks << RecentDocumentsBlock.new 179 env.boxes[1].blocks << RecentDocumentsBlock.new
166 180
@@ -592,7 +606,7 @@ class Environment &lt; ActiveRecord::Base @@ -592,7 +606,7 @@ class Environment &lt; ActiveRecord::Base
592 # only one environment can be the default one 606 # only one environment can be the default one
593 validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one') 607 validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one')
594 608
595 - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) 609 + validates_format_of :contact_email, :noreply_email, :with => Noosfero::Constants::EMAIL_FORMAT, :allow_blank => true
596 610
597 xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation' 611 xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation'
598 612
@@ -779,7 +793,7 @@ class Environment &lt; ActiveRecord::Base @@ -779,7 +793,7 @@ class Environment &lt; ActiveRecord::Base
779 end 793 end
780 794
781 def notification_emails 795 def notification_emails
782 - [contact_email.blank? ? nil : contact_email].compact + admins.map(&:email) 796 + [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email)
783 end 797 end
784 798
785 after_create :create_templates 799 after_create :create_templates
app/models/environment_statistics_block.rb
  1 +# TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  2 +# the Noosfero core soon, see ActionItem3045
  3 +
1 class EnvironmentStatisticsBlock < Block 4 class EnvironmentStatisticsBlock < Block
2 5
3 def self.description 6 def self.description
4 - _('Environment stastistics') 7 + _('Environment stastistics (DEPRECATED)')
5 end 8 end
6 9
7 def default_title 10 def default_title
app/models/forum.rb
@@ -5,6 +5,7 @@ class Forum &lt; Folder @@ -5,6 +5,7 @@ class Forum &lt; Folder
5 5
6 settings_items :terms_of_use, :type => :string, :default => "" 6 settings_items :terms_of_use, :type => :string, :default => ""
7 settings_items :has_terms_of_use, :type => :boolean, :default => false 7 settings_items :has_terms_of_use, :type => :boolean, :default => false
  8 + settings_items :allows_members_to_create_topics, :type => :boolean, :default => false
8 has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people' 9 has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people'
9 10
10 before_save do |forum| 11 before_save do |forum|
@@ -66,4 +67,11 @@ class Forum &lt; Folder @@ -66,4 +67,11 @@ class Forum &lt; Folder
66 self.users_with_agreement.exists? user 67 self.users_with_agreement.exists? user
67 end 68 end
68 69
  70 + def can_create_topic?(user, profile)
  71 + return profile.community? && profile.members.include?(user) && self.allows_members_to_create_topics
  72 + end
  73 +
  74 + def allow_create?(user)
  75 + super || can_create_topic?(user, profile)
  76 + end
69 end 77 end
app/models/friendship.rb
1 class Friendship < ActiveRecord::Base 1 class Friendship < ActiveRecord::Base
2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person 2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person
3 - 3 +
  4 + extend CacheCounterHelper
  5 +
4 belongs_to :person, :foreign_key => :person_id 6 belongs_to :person, :foreign_key => :person_id
5 belongs_to :friend, :class_name => 'Person', :foreign_key => 'friend_id' 7 belongs_to :friend, :class_name => 'Person', :foreign_key => 'friend_id'
  8 +
  9 + after_create do |friendship|
  10 + update_cache_counter(:friends_count, friendship.person, 1)
  11 + update_cache_counter(:friends_count, friendship.friend, 1)
  12 + end
  13 +
  14 + after_destroy do |friendship|
  15 + update_cache_counter(:friends_count, friendship.person, -1)
  16 + update_cache_counter(:friends_count, friendship.friend, -1)
  17 + end
6 end 18 end
app/models/layout_template.rb
@@ -16,15 +16,15 @@ class LayoutTemplate @@ -16,15 +16,15 @@ class LayoutTemplate
16 end 16 end
17 17
18 def name 18 def name
19 - @config['name'] 19 + _ @config['name']
20 end 20 end
21 21
22 def title 22 def title
23 - @config['title'] 23 + _ @config['title']
24 end 24 end
25 25
26 def description 26 def description
27 - @config['description'] 27 + _ @config['description']
28 end 28 end
29 29
30 def number_of_boxes 30 def number_of_boxes
app/models/mailing.rb
@@ -17,7 +17,7 @@ class Mailing &lt; ActiveRecord::Base @@ -17,7 +17,7 @@ class Mailing &lt; ActiveRecord::Base
17 end 17 end
18 18
19 def generate_from 19 def generate_from
20 - "#{source.name} <#{source.contact_email}>" 20 + "#{source.name} <#{if source.is_a? Environment then source.noreply_email else source.contact_email end}>"
21 end 21 end
22 22
23 def generate_subject 23 def generate_subject
app/models/members_block.rb
@@ -36,4 +36,15 @@ class MembersBlock &lt; ProfileListBlock @@ -36,4 +36,15 @@ class MembersBlock &lt; ProfileListBlock
36 } 36 }
37 end 37 end
38 38
  39 + def cache_key(language='en', user=nil)
  40 + logged = ''
  41 + if user
  42 + logged += '-logged-in'
  43 + if user.is_member_of? self.owner
  44 + logged += '-member'
  45 + end
  46 + end
  47 + super + logged
  48 + end
  49 +
39 end 50 end
app/models/organization.rb
@@ -26,18 +26,7 @@ class Organization &lt; Profile @@ -26,18 +26,7 @@ class Organization &lt; Profile
26 26
27 has_many :mailings, :class_name => 'OrganizationMailing', :foreign_key => :source_id, :as => 'source' 27 has_many :mailings, :class_name => 'OrganizationMailing', :foreign_key => :source_id, :as => 'source'
28 28
29 - named_scope :more_popular,  
30 - :select => "#{Profile.qualified_column_names}, count(resource_id) as total",  
31 - :group => Profile.qualified_column_names,  
32 - :joins => "LEFT OUTER JOIN role_assignments ON profiles.id = role_assignments.resource_id",  
33 - :order => "total DESC"  
34 -  
35 - named_scope :more_active,  
36 - :select => "#{Profile.qualified_column_names}, count(action_tracker.id) as total",  
37 - :joins => "LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id",  
38 - :group => Profile.qualified_column_names,  
39 - :order => 'total DESC',  
40 - :conditions => ['action_tracker.created_at >= ? OR action_tracker.id IS NULL', ActionTracker::Record::RECENT_DELAY.days.ago] 29 + named_scope :more_popular, :order => 'members_count DESC'
41 30
42 def validation_methodology 31 def validation_methodology
43 self.validation_info ? self.validation_info.validation_methodology : nil 32 self.validation_info ? self.validation_info.validation_methodology : nil
app/models/organization_mailing.rb
1 class OrganizationMailing < Mailing 1 class OrganizationMailing < Mailing
2 2
3 def generate_from 3 def generate_from
4 - "#{person.name} <#{source.environment.contact_email}>" 4 + "#{person.name} <#{source.environment.noreply_email}>"
5 end 5 end
6 6
7 def recipients(offset=0, limit=100) 7 def recipients(offset=0, limit=100)
app/models/pending_task_notifier.rb
@@ -2,7 +2,7 @@ class PendingTaskNotifier &lt; ActionMailer::Base @@ -2,7 +2,7 @@ class PendingTaskNotifier &lt; ActionMailer::Base
2 2
3 def notification(person) 3 def notification(person)
4 recipients person.email 4 recipients person.email
5 - from "#{person.environment.name} <#{person.environment.contact_email}>" 5 + from "#{person.environment.name} <#{person.environment.noreply_email}>"
6 subject _("[%s] Pending tasks") % person.environment.name 6 subject _("[%s] Pending tasks") % person.environment.name
7 body :person => person, 7 body :person => person,
8 :tasks => person.tasks.pending, 8 :tasks => person.tasks.pending,
app/models/person.rb
@@ -71,18 +71,7 @@ class Person &lt; Profile @@ -71,18 +71,7 @@ class Person &lt; Profile
71 has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people' 71 has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people'
72 has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions' 72 has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions'
73 73
74 - named_scope :more_popular,  
75 - :select => "#{Profile.qualified_column_names}, count(friend_id) as total",  
76 - :group => Profile.qualified_column_names,  
77 - :joins => "LEFT OUTER JOIN friendships on profiles.id = friendships.person_id",  
78 - :order => "total DESC"  
79 -  
80 - named_scope :more_active,  
81 - :select => "#{Profile.qualified_column_names}, count(action_tracker.id) as total",  
82 - :joins => "LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id",  
83 - :group => Profile.qualified_column_names,  
84 - :order => 'total DESC',  
85 - :conditions => ['action_tracker.created_at >= ? OR action_tracker.id IS NULL', ActionTracker::Record::RECENT_DELAY.days.ago] 74 + named_scope :more_popular, :order => 'friends_count DESC'
86 75
87 named_scope :abusers, :joins => :abuse_complaints, :conditions => ['tasks.status = 3'], :select => 'DISTINCT profiles.*' 76 named_scope :abusers, :joins => :abuse_complaints, :conditions => ['tasks.status = 3'], :select => 'DISTINCT profiles.*'
88 named_scope :non_abusers, :joins => "LEFT JOIN tasks ON profiles.id = tasks.requestor_id AND tasks.type='AbuseComplaint'", :conditions => ["tasks.status != 3 OR tasks.id is NULL"], :select => "DISTINCT profiles.*" 77 named_scope :non_abusers, :joins => "LEFT JOIN tasks ON profiles.id = tasks.requestor_id AND tasks.type='AbuseComplaint'", :conditions => ["tasks.status != 3 OR tasks.id is NULL"], :select => "DISTINCT profiles.*"
@@ -501,6 +490,17 @@ class Person &lt; Profile @@ -501,6 +490,17 @@ class Person &lt; Profile
501 gravatar_profile_image_url(self.email, :size=>20, :d => gravatar_default) 490 gravatar_profile_image_url(self.email, :size=>20, :d => gravatar_default)
502 end 491 end
503 492
  493 + settings_items :last_notification, :type => DateTime
  494 + settings_items :notification_time, :type => :integer, :default => 0
  495 +
  496 + def notifier
  497 + @notifier ||= PersonNotifier.new(self)
  498 + end
  499 +
  500 + after_update do |person|
  501 + person.notifier.reschedule_next_notification_mail
  502 + end
  503 +
504 protected 504 protected
505 505
506 def followed_by?(profile) 506 def followed_by?(profile)
app/models/person_notifier.rb 0 → 100644
@@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
  1 +class PersonNotifier
  2 +
  3 + def initialize(person)
  4 + @person = person
  5 + end
  6 +
  7 + def self.schedule_all_next_notification_mail
  8 + Delayed::Job.enqueue(NotifyAllJob.new) unless NotifyAllJob.exists?
  9 + end
  10 +
  11 + def schedule_next_notification_mail
  12 + dispatch_notification_mail if !NotifyJob.exists?(@person.id)
  13 + end
  14 +
  15 + def dispatch_notification_mail
  16 + Delayed::Job.enqueue(NotifyJob.new(@person.id), nil, @person.notification_time.hours.from_now) if @person.notification_time>0
  17 + end
  18 +
  19 + def reschedule_next_notification_mail
  20 + return nil unless @person.setting_changed?(:notification_time) || @person.setting_changed?(:last_notification)
  21 + NotifyJob.find(@person.id).delete_all
  22 + schedule_next_notification_mail
  23 + end
  24 +
  25 + def notify
  26 + if @person.notification_time && @person.notification_time > 0
  27 + from = @person.last_notification || DateTime.now - @person.notification_time.hours
  28 + notifications = @person.tracked_notifications.find(:all, :conditions => ["created_at > ?", from])
  29 + Noosfero.with_locale @person.environment.default_language do
  30 + Mailer::deliver_content_summary(@person, notifications) unless notifications.empty?
  31 + end
  32 + @person.settings[:last_notification] = DateTime.now
  33 + @person.save!
  34 + end
  35 + end
  36 +
  37 + class NotifyAllJob
  38 + def self.exists?
  39 + Delayed::Job.where(:handler => "--- !ruby/object:PersonNotifier::NotifyAllJob {}\n\n").count > 0
  40 + end
  41 +
  42 + def perform
  43 + Person.find_each {|person| person.notifier.schedule_next_notification_mail }
  44 + end
  45 + end
  46 +
  47 + class NotifyJob < Struct.new(:person_id)
  48 +
  49 + def self.exists?(person_id)
  50 + !find(person_id).empty?
  51 + end
  52 +
  53 + def self.find(person_id)
  54 + Delayed::Job.where(:handler => "--- !ruby/struct:PersonNotifier::NotifyJob \nperson_id: #{person_id}\n")
  55 + end
  56 +
  57 + def perform
  58 + Person.find(person_id).notifier.notify
  59 + end
  60 +
  61 + def on_permanent_failure
  62 + person = Person.find(person_id)
  63 + person.notifier.dispatch_notification_mail
  64 + end
  65 +
  66 + end
  67 +
  68 + class Mailer < ActionMailer::Base
  69 +
  70 + add_template_helper(PersonNotifierHelper)
  71 +
  72 + def session
  73 + {:theme => nil}
  74 + end
  75 +
  76 + def content_summary(person, notifications)
  77 + @current_theme = 'default'
  78 + @profile = person
  79 + recipients person.email
  80 + from "#{@profile.environment.name} <#{@profile.environment.contact_email}>"
  81 + subject _("[%s] Network Activity") % [@profile.environment.name]
  82 + body :recipient => @profile.nickname || @profile.name,
  83 + :environment => @profile.environment.name,
  84 + :url => @profile.environment.top_url,
  85 + :notifications => notifications
  86 + content_type "text/html"
  87 + end
  88 + end
  89 +end
app/models/profile.rb
@@ -92,10 +92,6 @@ class Profile &lt; ActiveRecord::Base @@ -92,10 +92,6 @@ class Profile &lt; ActiveRecord::Base
92 members.order(:name) 92 members.order(:name)
93 end 93 end
94 94
95 - def members_count  
96 - members.count  
97 - end  
98 -  
99 class << self 95 class << self
100 def count_with_distinct(*args) 96 def count_with_distinct(*args)
101 options = args.last || {} 97 options = args.last || {}
@@ -118,10 +114,11 @@ class Profile &lt; ActiveRecord::Base @@ -118,10 +114,11 @@ class Profile &lt; ActiveRecord::Base
118 114
119 named_scope :visible, :conditions => { :visible => true } 115 named_scope :visible, :conditions => { :visible => true }
120 named_scope :public, :conditions => { :visible => true, :public_profile => true } 116 named_scope :public, :conditions => { :visible => true, :public_profile => true }
121 - # Subclasses must override these methods 117 +
  118 + # Subclasses must override this method
122 named_scope :more_popular 119 named_scope :more_popular
123 - named_scope :more_active  
124 120
  121 + named_scope :more_active, :order => 'activities_count DESC'
125 named_scope :more_recent, :order => "created_at DESC" 122 named_scope :more_recent, :order => "created_at DESC"
126 123
127 acts_as_trackable :dependent => :destroy 124 acts_as_trackable :dependent => :destroy
@@ -616,10 +613,10 @@ private :generate_url, :url_options @@ -616,10 +613,10 @@ private :generate_url, :url_options
616 # Adds a person as member of this Profile. 613 # Adds a person as member of this Profile.
617 def add_member(person) 614 def add_member(person)
618 if self.has_members? 615 if self.has_members?
619 - if self.closed? && members_count > 0 616 + if self.closed? && members.count > 0
620 AddMember.create!(:person => person, :organization => self) unless self.already_request_membership?(person) 617 AddMember.create!(:person => person, :organization => self) unless self.already_request_membership?(person)
621 else 618 else
622 - self.affiliate(person, Profile::Roles.admin(environment.id)) if members_count == 0 619 + self.affiliate(person, Profile::Roles.admin(environment.id)) if members.count == 0
623 self.affiliate(person, Profile::Roles.member(environment.id)) 620 self.affiliate(person, Profile::Roles.member(environment.id))
624 end 621 end
625 else 622 else
app/models/scrap.rb
@@ -14,7 +14,7 @@ class Scrap &lt; ActiveRecord::Base @@ -14,7 +14,7 @@ class Scrap &lt; ActiveRecord::Base
14 14
15 named_scope :not_replies, :conditions => {:scrap_id => nil} 15 named_scope :not_replies, :conditions => {:scrap_id => nil}
16 16
17 - track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target 17 + track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target
18 18
19 track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver} 19 track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver}
20 20
@@ -59,7 +59,7 @@ class Scrap &lt; ActiveRecord::Base @@ -59,7 +59,7 @@ class Scrap &lt; ActiveRecord::Base
59 sender, receiver = scrap.sender, scrap.receiver 59 sender, receiver = scrap.sender, scrap.receiver
60 recipients receiver.email 60 recipients receiver.email
61 61
62 - from "#{sender.environment.name} <#{sender.environment.contact_email}>" 62 + from "#{sender.environment.name} <#{sender.environment.noreply_email}>"
63 subject _("[%s] You received a scrap!") % [sender.environment.name] 63 subject _("[%s] You received a scrap!") % [sender.environment.name]
64 body :recipient => receiver.name, 64 body :recipient => receiver.name,
65 :sender => sender.name, 65 :sender => sender.name,
app/models/task_mailer.rb
@@ -60,7 +60,7 @@ class TaskMailer &lt; ActionMailer::Base @@ -60,7 +60,7 @@ class TaskMailer &lt; ActionMailer::Base
60 end 60 end
61 61
62 def self.generate_from(task) 62 def self.generate_from(task)
63 - "#{task.environment.name} <#{task.environment.contact_email}>" 63 + "#{task.environment.name} <#{task.environment.noreply_email}>"
64 end 64 end
65 65
66 def generate_environment_url(task, url = {}) 66 def generate_environment_url(task, url = {})
app/models/theme.rb
@@ -42,17 +42,25 @@ class Theme @@ -42,17 +42,25 @@ class Theme
42 end 42 end
43 43
44 def approved_themes(owner) 44 def approved_themes(owner)
45 - Dir.glob(File.join(system_themes_dir, '*')).select do |item|  
46 - if File.exists?( File.join(item, 'theme.yml') )  
47 - config = YAML.load_file(File.join(item, 'theme.yml'))  
48 - (config['owner_type'] == owner.class.base_class.name) &&  
49 - (config['owner_id'] == owner.id) || config['public'] 45 + Dir.glob(File.join(system_themes_dir, '*')).map do |item|
  46 + next unless File.exists? File.join(item, 'theme.yml')
  47 + id = File.basename item
  48 + config = YAML.load_file File.join(item, 'theme.yml')
  49 +
  50 + approved = config['public']
  51 + unless approved
  52 + begin
  53 + approved = owner.kind_of?(config['owner_type'].constantize)
  54 + rescue
  55 + end
  56 + approved &&= config['owner_id'] == owner.id if config['owner_id'].present?
50 end 57 end
51 - end.map do |desc|  
52 - new(File.basename(desc)) 58 +
  59 + [id, config] if approved
  60 + end.compact.map do |id, config|
  61 + new id, config
53 end 62 end
54 end 63 end
55 -  
56 end 64 end
57 65
58 class DuplicatedIdentifier < Exception; end 66 class DuplicatedIdentifier < Exception; end
app/models/uploaded_file.rb
@@ -12,15 +12,12 @@ class UploadedFile &lt; Article @@ -12,15 +12,12 @@ class UploadedFile &lt; Article
12 12
13 include ShortFilename 13 include ShortFilename
14 14
15 - settings_items :title, :type => 'string'  
16 - xss_terminate :only => [ :title ]  
17 -  
18 - def title_with_default  
19 - title_without_default || short_filename(name, 60) 15 + def title
  16 + if self.name.present? then self.name else self.filename end
  17 + end
  18 + def title= value
  19 + self.name = value
20 end 20 end
21 - alias_method_chain :title, :default  
22 -  
23 - validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? })  
24 21
25 sanitize_filename 22 sanitize_filename
26 23
@@ -32,10 +29,6 @@ class UploadedFile &lt; Article @@ -32,10 +29,6 @@ class UploadedFile &lt; Article
32 self.image? ? self.full_filename(:display).gsub(File.join(RAILS_ROOT, 'public'), '') : nil 29 self.image? ? self.full_filename(:display).gsub(File.join(RAILS_ROOT, 'public'), '') : nil
33 end 30 end
34 31
35 - def display_title  
36 - title.blank? ? name : title  
37 - end  
38 -  
39 def first_paragraph 32 def first_paragraph
40 '' 33 ''
41 end 34 end
@@ -109,7 +102,7 @@ class UploadedFile &lt; Article @@ -109,7 +102,7 @@ class UploadedFile &lt; Article
109 alias :orig_set_filename :filename= 102 alias :orig_set_filename :filename=
110 def filename=(value) 103 def filename=(value)
111 orig_set_filename(value) 104 orig_set_filename(value)
112 - self.name = self.filename 105 + self.name ||= self.filename
113 end 106 end
114 107
115 def download_headers 108 def download_headers
app/models/user.rb
@@ -54,7 +54,7 @@ class User &lt; ActiveRecord::Base @@ -54,7 +54,7 @@ class User &lt; ActiveRecord::Base
54 def activation_email_notify(user) 54 def activation_email_notify(user)
55 user_email = "#{user.login}@#{user.email_domain}" 55 user_email = "#{user.login}@#{user.email_domain}"
56 recipients user_email 56 recipients user_email
57 - from "#{user.environment.name} <#{user.environment.contact_email}>" 57 + from "#{user.environment.name} <#{user.environment.noreply_email}>"
58 subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name } 58 subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name }
59 body :name => user.name, 59 body :name => user.name,
60 :email => user_email, 60 :email => user_email,
@@ -66,12 +66,13 @@ class User &lt; ActiveRecord::Base @@ -66,12 +66,13 @@ class User &lt; ActiveRecord::Base
66 def activation_code(user) 66 def activation_code(user)
67 recipients user.email 67 recipients user.email
68 68
69 - from "#{user.environment.name} <#{user.environment.contact_email}>" 69 + from "#{user.environment.name} <#{user.environment.noreply_email}>"
70 subject _("[%s] Activate your account") % [user.environment.name] 70 subject _("[%s] Activate your account") % [user.environment.name]
71 body :recipient => user.name, 71 body :recipient => user.name,
72 :activation_code => user.activation_code, 72 :activation_code => user.activation_code,
73 :environment => user.environment.name, 73 :environment => user.environment.name,
74 - :url => user.environment.top_url 74 + :url => user.environment.top_url,
  75 + :redirection => (true if user.return_to)
75 end 76 end
76 77
77 def signup_welcome_email(user) 78 def signup_welcome_email(user)
@@ -81,7 +82,7 @@ class User &lt; ActiveRecord::Base @@ -81,7 +82,7 @@ class User &lt; ActiveRecord::Base
81 content_type 'text/html' 82 content_type 'text/html'
82 recipients user.email 83 recipients user.email
83 84
84 - from "#{user.environment.name} <#{user.environment.contact_email}>" 85 + from "#{user.environment.name} <#{user.environment.noreply_email}>"
85 subject email_subject.blank? ? _("Welcome to environment %s") % [user.environment.name] : email_subject 86 subject email_subject.blank? ? _("Welcome to environment %s") % [user.environment.name] : email_subject
86 body email_body 87 body email_body
87 end 88 end
@@ -93,7 +94,7 @@ class User &lt; ActiveRecord::Base @@ -93,7 +94,7 @@ class User &lt; ActiveRecord::Base
93 self.person.save! 94 self.person.save!
94 end 95 end
95 end 96 end
96 - 97 +
97 has_one :person, :dependent => :destroy 98 has_one :person, :dependent => :destroy
98 belongs_to :environment 99 belongs_to :environment
99 100
@@ -183,7 +184,7 @@ class User &lt; ActiveRecord::Base @@ -183,7 +184,7 @@ class User &lt; ActiveRecord::Base
183 encryption_methods[sym] = block 184 encryption_methods[sym] = block
184 end 185 end
185 186
186 - # the encryption method used for this instance 187 + # the encryption method used for this instance
187 def encryption_method 188 def encryption_method
188 (password_type || User.system_encryption_method).to_sym 189 (password_type || User.system_encryption_method).to_sym
189 end 190 end
@@ -226,7 +227,7 @@ class User &lt; ActiveRecord::Base @@ -226,7 +227,7 @@ class User &lt; ActiveRecord::Base
226 end 227 end
227 228
228 def remember_token? 229 def remember_token?
229 - remember_token_expires_at && Time.now.utc < remember_token_expires_at 230 + remember_token_expires_at && Time.now.utc < remember_token_expires_at
230 end 231 end
231 232
232 # These create and unset the fields required for remembering users between browser closes 233 # These create and unset the fields required for remembering users between browser closes
@@ -255,7 +256,7 @@ class User &lt; ActiveRecord::Base @@ -255,7 +256,7 @@ class User &lt; ActiveRecord::Base
255 raise IncorrectPassword unless self.authenticated?(current) 256 raise IncorrectPassword unless self.authenticated?(current)
256 self.force_change_password!(new, confirmation) 257 self.force_change_password!(new, confirmation)
257 end 258 end
258 - 259 +
259 # Changes the password of a user without asking for the old password. This 260 # Changes the password of a user without asking for the old password. This
260 # method is intended to be used by the "I forgot my password", and must be 261 # method is intended to be used by the "I forgot my password", and must be
261 # used with care. 262 # used with care.
@@ -326,7 +327,7 @@ class User &lt; ActiveRecord::Base @@ -326,7 +327,7 @@ class User &lt; ActiveRecord::Base
326 end 327 end
327 328
328 protected 329 protected
329 - # before filter 330 + # before filter
330 def encrypt_password 331 def encrypt_password
331 return if password.blank? 332 return if password.blank?
332 self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? 333 self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
app/sweepers/profile_sweeper.rb
@@ -8,6 +8,8 @@ class ProfileSweeper # &lt; ActiveRecord::Observer @@ -8,6 +8,8 @@ class ProfileSweeper # &lt; ActiveRecord::Observer
8 end 8 end
9 9
10 def after_create(profile) 10 def after_create(profile)
  11 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  12 + # the Noosfero core soon, see ActionItem3045
11 expire_statistics_block_cache(profile) 13 expire_statistics_block_cache(profile)
12 end 14 end
13 15
@@ -29,6 +31,8 @@ protected @@ -29,6 +31,8 @@ protected
29 expire_blogs(profile) if profile.organization? 31 expire_blogs(profile) if profile.organization?
30 end 32 end
31 33
  34 + # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
  35 + # the Noosfero core soon, see ActionItem3045
32 def expire_statistics_block_cache(profile) 36 def expire_statistics_block_cache(profile)
33 blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } 37 blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) }
34 BlockSweeper.expire_blocks(blocks) 38 BlockSweeper.expire_blocks(blocks)
app/views/admin_panel/_site_info.rhtml
1 <%= required labelled_form_field(_('Site name'), text_field(:environment, :name)) %> 1 <%= required labelled_form_field(_('Site name'), text_field(:environment, :name)) %>
2 <%= labelled_form_field(_('Contact email'), text_field(:environment, :contact_email)) %> 2 <%= labelled_form_field(_('Contact email'), text_field(:environment, :contact_email)) %>
  3 +<%= labelled_form_field(_('No reply email'), text_field(:environment, :noreply_email)) %>
3 <% themes_options = Theme.system_themes.map {|theme| [theme.name, theme.id] }.sort %> 4 <% themes_options = Theme.system_themes.map {|theme| [theme.name, theme.id] }.sort %>
4 <%= labelled_form_field(_('Theme'), select(:environment, :theme, options_for_select(themes_options, environment.theme))) %> 5 <%= labelled_form_field(_('Theme'), select(:environment, :theme, options_for_select(themes_options, environment.theme))) %>
5 <%= required f.text_field(:reports_lower_bound, :size => 3) %> 6 <%= required f.text_field(:reports_lower_bound, :size => 3) %>
app/views/blocks/profile_image.rhtml
1 <div class="vcard"> 1 <div class="vcard">
2 2
3 -<p><%= block.title %></p> 3 +<% if block.title.present? %>
  4 + <p><%= block.title %></p>
  5 +<% end %>
4 6
5 <div class="profile-big-image"> 7 <div class="profile-big-image">
6 <div class="profile-big-image-inner1"> 8 <div class="profile-big-image-inner1">
@@ -16,7 +18,7 @@ @@ -16,7 +18,7 @@
16 18
17 <% if !user.nil? and user.has_permission?('edit_profile', profile) %> 19 <% if !user.nil? and user.has_permission?('edit_profile', profile) %>
18 <div class='admin-link'> 20 <div class='admin-link'>
19 - <%= link_to _('Control panel'), :controller => 'profile_editor' %> 21 + <%= link_to _('Control panel'), block.owner.admin_url %>
20 </div> 22 </div>
21 <% end %> 23 <% end %>
22 24
app/views/blocks/profile_info.rhtml
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li> 21 <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li>
22 <% end %> 22 <% end %>
23 <% if !user.nil? and user.has_permission?('edit_profile', profile) %> 23 <% if !user.nil? and user.has_permission?('edit_profile', profile) %>
24 - <li><%= link_to _('Control panel'), :controller => 'profile_editor' %></li> 24 + <li><%= link_to _('Control panel'), block.owner.admin_url %></li>
25 <% end %> 25 <% end %>
26 <% if profile.person? %> 26 <% if profile.person? %>
27 <li><%= _('Since %{year}/%{month}') % { :year => block.owner.created_at.year, :month => block.owner.created_at.month } %></li> 27 <li><%= _('Since %{year}/%{month}') % { :year => block.owner.created_at.year, :month => block.owner.created_at.month } %></li>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 <% end %> 40 <% end %>
41 41
42 <div class="profile-info-options"> 42 <div class="profile-info-options">
43 - <%= render :file => view_for_profile_actions(@block.owner.class) %> 43 + <%= render :file => view_for_profile_actions(block.owner.class) %>
44 </div> 44 </div>
45 45
46 </div><!-- end class="vcard" --> 46 </div><!-- end class="vcard" -->
app/views/content_viewer/_addthis.rhtml 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<div id="addThis">
  2 + <script type="text/javascript">
  3 + addthis_pub = '<%= escape_javascript( NOOSFERO_CONF['addthis_pub'] ) %>';
  4 + addthis_logo = '<%= escape_javascript( NOOSFERO_CONF['addthis_logo'] ) %>';
  5 + addthis_options = '<%= escape_javascript( NOOSFERO_CONF['addthis_options'] ) %>';
  6 + </script>
  7 + <a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><%= addthis_image_tag %></a>
  8 +</div>
app/views/content_viewer/_article_toolbar.rhtml
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <%= expirable_button @page, :spread, content, url if url %> 26 <%= expirable_button @page, :spread, content, url if url %>
27 <% end %> 27 <% end %>
28 28
29 - <% if !@page.gallery? && @page.allow_create?(user) %> 29 + <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %>
30 <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %> 30 <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %>
31 <% content = _('Add translation') %> 31 <% content = _('Add translation') %>
32 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %> 32 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %>
app/views/content_viewer/view_page.rhtml
@@ -43,21 +43,7 @@ @@ -43,21 +43,7 @@
43 <%= render :partial => 'shared/disabled_enterprise' %> 43 <%= render :partial => 'shared/disabled_enterprise' %>
44 44
45 <% if NOOSFERO_CONF['addthis_enabled'] %> 45 <% if NOOSFERO_CONF['addthis_enabled'] %>
46 -<div id="addThis">  
47 -<script type="text/javascript">  
48 - addthis_pub = '<%= escape_javascript( NOOSFERO_CONF['addthis_pub'] ) %>';  
49 - addthis_logo = '<%= escape_javascript( NOOSFERO_CONF['addthis_logo'] ) %>';  
50 - addthis_config = {  
51 - services_custom: {  
52 - name: 'Facebook',  
53 - url: '<%= addthis_facebook_url(@page) %>',  
54 - icon: 'http://cache.addthiscdn.com/icons/v1/thumbs/facebook.gif'  
55 - }  
56 - };  
57 - addthis_options = '<%= escape_javascript( NOOSFERO_CONF['addthis_options'] ) %>';  
58 -</script>  
59 -<a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><%= addthis_image_tag %></a>  
60 -</div> 46 + <%= render :partial => 'addthis' %>
61 <% end %> 47 <% end %>
62 48
63 <% cache(@page.cache_key(params, user, language)) do %> 49 <% cache(@page.cache_key(params, user, language)) do %>
@@ -84,6 +70,8 @@ @@ -84,6 +70,8 @@
84 70
85 <%= display_source_info(@page) %> 71 <%= display_source_info(@page) %>
86 72
  73 +<%= @plugins.dispatch(:article_extra_contents, @page).collect { |content| instance_eval(&content) }.join("") %>
  74 +
87 <div class="comments" id="comments_list"> 75 <div class="comments" id="comments_list">
88 76
89 <% if @page.accept_comments? || @comments_count > 0 %> 77 <% if @page.accept_comments? || @comments_count > 0 %>
app/views/features/_manage_community_fields.rhtml
1 -<h2><%= __('Manage community fields') %></h2>  
2 -  
3 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_community_fields'}) do |f| %> 1 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_community_fields'}) do |f| %>
4 2
5 <table id='community_fields_conf'> 3 <table id='community_fields_conf'>
@@ -9,21 +7,37 @@ @@ -9,21 +7,37 @@
9 <th><%= _('Required') %></th> 7 <th><%= _('Required') %></th>
10 <th><%= _('Display on creation?') %></th> 8 <th><%= _('Display on creation?') %></th>
11 </tr> 9 </tr>
  10 +
  11 + <tr class='manage-fields-batch-actions'>
  12 + <td>
  13 + <%= _("Check/Uncheck All")%>
  14 + </td>
  15 + <td>
  16 + <input type="checkbox" id="community_active" />
  17 + </td>
  18 + <td>
  19 + <input type="checkbox" id="community_required" />
  20 + </td>
  21 + <td>
  22 + <input type="checkbox" id="community_signup" />
  23 + </td>
  24 + </tr>
  25 +
12 <% @community_fields.each do |field| %> 26 <% @community_fields.each do |field| %>
13 <tr> 27 <tr>
14 <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> 28 <td><label for="community_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
15 29
16 <td> 30 <td>
17 <%= hidden_field_tag "community_fields[#{field}][active]", false %> 31 <%= hidden_field_tag "community_fields[#{field}][active]", false %>
18 - <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "$('community_fields[#{field}][required]').disabled=$('community_fields[#{field}][signup]').disabled=!this.checked;" %> 32 + <%= check_box_tag "community_fields[#{field}][active]", true, environment.custom_community_field(field, 'active'), :onclick => "active_action(this, 'community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %>
19 </td> 33 </td>
20 <td> 34 <td>
21 <%= hidden_field_tag "community_fields[#{field}][required]", false %> 35 <%= hidden_field_tag "community_fields[#{field}][required]", false %>
22 - <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "if(this.checked) $('community_fields[#{field}][signup]').checked = true;" %> 36 + <%= check_box_tag "community_fields[#{field}][required]", true, environment.custom_community_field(field, 'required'), :onclick => "required_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %>
23 </td> 37 </td>
24 <td> 38 <td>
25 <%= hidden_field_tag "community_fields[#{field}][signup]", false %> 39 <%= hidden_field_tag "community_fields[#{field}][signup]", false %>
26 - <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "if(!this.checked) $('community_fields[#{field}][required]').checked = false;" %> 40 + <%= check_box_tag "community_fields[#{field}][signup]", true, environment.custom_community_field(field, 'signup'), :onclick => "signup_action('community_fields[#{field}][active]','community_fields[#{field}][required]', 'community_fields[#{field}][signup]')" %>
27 </td> 41 </td>
28 42
29 </tr> 43 </tr>
@@ -31,18 +45,18 @@ @@ -31,18 +45,18 @@
31 </table> 45 </table>
32 46
33 <script type='text/javascript'> 47 <script type='text/javascript'>
34 - var trs = $$('#community_fields_conf tr'); 48 + var trs = jQuery('#community_fields_conf tr');
35 var tr, td2; 49 var tr, td2;
36 - for ( var i=0; tr=trs[i]; i++ ) { 50 + for ( var i=2; tr=trs[i]; i++ ) {
37 if ( td2 = tr.getElementsByTagName('td')[1] ) { 51 if ( td2 = tr.getElementsByTagName('td')[1] ) {
38 - td2.getElementsByTagName('input')[0].onclick(); 52 + td2.getElementsByTagName('input')[1].onclick();
39 } 53 }
40 } 54 }
41 </script> 55 </script>
42 56
43 <div> 57 <div>
44 <% button_bar do %> 58 <% button_bar do %>
45 - <%= submit_button('save', _('Save changes')) %> 59 + <%= submit_button('save', _('Save changes'), :id=>"save_community_fields") %>
46 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> 60 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %>
47 <% end %> 61 <% end %>
48 </div> 62 </div>
app/views/features/_manage_enterprise_fields.rhtml
1 -<h2><%= __('Manage enterprise fields') %></h2>  
2 -  
3 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_enterprise_fields'}) do |f| %> 1 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_enterprise_fields'}) do |f| %>
4 2
5 <table id='enterprise_fields_conf'> 3 <table id='enterprise_fields_conf'>
@@ -9,21 +7,37 @@ @@ -9,21 +7,37 @@
9 <th><%= _('Required') %></th> 7 <th><%= _('Required') %></th>
10 <th><%= _('Display on registration?') %></th> 8 <th><%= _('Display on registration?') %></th>
11 </tr> 9 </tr>
  10 +
  11 + <tr class='manage-fields-batch-actions'>
  12 + <td>
  13 + <%= _("Check/Uncheck All")%>
  14 + </td>
  15 + <td>
  16 + <input type="checkbox" id="enterprise_active" />
  17 + </td>
  18 + <td>
  19 + <input type="checkbox" id="enterprise_required" />
  20 + </td>
  21 + <td>
  22 + <input type="checkbox" id="enterprise_signup" />
  23 + </td>
  24 + </tr>
  25 +
12 <% @enterprise_fields.each do |field| %> 26 <% @enterprise_fields.each do |field| %>
13 <tr> 27 <tr>
14 28
15 <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> 29 <td><label for="enterprise_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
16 <td> 30 <td>
17 <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %> 31 <%= hidden_field_tag "enterprise_fields[#{field}][active]", false %>
18 - <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "$('enterprise_fields[#{field}][required]').disabled=$('enterprise_fields[#{field}][signup]').disabled=!this.checked;" %> 32 + <%= check_box_tag "enterprise_fields[#{field}][active]", true, environment.custom_enterprise_field(field, 'active'), :onclick => "active_action(this, 'enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %>
19 </td> 33 </td>
20 <td> 34 <td>
21 <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %> 35 <%= hidden_field_tag "enterprise_fields[#{field}][required]", false %>
22 - <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "if(this.checked) $('enterprise_fields[#{field}][signup]').checked = true;" %> 36 + <%= check_box_tag "enterprise_fields[#{field}][required]", true, environment.custom_enterprise_field(field, 'required'), :onclick => "required_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %>
23 </td> 37 </td>
24 <td> 38 <td>
25 <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %> 39 <%= hidden_field_tag "enterprise_fields[#{field}][signup]", false %>
26 - <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "if(!this.checked) $('enterprise_fields[#{field}][required]').checked = false;" %> 40 + <%= check_box_tag "enterprise_fields[#{field}][signup]", true, environment.custom_enterprise_field(field, 'signup'), :onclick => "signup_action('enterprise_fields[#{field}][active]','enterprise_fields[#{field}][required]', 'enterprise_fields[#{field}][signup]')" %>
27 </td> 41 </td>
28 42
29 </tr> 43 </tr>
@@ -31,18 +45,18 @@ @@ -31,18 +45,18 @@
31 </table> 45 </table>
32 46
33 <script type='text/javascript'> 47 <script type='text/javascript'>
34 - var trs = $$('#enterprise_fields_conf tr'); 48 + var trs = jQuery('#enterprise_fields_conf tr');
35 var tr, td2; 49 var tr, td2;
36 - for ( var i=0; tr=trs[i]; i++ ) { 50 + for ( var i=2; tr=trs[i]; i++ ) {
37 if ( td2 = tr.getElementsByTagName('td')[1] ) { 51 if ( td2 = tr.getElementsByTagName('td')[1] ) {
38 - td2.getElementsByTagName('input')[0].onclick(); 52 + td2.getElementsByTagName('input')[1].onclick();
39 } 53 }
40 } 54 }
41 </script> 55 </script>
42 56
43 <div> 57 <div>
44 <% button_bar do %> 58 <% button_bar do %>
45 - <%= submit_button('save', _('Save changes')) %> 59 + <%= submit_button('save', _('Save changes'), :id=>"save_enterprise_fields") %>
46 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> 60 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %>
47 <% end %> 61 <% end %>
48 </div> 62 </div>
app/views/features/_manage_person_fields.rhtml
1 -<h2><%= _('Manage person fields') %></h2>  
2 -  
3 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_person_fields'}) do |f| %> 1 <% labelled_form_for(:environment, @environment, :url => {:action => 'manage_person_fields'}) do |f| %>
4 2
5 <table id='person_fields_conf'> 3 <table id='person_fields_conf'>
@@ -9,31 +7,48 @@ @@ -9,31 +7,48 @@
9 <th><%= _('Required') %></th> 7 <th><%= _('Required') %></th>
10 <th><%= _('Display on signup?') %></th> 8 <th><%= _('Display on signup?') %></th>
11 </tr> 9 </tr>
  10 +
  11 + <tr class='manage-fields-batch-actions'>
  12 + <td>
  13 + <%= _("Check/Uncheck All")%>
  14 + </td>
  15 + <td>
  16 + <input type="checkbox" id="person_active" />
  17 + </td>
  18 + <td>
  19 + <input type="checkbox" id="person_required" />
  20 + </td>
  21 + <td>
  22 + <input type="checkbox" id="person_signup" />
  23 + </td>
  24 + </tr>
  25 +
12 <% @person_fields.each do |field| %> 26 <% @person_fields.each do |field| %>
13 <tr> 27 <tr>
14 <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td> 28 <td><label for="person_fields[<%= field %>][active]"><%= _(field.humanize) %></label></td>
15 <td> 29 <td>
16 <%= hidden_field_tag "person_fields[#{field}][active]", false %> 30 <%= hidden_field_tag "person_fields[#{field}][active]", false %>
17 - <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "$('person_fields[#{field}][required]').disabled=$('person_fields[#{field}][signup]').disabled=!this.checked;" %> 31 + <%= check_box_tag "person_fields[#{field}][active]", true, environment.custom_person_field(field, 'active'), :onclick => "active_action(this, 'person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %>
18 </td> 32 </td>
19 <td> 33 <td>
20 <%= hidden_field_tag "person_fields[#{field}][required]", false %> 34 <%= hidden_field_tag "person_fields[#{field}][required]", false %>
21 - <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "if(this.checked) $('person_fields[#{field}][signup]').checked = true;" %> 35 + <%= check_box_tag "person_fields[#{field}][required]", true, environment.custom_person_field(field, 'required'), :onclick => "required_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %>
22 </td> 36 </td>
23 <td> 37 <td>
24 <%= hidden_field_tag "person_fields[#{field}][signup]", false %> 38 <%= hidden_field_tag "person_fields[#{field}][signup]", false %>
25 - <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "if(!this.checked) $('person_fields[#{field}][required]').checked = false;" %> 39 + <%= check_box_tag "person_fields[#{field}][signup]", true, environment.custom_person_field(field, 'signup'), :onclick => "signup_action('person_fields[#{field}][active]','person_fields[#{field}][required]', 'person_fields[#{field}][signup]')" %>
26 </td> 40 </td>
27 </tr> 41 </tr>
28 <% end %> 42 <% end %>
29 </table> 43 </table>
30 44
31 <script type='text/javascript'>// <!-- 45 <script type='text/javascript'>// <!--
32 - var trs = $$('#person_fields_conf tr'); 46 + var trs = jQuery('#person_fields_conf tr');
  47 +
33 var tr, td2; 48 var tr, td2;
34 - for ( var i=0; tr=trs[i]; i++ ) { 49 + for ( var i=2; tr=trs[i]; i++ ) {
35 if ( td2 = tr.getElementsByTagName('td')[1] ) { 50 if ( td2 = tr.getElementsByTagName('td')[1] ) {
36 - td2.getElementsByTagName('input')[0].onclick(); 51 + td2.getElementsByTagName('input')[1].onclick();
37 } 52 }
38 } 53 }
39 // --> 54 // -->
@@ -41,7 +56,7 @@ @@ -41,7 +56,7 @@
41 56
42 <div> 57 <div>
43 <% button_bar do %> 58 <% button_bar do %>
44 - <%= submit_button('save', _('Save changes')) %> 59 + <%= submit_button('save', _('Save changes'), :id=>"save_person_fields") %>
45 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> 60 <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %>
46 <% end %> 61 <% end %>
47 </div> 62 </div>
app/views/features/index.rhtml
@@ -26,9 +26,13 @@ Check all the features you want to enable for your environment, uncheck all the @@ -26,9 +26,13 @@ Check all the features you want to enable for your environment, uncheck all the
26 26
27 <h2><%= _('Configure features') %></h2> 27 <h2><%= _('Configure features') %></h2>
28 28
  29 +<h3><%= _('Page to redirect after signup') %></h3>
  30 + <%= select 'environment', 'redirection_after_signup', Environment.signup_redirection_options.map{|key,value|[value,key]} %>
  31 +<hr/>
29 <h3><%= _('Page to redirect after login') %></h3> 32 <h3><%= _('Page to redirect after login') %></h3>
30 <%= select 'environment', 'redirection_after_login', Environment.login_redirection_options.map{|key,value|[value,key]} %> 33 <%= select 'environment', 'redirection_after_login', Environment.login_redirection_options.map{|key,value|[value,key]} %>
31 <hr/> 34 <hr/>
  35 +
32 <h3><%= _('Organization Approval Method') %></h3> 36 <h3><%= _('Organization Approval Method') %></h3>
33 <%= select_organization_approval_method('environment', 'organization_approval_method') %> 37 <%= select_organization_approval_method('environment', 'organization_approval_method') %>
34 <hr/> 38 <hr/>
app/views/features/manage_fields.rhtml
1 -<%= render :partial => 'manage_person_fields' %> 1 +<h1><%= _('Manage fields displayed for profiles') %></h1>
2 2
3 -<% if !environment.enabled?('disable_asset_enterprises') %>  
4 - <%= render :partial => 'manage_enterprise_fields' %> 3 +<% tabs = [] %>
  4 +<% tabs << {:title => _("Person's fields"), :id => 'person-fields',
  5 + :content => (render :partial => 'manage_person_fields')} %>
  6 +<% tabs << {:title => _("Community's fields"), :id => 'community-fields',
  7 + :content => (render :partial => 'manage_community_fields')} %>
  8 +<% unless environment.enabled?('disable_asset_enterprises') %>
  9 + <% tabs << {:title => _("Enterprise's fields"), :id => 'enterprise-fields',
  10 + :content => (render :partial => 'manage_enterprise_fields')} %>
5 <% end %> 11 <% end %>
6 12
7 -<%= render :partial => 'manage_community_fields' %> 13 +<%= render_tabs(tabs) %>
  14 +
  15 +<%= javascript_include_tag "manage-fields.js" %>
app/views/layouts/application-ng.rhtml
@@ -6,6 +6,27 @@ @@ -6,6 +6,27 @@
6 <!--<meta http-equiv="refresh" content="1"/>--> 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 <meta name="description" content="<%= @environment.name %>" /> 8 <meta name="description" content="<%= @environment.name %>" />
  9 +
  10 + <!-- Twitter Card -->
  11 + <meta name="twitter:card" value="summary">
  12 + <meta name="twitter:title" content="<%= h page_title %>">
  13 + <meta name="twitter:description" content="<%= meta_description_tag(@page) %>">
  14 +
  15 + <!-- Open Graph -->
  16 + <meta property="og:type" content="<%= @page ? 'article' : 'website' %>">
  17 + <meta property="og:url" content="<%= @page ? url_for(@page.url) : @environment.top_url %>">
  18 + <meta property="og:title" content="<%= h page_title %>">
  19 + <meta property="og:site_name" content="<%= profile ? profile.name : @environment.name %>">
  20 + <meta property="og:description" content="<%= @page ? truncate(strip_tags(@page.body.to_s), :length => 200) : @environment.name %>">
  21 +
  22 + <% if @page %>
  23 + <meta property="article:published_time" content="<%= show_date(@page.published_at) %>">
  24 + <% @page.body_images_paths.each do |img| %>
  25 + <meta name="twitter:image" content="<%= img.to_s %>">
  26 + <meta property="og:image" content="<%= img.to_s %>">
  27 + <% end %>
  28 + <% end %>
  29 +
9 <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> 30 <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" />
10 <%= noosfero_javascript %> 31 <%= noosfero_javascript %>
11 <%= noosfero_stylesheets %> 32 <%= noosfero_stylesheets %>
app/views/person_notifier/mailer/_add_member_in_community.rhtml 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => 'default_activity', :locals => { :activity => activity } %>
app/views/person_notifier/mailer/_comment.rhtml 0 → 100644
@@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
  1 +<% Comment %>
  2 +<% Profile %>
  3 +<% Person %>
  4 +
  5 +<table style="background: #f0f0f1;border-bottom: 1px solid #d2d2d2 !important;border-top: 1px solid #fff;margin-bottom: 0;">
  6 +<tr>
  7 + <td>
  8 + <% if comment.author %>
  9 + <%= link_to profile_image(comment.author, :minor),
  10 + comment.author_url,
  11 + :class => 'comment-picture',
  12 + :title => comment.author_name
  13 + %>
  14 + <% end %>
  15 + </td>
  16 + <td>
  17 + <%= comment.author.present? ? link_to(comment.author_name, comment.author.url, :style => "font-size: 12px; color: #333; font-weight: bold; text-decoration: none;") : content_tag('strong', comment.author_name) %>
  18 + <% unless comment.title.blank? %>
  19 + <span style="font-size: 12px;"><%= comment.title %></span><br/>
  20 + <% end %>
  21 + <span style="font-size: 10px;"><%= txt2html comment.body %></span><br/>
  22 + <span style="font-size: 8px; color: #444444"><%= time_ago_as_sentence(comment.created_at) %></span>
  23 + <br style="clear: both;" />
  24 +
  25 + <% unless comment.replies.blank? %>
  26 + <ul class="comment-replies">
  27 + <% comment.replies.each do |reply| %>
  28 + <%= render :partial => 'comment', :locals => { :comment => reply } %>
  29 + <% end %>
  30 + </ul>
  31 + <% end %>
  32 + </td>
  33 +</table>
app/views/person_notifier/mailer/_create_article.rhtml 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +<table>
  2 +<tr>
  3 + <td>
  4 + <%= link_to(profile_image(activity.user, :minor), activity.user.url) %>
  5 + </td>
  6 + <td>
  7 + <p style="width:550px">
  8 + <span style="font-size: 14px;"><%= link_to activity.user.short_name(20), activity.user.url %></span>
  9 + <span style="font-size: 14px;"><%= _("has published on community %s") % link_to(activity.target.profile.short_name(20), activity.target.profile.url, :style => "color: #333; font-weight: bold; text-decoration: none;") if activity.target.profile.is_a?(Community) %></span>
  10 + <span style="font-size: 10px; color: #444444; float:right;"><%= time_ago_as_sentence(activity.created_at) %></span>
  11 + </p>
  12 + <p>
  13 + <span style="font-size: 14px;"><%= link_to(activity.params['name'], activity.params['url'], :style => "color: #333; font-weight: bold; text-decoration: none;") %></span>
  14 + <br/>
  15 + <span title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-new<%= activity.target.class.icon_name %>'></span>
  16 + <%= image_tag(activity.params['first_image']) unless activity.params['first_image'].blank? %><%= strip_tags(truncate(activity.params['lead'], :length => 1000, :ommision => '...')).gsub(/(\xC2\xA0|\s)+/, ' ').gsub(/^\s+/, '') %>
  17 + </p>
  18 + <p><%= content_tag(:p, link_to(_('See complete forum'), activity.get_url), :class => 'see-forum') if activity.target.is_a?(Forum) %></p>
  19 + </td>
  20 +</tr>
  21 +<tr>
  22 + <td></td>
  23 + <td>
  24 + <%= render :partial => 'profile_comments', :locals => { :activity => activity } %>
  25 + </td>
  26 +</tr>
  27 +</table>
app/views/person_notifier/mailer/_default_activity.rhtml 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +<table>
  2 +<tr>
  3 + <td>
  4 + <%= link_to(profile_image(activity.user, :minor), activity.user.url) %>
  5 + </td>
  6 + <td>
  7 + <p style="width:550px">
  8 + <span style="font-size: 14px;"><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></span>
  9 + <span style="font-size: 10px; color: #444444; float: right;"><%= time_ago_as_sentence(activity.created_at) %></span>
  10 + </p>
  11 + </td>
  12 +</tr>
  13 +<tr>
  14 + <td></td>
  15 + <td>
  16 + <%= render :partial => 'profile_comments', :locals => { :activity => activity } %>
  17 + </td>
  18 +</tr>
  19 +</table>
app/views/person_notifier/mailer/_join_community.rhtml 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => 'default_activity', :locals => { :activity => activity } %>
app/views/person_notifier/mailer/_leave_scrap.rhtml 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => 'default_activity', :locals => { :activity => activity } %>
app/views/person_notifier/mailer/_leave_scrap_to_self.rhtml 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +_leave_scrap.rhtml
0 \ No newline at end of file 2 \ No newline at end of file
app/views/person_notifier/mailer/_new_friendship.rhtml 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => 'default_activity', :locals => { :activity => activity } %>
app/views/person_notifier/mailer/_profile_comments.rhtml 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +<% if activity.comments_count > 2 %>
  2 + <div style="font-size: 10px;">
  3 + <% if activity.params['url'].blank? %>
  4 + <%= _("%s comments") % activity.comments_count %>
  5 + <% else %>
  6 + <%= link_to(_("View all %s comments") % activity.comments_count, activity.params['url']) %>
  7 + <% end %>
  8 + </div>
  9 +<% else %>
  10 + <ul>
  11 + <%= render :partial => 'comment', :collection => activity.comments %>
  12 + </ul>
  13 +<% end %>
app/views/person_notifier/mailer/_reply_scrap_on_self.rhtml 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +_leave_scrap.rhtml
0 \ No newline at end of file 2 \ No newline at end of file
app/views/person_notifier/mailer/_upload_image.rhtml 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +<table>
  2 + <tr>
  3 + <td>
  4 + <%= link_to(profile_image(activity.user, :minor), activity.user.url) %>
  5 + </td>
  6 + <td>
  7 + <p style="width:550px">
  8 + <span style="font-size: 14px;"><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></span>
  9 + <span style="font-size: 10px; color: #444444; float:right;"><%= time_ago_as_sentence(activity.created_at) %></span>
  10 + </p>
  11 + </td>
  12 +</tr>
  13 +</table>
  14 +<div title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-newgallery'></div>
  15 +<br/>
app/views/person_notifier/mailer/content_summary.rhtml 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +<h3><%= _("%s's network activity") % @profile.name %></h3>
  2 +<br/>
  3 +<div>
  4 +<% @notifications.each do |activity| %>
  5 + <div style="border-left:none;border-right:none;border-top:1px solid #ccc;border-bottom:none;padding:10px;width:600px">
  6 + <%= render :partial => activity.verb, :locals => { :activity => activity } rescue "cannot render notification for #{activity.verb}" %>
  7 + </div>
  8 +<% end %>
  9 +</div>
  10 +
  11 +<div style="color:#444444;font-size:11px;">
  12 +<p><%= _("Greetings,") %></p>
  13 +<br/>
  14 +<p>--</p>
  15 +<p><%= _('%s team.') % @environment %></p>
  16 +<p><%= url_for @url %></p>
  17 +</div>
  18 +<br/>
app/views/profile_editor/_person.rhtml
@@ -19,3 +19,8 @@ @@ -19,3 +19,8 @@
19 <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %> 19 <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %>
20 20
21 <%= render :partial => 'person_form', :locals => {:f => f} %> 21 <%= render :partial => 'person_form', :locals => {:f => f} %>
  22 +
  23 + <h2><%= _('Notification options') %></h2>
  24 + <div>
  25 + <%= select_tag 'profile_data[notification_time]', options_for_select([[_('Disabled'), 0], [_('Hourly'), 1], [_('Half Day'), 12], [_('Daily'), 24]], @profile.notification_time) %>
  26 + </div>
app/views/shared/_select_categories.rhtml
1 -<div id="category-ajax-selector"> 1 +<% extend CategoriesHelper %>
  2 +
2 <% if !@current_category.nil? %> 3 <% if !@current_category.nil? %>
3 - <h3 class="box-title"><%= _('Current category:') %></h3>  
4 <%= hidden_field_tag "#{object_name}[#{object_name}_category_id]", @current_category.id unless multiple %> 4 <%= hidden_field_tag "#{object_name}[#{object_name}_category_id]", @current_category.id unless multiple %>
  5 + <%= hidden_field_tag "#{object_name}[category_ids][]", @current_category.id if multiple %>
  6 + <%= button_to_remote_without_text(:back, _('Back'),
  7 + { :update => "select-categories",
  8 + :url => { :action => 'update_categories', :id => @object },
  9 + :loaded => visual_effect(:highlight, "select-categories")
  10 + },
  11 + :id => 'cancel-category-button') %>
5 <% 12 <%
6 categories = [@current_category] 13 categories = [@current_category]
7 categories.push(@current_category) while @current_category = @current_category.parent 14 categories.push(@current_category) while @current_category = @current_category.parent
8 %> 15 %>
9 <%= categories.compact.reverse.map{|i| 16 <%= categories.compact.reverse.map{|i|
10 - link_to_remote(i.name, 17 + link_to_remote(i.name,
11 :update => "select-categories", 18 :update => "select-categories",
12 :url => { :action => 'update_categories', :category_id => i.id, :id => @object }, 19 :url => { :action => 'update_categories', :category_id => i.id, :id => @object },
13 :loaded => visual_effect(:highlight, "select-categories"), 20 :loaded => visual_effect(:highlight, "select-categories"),
14 :class => 'select-current-category-link')}.join(' &rarr; ') 21 :class => 'select-current-category-link')}.join(' &rarr; ')
15 %> 22 %>
16 - <strong>  
17 - <%= button_to_function_without_text(:save, _('Save'), nil, :id => 'save-category-button') do |page|  
18 - page.insert_html :bottom, 'selected-categories', content_tag('li', categories.first.full_name + 23 + <%= button_to_function_without_text(:add, _('Add'), nil, :id => 'save-category-button') do |page|
  24 + page.insert_html :bottom, 'selected-categories', content_tag('div',
19 hidden_field_tag("#{object_name}[category_ids][]", categories.first.id) + 25 hidden_field_tag("#{object_name}[category_ids][]", categories.first.id) +
20 - button_to_function_without_text(:cancel, _('Remove'), nil, :id => "remove-selected-category-#{categories.first.id}-button") {|page| page["selected-category-#{categories.first.id}"].remove}, :id => "selected-category-#{categories.first.id}") 26 + selected_category_link(categories.first), :id => "selected-category-#{categories.first.id}")
  27 + page.replace_html 'select-categories', :partial => 'shared/select_subcategories',
  28 + :locals => {:object_name => object_name, :categories => @toplevel_categories}
21 end if multiple %> 29 end if multiple %>
22 - <%= button_to_remote_without_text(:cancel, _('Cancel'),  
23 - { :update => "select-categories",  
24 - :url => { :action => 'update_categories', :id => @object },  
25 - :loaded => visual_effect(:highlight, "select-categories")  
26 - },  
27 - :id => 'cancel-category-button') %>  
28 - </strong>  
29 -<% else %>  
30 - <h3 class="box-title"><%= _('Select a category:') %></h3>  
31 <% end %> 30 <% end %>
32 31
33 -<% if !@categories.empty? %>  
34 - <h3><%= _('Categories:') %></h3>  
35 - <% @categories.select{|i| !@object.respond_to?(:accept_category?) || @object.accept_category?(i)}.each do |category| %>  
36 - <%= link_to_remote category.name,  
37 - { :update => "select-categories",  
38 - :url => { :action => "update_categories", :category_id => category.id, :id => @object},  
39 - :loaded => visual_effect(:highlight, "select-categories")  
40 - },  
41 - :class => 'select-subcategory-link',  
42 - :id => "select-category-#{category.id}-link"  
43 - %>  
44 - <% end %> &nbsp;  
45 -<% end %> 32 +<div class="toplevel-categories">
  33 + <%= render :partial => 'shared/select_subcategories', :locals => {:object_name => object_name, :categories => @categories} %>
46 </div> 34 </div>
app/views/shared/_select_categories_top.rhtml 0 → 100644
@@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
  1 +<% categories_selected ||= nil %>
  2 +<% title ||= nil %>
  3 +
  4 +<% extend CategoriesHelper %>
  5 +
  6 +<%= content_tag "h#{title_size}", title, :class => "box-title" %>
  7 +
  8 +<%= hidden_field_tag "#{object_name}[category_ids][]", nil %>
  9 +
  10 +<div id="category-ajax-selector">
  11 +<% unless categories_selected.nil? %>
  12 +<div id="selected-categories">
  13 + <div class="label"><%= _('Selected categories:') %></div>
  14 + <% categories_selected.each do |cat| %>
  15 + <div id="selected-category-<%= cat.id %>">
  16 + <%= hidden_field_tag("#{object_name}[category_ids][]", cat.id) %>
  17 + <%= selected_category_link(cat) %>
  18 + </div>
  19 + <% end %>
  20 +</div>
  21 +<% end %>
  22 +<div id="select-categories">
  23 + <%= render :partial => 'shared/select_categories', :locals => {:object_name => object_name, :multiple => true, :categories_selected => categories_selected }, :layout => false %>
  24 +</div>
  25 +
  26 +</div>
app/views/shared/_select_subcategories.rhtml 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +<% if !categories.nil? && !categories.empty? && !@object.nil? %>
  2 + <hr>
  3 + <div class="category-helper-label"><%= _('Click to select a category') %></div>
  4 +
  5 + <% categories.select{|i| @object.accept_category?(i)}.each do |category| %>
  6 +
  7 + <%= link_to_remote category.name,
  8 + { :update => "select-categories",
  9 + :url => { :action => "update_categories", :category_id => category.id, :id => @object},
  10 + :loaded => visual_effect(:highlight, "select-categories")
  11 + },
  12 + :class => 'select-subcategory-link',
  13 + :id => "select-category-#{category.id}-link"
  14 + %>
  15 + <% end %>
  16 +<% end %>
app/views/shared/block.rhtml
1 <% if block.cacheable? && use_cache %> 1 <% if block.cacheable? && use_cache %>
2 - <% cache_timeout(block.cache_key(language), block.timeout) do %> 2 + <% cache_timeout(block.cache_key(language, user), block.timeout) do %>
3 <%= display_block_content(block, user, main_content) %> 3 <%= display_block_content(block, user, main_content) %>
4 <% end %> 4 <% end %>
5 <% else %> 5 <% else %>
app/views/themes/_select_template.rhtml
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 "/designs/templates/#{template.id}/thumbnail.png", 12 "/designs/templates/#{template.id}/thumbnail.png",
13 :alt => _('The "%s" template')) + 13 :alt => _('The "%s" template')) +
14 '<div class="opt-info">'.html_safe + 14 '<div class="opt-info">'.html_safe +
15 - content_tag('strong', template.name, :class => 'name') + 15 + content_tag('strong', template.name, :title => template.title, :class => 'name') +
16 ' <br/> '.html_safe 16 ' <br/> '.html_safe
17 17
18 if @current_template == template.id # selected 18 if @current_template == template.id # selected
app/views/user/mailer/activation_code.rhtml
1 <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> 1 <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
2 2
3 -<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code) }) %> 3 +<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => @redirection) }) %>
4 4
5 <%= _("Greetings,") %> 5 <%= _("Greetings,") %>
6 6
app/views/users/_users_list.rhtml
@@ -19,16 +19,17 @@ @@ -19,16 +19,17 @@
19 <td class='actions'> 19 <td class='actions'>
20 <div class="members-buttons-cell"> 20 <div class="members-buttons-cell">
21 <% if p.is_admin? %> 21 <% if p.is_admin? %>
22 - <%= button_without_text :'reset-admin-role', _('Reset admin role'), :action => 'reset_admin_role', :id => p, :q => @q, :filter => @filter %> 22 + <%= button_without_text :'reset-admin-role', _('Reset admin role'), {:action => 'reset_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to reset this user as administrator?") %>
23 <% else %> 23 <% else %>
24 - <%= button_without_text :'set-admin-role', _('Set admin role'), :action => 'set_admin_role', :id => p, :q => @q, :filter => @filter %> 24 + <%= button_without_text :'set-admin-role', _('Set admin role'), {:action => 'set_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to set this user as administrator?") %>
25 <% end %> 25 <% end %>
26 <% if !p.user.activated? %> 26 <% if !p.user.activated? %>
27 - <%= button_without_text :'activate-user', _('Activate user'), :action => 'activate', :id => p, :q => @q, :filter => @filter %> 27 + <%= button_without_text :'activate-user', _('Activate user'), {:action => 'activate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to activate this user?") %>
28 <% else %> 28 <% else %>
29 - <%= button_without_text :'deactivate-user', _('Deactivate user'), :action => 'deactivate', :id => p, :q => @q, :filter => @filter %> 29 + <%= button_without_text :'deactivate-user', _('Deactivate user'), {:action => 'deactivate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to deactivate this user?") %>
30 <% end %> 30 <% end %>
31 - </div> 31 + <%= button_without_text :'delete', _('Remove'), {:action => :destroy_user, :id => p, :q => @q}, :method => :post, :filter => @filter, :confirm => _("Do you want to remove this user?") %>
  32 + </div>
32 </td> 33 </td>
33 </tr> 34 </tr>
34 <% end %> 35 <% end %>
config/initializers/activities_counter_cache.rb 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +if Delayed::Backend::ActiveRecord::Job.table_exists?
  2 + job = Delayed::Backend::ActiveRecord::Job.all :conditions => ['handler LIKE ?', "%ActivitiesCounterCacheJob%"]
  3 + if job.blank?
  4 + Delayed::Backend::ActiveRecord::Job.enqueue(ActivitiesCounterCacheJob.new, -3)
  5 + end
  6 +end
config/initializers/delayed_job_config.rb
1 Delayed::Worker.backend = :active_record 1 Delayed::Worker.backend = :active_record
2 Delayed::Worker.max_attempts = 2 2 Delayed::Worker.max_attempts = 2
3 -Delayed::Worker.max_run_time = 10.minutes 3 +
  4 +# TODO This is consuming ton of space on development with a postgres connection
  5 +# error on the jobs. This must be verified before going into production.
  6 +# Logging jobs backtraces
  7 +#class Delayed::Worker
  8 +# def handle_failed_job_with_loggin(job, error)
  9 +# handle_failed_job_without_loggin(job,error)
  10 +# Delayed::Worker.logger.error(error.message)
  11 +# Delayed::Worker.logger.error(error.backtrace.join("\n"))
  12 +# end
  13 +# alias_method_chain :handle_failed_job, :loggin
  14 +#end
config/initializers/noosfero_extensions.rb 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +require 'noosfero/role_assignment_ext'
  2 +require 'noosfero/action_tracker_ext'
config/initializers/person_notification.rb 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +if Delayed::Backend::ActiveRecord::Job.table_exists?
  2 + PersonNotifier.schedule_all_next_notification_mail
  3 +end
db/migrate/20140205191914_add_redirection_after_signup_to_environment.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddRedirectionAfterSignupToEnvironment < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :environments, :redirection_after_signup, :string, :default => 'keep_on_same_page'
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :environments, :redirection_after_signup
  8 + end
  9 +end
db/migrate/20140221142304_move_title_virtual_field_to_name_in_uploaded_file.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +class MoveTitleVirtualFieldToNameInUploadedFile < ActiveRecord::Migration
  2 + def self.up
  3 + UploadedFile.find_each do |uploaded_file|
  4 + uploaded_file.name = uploaded_file.setting.delete :title
  5 + uploaded_file.send :update_without_callbacks
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + say "this migration can't be reverted"
  11 + end
  12 +end
db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +class MoveContactEmailToNoreplyEmailAtEnvironment < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :environments, :noreply_email, :string
  4 + Environment.reset_column_information
  5 +
  6 + Environment.find_each do |environment|
  7 + environment.noreply_email = environment.contact_email
  8 + environment.contact_email = nil
  9 + environment.save!
  10 + end
  11 + end
  12 +
  13 + def self.down
  14 + say "this migration can't be reverted"
  15 + end
  16 +end
db/migrate/20140312132212_add_indexes_for_article_search.rb 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +class AddIndexesForArticleSearch < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :articles, :created_at
  4 + add_index :articles, :hits
  5 + add_index :articles, :comments_count
  6 + end
  7 +
  8 + def self.down
  9 + remove_index :articles, :created_at
  10 + remove_index :articles, :hits
  11 + remove_index :articles, :comments_count
  12 + end
  13 +end
db/migrate/20140312134218_add_indexes_for_profile_search.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddIndexesForProfileSearch < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :profiles, :created_at
  4 + end
  5 +
  6 + def self.down
  7 + remove_index :profiles, :created_at
  8 + end
  9 +end
db/migrate/20140312141805_create_cache_counts_for_profiles.rb 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +class CreateCacheCountsForProfiles < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :profiles, :friends_count, :integer, :null => false, :default => 0
  4 + add_column :profiles, :members_count, :integer, :null => false, :default => 0
  5 + add_column :profiles, :activities_count, :integer, :null => false, :default => 0
  6 + add_index :profiles, :friends_count
  7 + add_index :profiles, :members_count
  8 + add_index :profiles, :activities_count
  9 + end
  10 +
  11 + def self.down
  12 + remove_column :profiles, :friends_count
  13 + remove_column :profiles, :members_count
  14 + remove_column :profiles, :activities_count
  15 + remove_index :profiles, :friends_count
  16 + remove_index :profiles, :members_count
  17 + remove_index :profiles, :activities_count
  18 + end
  19 +end
db/migrate/20140312144156_define_initial_value_for_profiles_friends_count.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +class DefineInitialValueForProfilesFriendsCount < ActiveRecord::Migration
  2 + def self.up
  3 + friends_counts = execute("SELECT profiles.id, count(profiles.id) FROM profiles INNER JOIN friendships ON ( profiles.id = friendships.friend_id AND profiles.type = E'Person') GROUP BY profiles.id;")
  4 + friends_counts.each do |count|
  5 + execute("UPDATE profiles SET friends_count=#{count['count'].to_i} WHERE profiles.id=#{count['id']};")
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + execute("UPDATE profiles SET friends_count=0;")
  11 + end
  12 +end
db/migrate/20140312151857_define_initial_value_for_profiles_activities_count.rb 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +class DefineInitialValueForProfilesActivitiesCount < ActiveRecord::Migration
  2 + def self.up
  3 + person_activities_counts = execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= '#{30.days.ago.to_s(:db)}') AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")
  4 + organization_activities_counts = execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= '#{30.days.ago.to_s(:db)}') AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;")
  5 + activities_counts = person_activities_counts.entries + organization_activities_counts.entries
  6 + activities_counts.each do |count|
  7 + execute("UPDATE profiles SET activities_count=#{count['count'].to_i} WHERE profiles.id=#{count['id']};")
  8 + end
  9 + end
  10 +
  11 + def self.down
  12 + execute("UPDATE profiles SET activities_count=0;")
  13 + end
  14 +end
db/migrate/20140312184749_add_return_to_to_users.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddReturnToToUsers < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :users, :return_to, :string
  4 + end
  5 +
  6 + def self.down
  7 + remove_column :users, :return_to, :string
  8 + end
  9 +end
db/migrate/20140313213142_define_initial_value_for_profiles_members_count.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +class DefineInitialValueForProfilesMembersCount < ActiveRecord::Migration
  2 + def self.up
  3 + members_counts = execute("SELECT profiles.id, count(profiles.id) FROM profiles LEFT OUTER JOIN role_assignments ON profiles.id = role_assignments.resource_id WHERE (profiles.type = 'Organization' OR profiles.type = 'Community' OR profiles.type = 'Enterprise') GROUP BY profiles.id;")
  4 + members_counts.each do |count|
  5 + execute("UPDATE profiles SET members_count=#{count['count'].to_i} WHERE profiles.id=#{count['id']};")
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + execute("UPDATE profiles SET members_count=0;")
  11 + end
  12 +end
db/migrate/20140314200103_add_indexes_for_products_search.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class AddIndexesForProductsSearch < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :products, :created_at
  4 + end
  5 +
  6 + def self.down
  7 + remove_index :products, :created_at
  8 + end
  9 +end
1 -# This file is auto-generated from the current state of the database. Instead of editing this file, 1 +# This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of Active Record to incrementally modify your database, and 2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 # then regenerate this schema definition. 3 # then regenerate this schema definition.
4 # 4 #
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 # 9 #
10 # It's strongly recommended to check this file into your version control system. 10 # It's strongly recommended to check this file into your version control system.
11 11
12 -ActiveRecord::Schema.define(:version => 20140108132730) do 12 +ActiveRecord::Schema.define(:version => 20140314200103) do
13 13
14 create_table "abuse_reports", :force => true do |t| 14 create_table "abuse_reports", :force => true do |t|
15 t.integer "reporter_id" 15 t.integer "reporter_id"
@@ -140,6 +140,9 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -140,6 +140,9 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
140 t.integer "position" 140 t.integer "position"
141 end 141 end
142 142
  143 + add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count"
  144 + add_index "articles", ["created_at"], :name => "index_articles_on_created_at"
  145 + add_index "articles", ["hits"], :name => "index_articles_on_hits"
143 add_index "articles", ["name"], :name => "index_articles_on_name" 146 add_index "articles", ["name"], :name => "index_articles_on_name"
144 add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id" 147 add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id"
145 add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id" 148 add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id"
@@ -282,6 +285,8 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -282,6 +285,8 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
282 t.text "signup_welcome_text" 285 t.text "signup_welcome_text"
283 t.string "languages" 286 t.string "languages"
284 t.string "default_language" 287 t.string "default_language"
  288 + t.string "redirection_after_signup", :default => "keep_on_same_page"
  289 + t.string "noreply_email"
285 end 290 end
286 291
287 create_table "external_feeds", :force => true do |t| 292 create_table "external_feeds", :force => true do |t|
@@ -432,6 +437,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -432,6 +437,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
432 t.boolean "archived", :default => false 437 t.boolean "archived", :default => false
433 end 438 end
434 439
  440 + add_index "products", ["created_at"], :name => "index_products_on_created_at"
435 add_index "products", ["product_category_id"], :name => "index_products_on_product_category_id" 441 add_index "products", ["product_category_id"], :name => "index_products_on_product_category_id"
436 add_index "products", ["profile_id"], :name => "index_products_on_profile_id" 442 add_index "products", ["profile_id"], :name => "index_products_on_profile_id"
437 443
@@ -470,10 +476,17 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -470,10 +476,17 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
470 t.string "redirection_after_login" 476 t.string "redirection_after_login"
471 t.string "personal_website" 477 t.string "personal_website"
472 t.string "jabber_id" 478 t.string "jabber_id"
  479 + t.integer "friends_count", :default => 0, :null => false
  480 + t.integer "members_count", :default => 0, :null => false
  481 + t.integer "activities_count", :default => 0, :null => false
473 end 482 end
474 483
  484 + add_index "profiles", ["activities_count"], :name => "index_profiles_on_activities_count"
  485 + add_index "profiles", ["created_at"], :name => "index_profiles_on_created_at"
475 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id" 486 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id"
  487 + add_index "profiles", ["friends_count"], :name => "index_profiles_on_friends_count"
476 add_index "profiles", ["identifier"], :name => "index_profiles_on_identifier" 488 add_index "profiles", ["identifier"], :name => "index_profiles_on_identifier"
  489 + add_index "profiles", ["members_count"], :name => "index_profiles_on_members_count"
477 add_index "profiles", ["region_id"], :name => "index_profiles_on_region_id" 490 add_index "profiles", ["region_id"], :name => "index_profiles_on_region_id"
478 491
479 create_table "qualifier_certifiers", :force => true do |t| 492 create_table "qualifier_certifiers", :force => true do |t|
@@ -619,6 +632,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -619,6 +632,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
619 t.datetime "chat_status_at" 632 t.datetime "chat_status_at"
620 t.string "activation_code", :limit => 40 633 t.string "activation_code", :limit => 40
621 t.datetime "activated_at" 634 t.datetime "activated_at"
  635 + t.string "return_to"
622 end 636 end
623 637
624 create_table "validation_infos", :force => true do |t| 638 create_table "validation_infos", :force => true do |t|
debian/changelog
  1 +noosfero (0.47.0~rc1) squeeze-test; urgency=low
  2 +
  3 + * New features Release Candidate 1
  4 +
  5 + -- Rodrigo Souto <rodrigo@colivre.coop.br> Thu, 20 Mar 2014 20:26:45 +0000
  6 +
  7 +noosfero (0.46.2) unstable; urgency=low
  8 +
  9 + * Bugfix release
  10 +
  11 + -- Rodrigo Souto <rodrigo@colivre.coop.br> Wed, 19 Mar 2014 23:41:06 +0000
  12 +
1 noosfero (0.46.1) unstable; urgency=low 13 noosfero (0.46.1) unstable; urgency=low
2 14
3 * Bugfixes release 15 * Bugfixes release
features/forum.feature
@@ -166,3 +166,121 @@ Feature: forum @@ -166,3 +166,121 @@ Feature: forum
166 | Post one | joaosilva | Hi all | Hi all | 166 | Post one | joaosilva | Hi all | Hi all |
167 When I go to /joaosilva/forum 167 When I go to /joaosilva/forum
168 Then I should see "Joao" linking to "http://localhost/joaosilva" 168 Then I should see "Joao" linking to "http://localhost/joaosilva"
  169 +
  170 + @selenium
  171 + Scenario: community member should be able to see the discussion topic button
  172 + Given the following community
  173 + | identifier | name | owner |
  174 + | sample-community | Sample Community | joaosilva |
  175 + And the following forums
  176 + | owner | name |
  177 + | sample-community | Forum |
  178 + And the following users
  179 + | login | name |
  180 + | mariasilva | Maria Silva|
  181 + And "Maria Silva" is a member of "Sample Community"
  182 + And I am logged in as "joaosilva"
  183 + When I go to /sample-community/forum
  184 + And I follow "Configure forum"
  185 + And I check "Allow member to create topics"
  186 + And I press "Save"
  187 + And I am logged in as "mariasilva"
  188 + And I go to /sample-community/forum
  189 + Then I should see "New discussion topic"
  190 +
  191 + @selenium
  192 + Scenario: a non community member should not be able to see the discussion topic button
  193 + Given the following community
  194 + | identifier | name | owner |
  195 + | sample-community | Sample Community | joaosilva |
  196 + And the following forums
  197 + | owner | name |
  198 + | sample-community | Forum |
  199 + And the following users
  200 + | login | name |
  201 + | mariasilva | Maria Silva|
  202 + And I am logged in as "joaosilva"
  203 + When I go to /sample-community/forum
  204 + And I follow "Configure forum"
  205 + And I check "Allow member to create topics"
  206 + And I press "Save"
  207 + And I am logged in as "mariasilva"
  208 + And I go to /sample-community/forum
  209 + Then I should not see "New discussion topic"
  210 +
  211 + @selenium
  212 + Scenario: community member should not be able to see the discussion topic button
  213 + Given the following community
  214 + | identifier | name | owner |
  215 + | sample-community | Sample Community | joaosilva |
  216 + And the following forums
  217 + | owner | name |
  218 + | sample-community | Forum |
  219 + And the following users
  220 + | login | name |
  221 + | mariasilva | Maria Silva|
  222 + And "Maria Silva" is a member of "Sample Community"
  223 + And I am logged in as "joaosilva"
  224 + When I go to /sample-community/forum
  225 + And I follow "Configure forum"
  226 + And I uncheck "Allow member to create topics"
  227 + And I press "Save"
  228 + And I am logged in as "mariasilva"
  229 + And I go to /sample-community/forum
  230 + Then I should not see "New discussion topic"
  231 +
  232 + @selenium
  233 + Scenario: community member should be able to create a topic with the discussion topic button
  234 + Given the following community
  235 + | identifier | name | owner |
  236 + | sample-community | Sample Community | joaosilva |
  237 + And the following forums
  238 + | owner | name |
  239 + | sample-community | Forum |
  240 + And the following users
  241 + | login | name |
  242 + | mariasilva | Maria Silva|
  243 + And "Maria Silva" is a member of "Sample Community"
  244 + And I am logged in as "joaosilva"
  245 + When I go to /sample-community/forum
  246 + And I follow "Configure forum"
  247 + And I check "Allow member to create topics"
  248 + And I press "Save"
  249 + And I am logged in as "mariasilva"
  250 + And I go to /sample-community/forum
  251 + And I follow "New discussion topic"
  252 + And I follow "Text article with visual editor"
  253 + And I fill in "Title" with "Test"
  254 + And I press "Save"
  255 + Then I should see "Test"
  256 +
  257 + @selenium
  258 + Scenario: community member should be able to create a topic on a topic page
  259 + Given the following community
  260 + | identifier | name | owner |
  261 + | sample-community | Sample Community | joaosilva |
  262 + And the following forums
  263 + | owner | name |
  264 + | sample-community | Forum |
  265 + And the following users
  266 + | login | name |
  267 + | mariasilva | Maria Silva|
  268 + And "Maria Silva" is a member of "Sample Community"
  269 + And I am logged in as "joaosilva"
  270 + When I go to /sample-community/forum
  271 + And I follow "Configure forum"
  272 + And I check "Allow member to create topics"
  273 + And I press "Save"
  274 + And I am logged in as "mariasilva"
  275 + And I go to /sample-community/forum
  276 + And I follow "New discussion topic"
  277 + And I follow "Text article with visual editor"
  278 + And I fill in "Title" with "Test"
  279 + And I press "Save"
  280 + And I go to /sample-community/forum/test
  281 + And I follow "New discussion topic"
  282 + And I follow "Text article with visual editor"
  283 + And I fill in "Title" with "Test inside the topic page"
  284 + And I press "Save"
  285 + And I go to /sample-community/forum
  286 + Then I should see "Test inside the topic page"
169 \ No newline at end of file 287 \ No newline at end of file
features/manage_fields.feature 0 → 100644
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
  1 +Feature: check all manage fields
  2 + As an administrator
  3 + I want to check and uncheck all person, enterprise and community's fields
  4 +
  5 + Background:
  6 + Given the following users
  7 + | login | name |
  8 + | mariasilva | Maria Silva |
  9 + And the following enterprises
  10 + | identifier | owner | name | contact_email | contact_phone | enabled |
  11 + | paper-street | mariasilva | Paper Street | marial.silva@workerbees.org | (288) 555-0153 | true |
  12 + And the following community
  13 + | identifier | name |
  14 + | mycommunity | My Community |
  15 + And I am logged in as admin
  16 + And I go to /admin/features/manage_fields
  17 +
  18 + @selenium
  19 + Scenario: check all active person fields
  20 + Given I follow "Person's fields"
  21 + And I check "person_active"
  22 + And I press "save_person_fields"
  23 + When I go to admin_user's control panel
  24 + And I follow "Edit Profile"
  25 + Then I should see "Custom area of study"
  26 +
  27 + @selenium
  28 + Scenario: check all active enterprise fields
  29 + Given I follow "Enterprise's fields"
  30 + And I check "enterprise_active"
  31 + And I press "save_enterprise_fields"
  32 + When I go to paper-street's control panel
  33 + And I follow "Enterprise Info and settings"
  34 + Then I should see "Historic and current context"
  35 +
  36 + @selenium
  37 + Scenario: check all active community fields
  38 + Given I follow "Community's fields"
  39 + And I check "community_active"
  40 + And I press "save_community_fields"
  41 + When I go to mycommunity's control panel
  42 + And I follow "Community Info and settings"
  43 + Then I should see "Economic activity"
  44 +
  45 + @selenium
  46 + Scenario: uncheck Check/Uncheck All active person field
  47 + Given I follow "Person's fields"
  48 + And I check "person_active"
  49 + And I press "save_person_fields"
  50 + And I uncheck "person_active"
  51 + And I press "save_person_fields"
  52 + And I follow "Control panel"
  53 + When I follow "Edit Profile"
  54 + Then I should not see "Custom area of study"
  55 +
  56 + @selenium
  57 + Scenario: uncheck Check/Uncheck All active community field
  58 + Given I follow "Community's fields"
  59 + And I check "community_active"
  60 + And I press "save_community_fields"
  61 + And I uncheck "community_active"
  62 + And I press "save_community_fields"
  63 + When I go to mycommunity's control panel
  64 + And I follow "Community Info and settings"
  65 + Then I should not see "Economic activity"
  66 +
  67 + @selenium
  68 + Scenario: uncheck Check/Uncheck All active enterprise field
  69 + Given I follow "Enterprise's fields"
  70 + And I check "enterprise_active"
  71 + And I press "save_enterprise_fields"
  72 + And I uncheck "enterprise_active"
  73 + And I press "save_enterprise_fields"
  74 + When I go to paper-street's control panel
  75 + And I follow "Enterprise Info and settings"
  76 + Then I should not see "Historic and current context"
features/manage_users.feature 0 → 100644
@@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
  1 +Feature: manage users
  2 + As an environment administrator
  3 + I want to manage users
  4 + In order to remove, activate, deactivate users, and set admin roles.
  5 +
  6 +Background:
  7 + Given the following users
  8 + | login | name |
  9 + | joaosilva | Joao Silva |
  10 + | paulosantos | Paulo Santos |
  11 + Given I am logged in as admin
  12 + Given I go to /admin/users
  13 +
  14 + @selenium
  15 + Scenario: deactive user
  16 + When I follow "Deactivate user" within "tr[title='Joao Silva']"
  17 + And I confirm the "Do you want to deactivate this user?" dialog
  18 + Then I should see "Activate user" within "tr[title='Joao Silva']"
  19 +
  20 + @selenium
  21 + Scenario: activate user
  22 + Given I follow "Deactivate user" within "tr[title='Paulo Santos']"
  23 + Given I confirm the "Do you want to deactivate this user?" dialog
  24 + When I follow "Activate user" within "tr[title='Paulo Santos']"
  25 + And I confirm the "Do you want to activate this user?" dialog
  26 + Then I should see "Deactivate user" within "tr[title='Paulo Santos']"
  27 +
  28 + @selenium
  29 + Scenario: remove user
  30 + When I follow "Remove" within "tr[title='Joao Silva']"
  31 + And I confirm the "Do you want to remove this user?" dialog
  32 + And I go to /admin/users
  33 + Then I should not see "Joao Silva"
  34 +
  35 + @selenium
  36 + Scenario: admin user
  37 + When I follow "Set admin role" within "tr[title='Joao Silva']"
  38 + And I confirm the "Do you want to set this user as administrator?" dialog
  39 + Then I should see "Reset admin role" within "tr[title='Joao Silva']"
  40 +
  41 + @selenium
  42 + Scenario: unadmin user
  43 + Given I follow "Set admin role" within "tr[title='Paulo Santos']"
  44 + And I confirm the "Do you want to set this user as administrator?" dialog
  45 + When I follow "Reset admin role" within "tr[title='Paulo Santos']"
  46 + And I confirm the "Do you want to reset this user as administrator?" dialog
  47 + Then I should see "Set admin role" within "tr[title='Paulo Santos']"
features/signup.feature
@@ -3,7 +3,7 @@ Feature: signup @@ -3,7 +3,7 @@ Feature: signup
3 I want to sign up to the site 3 I want to sign up to the site
4 So I can have fun using its features 4 So I can have fun using its features
5 5
6 -@selenium 6 + @selenium
7 Scenario: successfull registration 7 Scenario: successfull registration
8 Given I am on the homepage 8 Given I am on the homepage
9 When I follow "Login" 9 When I follow "Login"
@@ -60,3 +60,183 @@ Feature: signup @@ -60,3 +60,183 @@ Feature: signup
60 And I fill in "Name" with "" 60 And I fill in "Name" with ""
61 When I press "Save" 61 When I press "Save"
62 Then I should see "Name can't be blank" 62 Then I should see "Name can't be blank"
  63 +
  64 + @selenium
  65 + Scenario: user should stay on same page after signup
  66 + Given the environment is configured to stay on the same page after signup
  67 + And feature "skip_new_user_email_confirmation" is enabled on environment
  68 + And I am on /search/people
  69 + When I follow "Sign up"
  70 + And I fill in the following within ".no-boxes":
  71 + | e-Mail | josesilva@example.com |
  72 + | Username | josesilva |
  73 + | Password | secret |
  74 + | Password confirmation | secret |
  75 + | Full name | José da Silva |
  76 + And wait for the captcha signup time
  77 + And I press "Create my account"
  78 + Then I should be on /search/people
  79 +
  80 + @selenium
  81 + Scenario: user should go to his homepage after signup
  82 + Given the environment is configured to redirect to profile homepage after signup
  83 + And feature "skip_new_user_email_confirmation" is enabled on environment
  84 + And I am on /search/people
  85 + When I follow "Sign up"
  86 + And I fill in the following within ".no-boxes":
  87 + | e-Mail | josesilva@example.com |
  88 + | Username | josesilva |
  89 + | Password | secret |
  90 + | Password confirmation | secret |
  91 + | Full name | José da Silva |
  92 + And wait for the captcha signup time
  93 + And I press "Create my account"
  94 + Then I should be on josesilva's profile
  95 +
  96 + @selenium
  97 + Scenario: user should go to his control panel after signup
  98 + Given the environment is configured to redirect to profile control panel after signup
  99 + And feature "skip_new_user_email_confirmation" is enabled on environment
  100 + And I am on /search/people
  101 + When I follow "Sign up"
  102 + And I fill in the following within ".no-boxes":
  103 + | e-Mail | josesilva@example.com |
  104 + | Username | josesilva |
  105 + | Password | secret |
  106 + | Password confirmation | secret |
  107 + | Full name | José da Silva |
  108 + And wait for the captcha signup time
  109 + And I press "Create my account"
  110 + Then I should be on josesilva's control panel
  111 +
  112 + @selenium
  113 + Scenario: user should go to his profile page after signup
  114 + Given the environment is configured to redirect to user profile page after signup
  115 + And feature "skip_new_user_email_confirmation" is enabled on environment
  116 + And I am on /search/people
  117 + When I follow "Sign up"
  118 + And I fill in the following within ".no-boxes":
  119 + | e-Mail | josesilva@example.com |
  120 + | Username | josesilva |
  121 + | Password | secret |
  122 + | Password confirmation | secret |
  123 + | Full name | José da Silva |
  124 + And wait for the captcha signup time
  125 + And I press "Create my account"
  126 + Then I should be on josesilva's profile
  127 +
  128 + @selenium
  129 + Scenario: user should go to the environment's homepage after signup
  130 + Given the environment is configured to redirect to site homepage after signup
  131 + And feature "skip_new_user_email_confirmation" is enabled on environment
  132 + And I am on /search/people
  133 + When I follow "Sign up"
  134 + And I fill in the following within ".no-boxes":
  135 + | e-Mail | josesilva@example.com |
  136 + | Username | josesilva |
  137 + | Password | secret |
  138 + | Password confirmation | secret |
  139 + | Full name | José da Silva |
  140 + And wait for the captcha signup time
  141 + And I press "Create my account"
  142 + Then I should be on the homepage
  143 +
  144 + @selenium
  145 + Scenario: user should stay on same page after following confirmation link
  146 + Given the environment is configured to stay on the same page after login
  147 + And feature "skip_new_user_email_confirmation" is disabled on environment
  148 + And I am on /search/people
  149 + When I follow "Sign up"
  150 + And I fill in the following within ".no-boxes":
  151 + | e-Mail | josesilva@example.com |
  152 + | Username | josesilva |
  153 + | Password | secret |
  154 + | Password confirmation | secret |
  155 + | Full name | José da Silva |
  156 + And wait for the captcha signup time
  157 + And I press "Create my account"
  158 + And I go to josesilva's confirmation URL
  159 + And I fill in "Username" with "josesilva"
  160 + And I fill in "Password" with "secret"
  161 + And I press "Log in"
  162 + Then I should be on /search/people
  163 +
  164 + @selenium
  165 + Scenario: user should go to his homepage after following confirmation link
  166 + Given the environment is configured to redirect to profile homepage after login
  167 + And feature "skip_new_user_email_confirmation" is disabled on environment
  168 + And I am on /search/people
  169 + When I follow "Sign up"
  170 + And I fill in the following within ".no-boxes":
  171 + | e-Mail | josesilva@example.com |
  172 + | Username | josesilva |
  173 + | Password | secret |
  174 + | Password confirmation | secret |
  175 + | Full name | José da Silva |
  176 + And wait for the captcha signup time
  177 + And I press "Create my account"
  178 + And I go to josesilva's confirmation URL
  179 + And I fill in "Username" with "josesilva"
  180 + And I fill in "Password" with "secret"
  181 + And I press "Log in"
  182 + Then I should be on /profile/josesilva
  183 +
  184 + @selenium
  185 + Scenario: user should go to his control panel after following confirmation link
  186 + Given the environment is configured to redirect to profile control panel after login
  187 + And feature "skip_new_user_email_confirmation" is disabled on environment
  188 + And I am on /search/people
  189 + When I follow "Sign up"
  190 + And I fill in the following within ".no-boxes":
  191 + | e-Mail | josesilva@example.com |
  192 + | Username | josesilva |
  193 + | Password | secret |
  194 + | Password confirmation | secret |
  195 + | Full name | José da Silva |
  196 + And wait for the captcha signup time
  197 + And I press "Create my account"
  198 + And I go to josesilva's confirmation URL
  199 + And I fill in "Username" with "josesilva"
  200 + And I fill in "Password" with "secret"
  201 + And I press "Log in"
  202 + Then I should be on /myprofile/josesilva
  203 +
  204 + @selenium
  205 + Scenario: user should go to his profile page after following confirmation link
  206 + Given the environment is configured to redirect to user profile page after login
  207 + And feature "skip_new_user_email_confirmation" is disabled on environment
  208 + And I am on /search/people
  209 + When I follow "Sign up"
  210 + And I fill in the following within ".no-boxes":
  211 + | e-Mail | josesilva@example.com |
  212 + | Username | josesilva |
  213 + | Password | secret |
  214 + | Password confirmation | secret |
  215 + | Full name | José da Silva |
  216 + And wait for the captcha signup time
  217 + And I press "Create my account"
  218 + And I go to josesilva's confirmation URL
  219 + And I fill in "Username" with "josesilva"
  220 + And I fill in "Password" with "secret"
  221 + And I press "Log in"
  222 + Then I should be on /profile/josesilva
  223 +
  224 + @selenium
  225 + Scenario: user should go to the environment homepage after following confirmation link
  226 + Given the environment is configured to redirect to site homepage after login
  227 + And feature "skip_new_user_email_confirmation" is disabled on environment
  228 + And I am on /search/people
  229 + When I follow "Sign up"
  230 + And I fill in the following within ".no-boxes":
  231 + | e-Mail | josesilva@example.com |
  232 + | Username | josesilva |
  233 + | Password | secret |
  234 + | Password confirmation | secret |
  235 + | Full name | José da Silva |
  236 + And wait for the captcha signup time
  237 + And I press "Create my account"
  238 + And I go to josesilva's confirmation URL
  239 + And I fill in "Username" with "josesilva"
  240 + And I fill in "Password" with "secret"
  241 + And I press "Log in"
  242 + Then I should be on the homepage
features/step_definitions/noosfero_steps.rb
@@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option @@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option
738 profile.save 738 profile.save
739 end 739 end
740 740
  741 +Given /^the environment is configured to (.*) after signup$/ do |option|
  742 + redirection = case option
  743 + when 'stay on the same page'
  744 + 'keep_on_same_page'
  745 + when 'redirect to site homepage'
  746 + 'site_homepage'
  747 + when 'redirect to user profile page'
  748 + 'user_profile_page'
  749 + when 'redirect to profile homepage'
  750 + 'user_homepage'
  751 + when 'redirect to profile control panel'
  752 + 'user_control_panel'
  753 + end
  754 + environment = Environment.default
  755 + environment.redirection_after_signup = redirection
  756 + environment.save
  757 +end
  758 +
741 When /^wait for the captcha signup time$/ do 759 When /^wait for the captcha signup time$/ do
742 environment = Environment.default 760 environment = Environment.default
743 sleep environment.min_signup_delay + 1 761 sleep environment.min_signup_delay + 1
features/support/paths.rb
@@ -111,6 +111,10 @@ module NavigationHelpers @@ -111,6 +111,10 @@ module NavigationHelpers
111 when /the user data path/ 111 when /the user data path/
112 '/account/user_data' 112 '/account/user_data'
113 113
  114 + when /^(.+)'s confirmation URL/
  115 + user = User[$1]
  116 + "/account/activate?activation_code=#{user.activation_code}&redirection=" + (user.return_to.nil? ? 'false' : 'true')
  117 +
114 when /^(.+)'s members page/ 118 when /^(.+)'s members page/
115 '/profile/%s/members' % profile_identifier($1) 119 '/profile/%s/members' % profile_identifier($1)
116 120
lib/activities_counter_cache_job.rb 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +class ActivitiesCounterCacheJob
  2 + def perform
  3 + person_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= '#{ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db)}') AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")
  4 + organization_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= '#{ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db)}') AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;")
  5 + activities_counts = person_activities_counts.entries + organization_activities_counts.entries
  6 + activities_counts.each do |count|
  7 + ActiveRecord::Base.connection.execute("UPDATE profiles SET activities_count=#{count['count'].to_i} WHERE profiles.id=#{count['id']};")
  8 + end
  9 + Delayed::Job.enqueue(ActivitiesCounterCacheJob.new, -3, 1.day.from_now)
  10 + end
  11 +end
lib/acts_as_having_settings.rb
@@ -14,6 +14,17 @@ module ActsAsHavingSettings @@ -14,6 +14,17 @@ module ActsAsHavingSettings
14 def #{settings_field} 14 def #{settings_field}
15 self[:#{settings_field}] ||= Hash.new 15 self[:#{settings_field}] ||= Hash.new
16 end 16 end
  17 +
  18 + def setting_changed?(setting_field)
  19 + setting_field = setting_field.to_sym
  20 + changed_settings = self.changes['#{settings_field}']
  21 + return false if changed_settings.nil?
  22 +
  23 + old_setting_value = changed_settings.first.nil? ? nil : changed_settings.first[setting_field]
  24 + new_setting_value = changed_settings.last[setting_field]
  25 + old_setting_value != new_setting_value
  26 + end
  27 +
17 before_save :symbolize_settings_keys 28 before_save :symbolize_settings_keys
18 private 29 private
19 def symbolize_settings_keys 30 def symbolize_settings_keys
@@ -36,11 +47,9 @@ module ActsAsHavingSettings @@ -36,11 +47,9 @@ module ActsAsHavingSettings
36 val.nil? ? (#{default}.is_a?(String) ? gettext(#{default}) : #{default}) : val 47 val.nil? ? (#{default}.is_a?(String) ? gettext(#{default}) : #{default}) : val
37 end 48 end
38 def #{setting}=(value) 49 def #{setting}=(value)
39 -  
40 - #UPGRADE Leandro: I add this line to save the serialize attribute  
41 - send(self.class.settings_field.to_s + '_will_change!')  
42 -  
43 - send(self.class.settings_field)[:#{setting}] = self.class.acts_as_having_settings_type_cast(value, #{data_type.inspect}) 50 + h = send(self.class.settings_field).clone
  51 + h[:#{setting}] = self.class.acts_as_having_settings_type_cast(value, #{data_type.inspect})
  52 + send(self.class.settings_field.to_s + '=', h)
44 end 53 end
45 CODE 54 CODE
46 end 55 end