Commit db1b3a639ac8debebdc50b45b40ce746abbd05b3
Exists in
staging
and in
42 other branches
Merge branch 'master' into debian6
Conflicts: lib/noosfero.rb
Showing
13 changed files
with
70 additions
and
23 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -197,6 +197,7 @@ class CmsController < MyProfileController |
| 197 | 197 | @article = profile.articles.find(params[:id]) |
| 198 | 198 | if request.post? |
| 199 | 199 | @article.destroy |
| 200 | + session[:notice] = _("\"#{@article.name}\" was removed.") | |
| 200 | 201 | redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent |
| 201 | 202 | end |
| 202 | 203 | end | ... | ... |
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -111,7 +111,7 @@ class ContentViewerController < ApplicationController |
| 111 | 111 | def add_comment |
| 112 | 112 | @comment.author = user if logged_in? |
| 113 | 113 | @comment.article = @page |
| 114 | - if (logged_in? || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save | |
| 114 | + if (pass_without_comment_captcha? || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save | |
| 115 | 115 | @page.touch |
| 116 | 116 | @comment = nil # clear the comment form |
| 117 | 117 | redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] |
| ... | ... | @@ -120,6 +120,11 @@ class ContentViewerController < ApplicationController |
| 120 | 120 | end |
| 121 | 121 | end |
| 122 | 122 | |
| 123 | + def pass_without_comment_captcha? | |
| 124 | + logged_in? && !environment.enabled?('captcha_for_logged_users') | |
| 125 | + end | |
| 126 | + helper_method :pass_without_comment_captcha? | |
| 127 | + | |
| 123 | 128 | def remove_comment |
| 124 | 129 | @comment = @page.comments.find(params[:remove_comment]) |
| 125 | 130 | if (user == @comment.author || user == @page.profile || user.has_permission?(:moderate_comments, @page.profile)) | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -1330,4 +1330,11 @@ module ApplicationHelper |
| 1330 | 1330 | end |
| 1331 | 1331 | end |
| 1332 | 1332 | |
| 1333 | + def delete_article_message(article) | |
| 1334 | + if article.folder? | |
| 1335 | + _("Are you sure that you want to remove the folder \"#{article.name}\"? Note that all the items inside it will also be removed!") | |
| 1336 | + else | |
| 1337 | + _("Are you sure that you want to remove the item \"#{article.name}\"?") | |
| 1338 | + end | |
| 1339 | + end | |
| 1333 | 1340 | end | ... | ... |
app/helpers/cms_helper.rb
| ... | ... | @@ -49,12 +49,6 @@ module CmsHelper |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | def display_delete_button(article) |
| 52 | - confirm_message = if article.folder? | |
| 53 | - _('Are you sure that you want to remove this folder? Note that all the items inside it will also be removed!') | |
| 54 | - else | |
| 55 | - _('Are you sure that you want to remove this item?') | |
| 56 | - end | |
| 57 | - | |
| 58 | - button_without_text :delete, _('Delete'), { :action => 'destroy', :id => article.id }, :method => :post, :confirm => confirm_message | |
| 52 | + button_without_text :delete, _('Delete'), { :action => 'destroy', :id => article.id }, :method => :post, :confirm => delete_article_message(article) | |
| 59 | 53 | end |
| 60 | 54 | end | ... | ... |
app/models/environment.rb
| ... | ... | @@ -120,7 +120,8 @@ class Environment < ActiveRecord::Base |
| 120 | 120 | 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'), |
| 121 | 121 | 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), |
| 122 | 122 | 'xmpp_chat' => _('XMPP/Jabber based chat'), |
| 123 | - 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images') | |
| 123 | + 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), | |
| 124 | + 'captcha_for_logged_users' => _('Ask captcha when a logged user comments too'), | |
| 124 | 125 | } |
| 125 | 126 | end |
| 126 | 127 | ... | ... |
app/views/content_viewer/_article_toolbar.rhtml
| ... | ... | @@ -8,8 +8,10 @@ |
| 8 | 8 | <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %> |
| 9 | 9 | <% if @page != profile.home_page && !@page.has_posts? %> |
| 10 | 10 | <%= link_to content_tag( 'span', _('Delete') ), |
| 11 | - profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page }), | |
| 12 | - :class => 'button with-text icon-delete' %> | |
| 11 | + profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page}), | |
| 12 | + :method => :post, | |
| 13 | + :class => 'button with-text icon-delete', | |
| 14 | + :confirm => delete_article_message(@page) %> | |
| 13 | 15 | <% end %> |
| 14 | 16 | <% if !environment.enabled?('disable_cms') && !@page.folder? %> |
| 15 | 17 | <% if profile.kind_of?(Person) %> | ... | ... |
app/views/content_viewer/_comment_form.rhtml
| 1 | 1 | <script type="text/javascript"> |
| 2 | 2 | function submit_comment_form(button) { |
| 3 | - <% if logged_in? %> | |
| 3 | + <% if pass_without_comment_captcha? %> | |
| 4 | 4 | button.form.confirm.value = 'true'; |
| 5 | 5 | button.disabled = true; |
| 6 | 6 | button.form.submit(); |
| ... | ... | @@ -42,7 +42,7 @@ function submit_comment_form(button) { |
| 42 | 42 | <%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %> |
| 43 | 43 | </h4> |
| 44 | 44 | |
| 45 | -<% unless logged_in? %> | |
| 45 | +<% unless pass_without_comment_captcha? %> | |
| 46 | 46 | <div id="recaptcha-container" style="display: none"> |
| 47 | 47 | <h3><%= _('Please type the two words below') %></h3> |
| 48 | 48 | <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> |
| ... | ... | @@ -72,9 +72,11 @@ function submit_comment_form(button) { |
| 72 | 72 | <%= _('If you are a registered user, you can login and be automatically recognized.') %> |
| 73 | 73 | </p> |
| 74 | 74 | |
| 75 | + <% end %> | |
| 76 | + | |
| 77 | + <% unless pass_without_comment_captcha? %> | |
| 75 | 78 | <%= hidden_field_tag(:recaptcha_response_field, nil, :id => nil) %> |
| 76 | 79 | <%= hidden_field_tag(:recaptcha_challenge_field, nil, :id => nil) %> |
| 77 | - | |
| 78 | 80 | <% end %> |
| 79 | 81 | |
| 80 | 82 | <%= labelled_form_field(_('Title'), text_field(:comment, :title)) %> | ... | ... |
debian/changelog
| ... | ... | @@ -9,6 +9,12 @@ noosfero (0.36.0~3) unstable; urgency=low |
| 9 | 9 | |
| 10 | 10 | -- Antonio Terceiro <terceiro@colivre.coop.br> Sun, 27 Nov 2011 14:11:33 -0200 |
| 11 | 11 | |
| 12 | +noosfero (0.35.1) unstable; urgency=low | |
| 13 | + | |
| 14 | + * Bugfixes version release | |
| 15 | + | |
| 16 | + -- Daniela Soares Feitosa <daniela@colivre.coop.br> Wed, 15 Feb 2012 17:17:48 -0200 | |
| 17 | + | |
| 12 | 18 | noosfero (0.35.0) unstable; urgency=low |
| 13 | 19 | |
| 14 | 20 | * Features version release | ... | ... |
lib/noosfero.rb
plugins/google_analytics/lib/google_analytics_plugin.rb
test/functional/cms_controller_test.rb
| ... | ... | @@ -874,9 +874,8 @@ class CmsControllerTest < ActionController::TestCase |
| 874 | 874 | |
| 875 | 875 | should 'offer confirmation to remove article' do |
| 876 | 876 | a = profile.articles.create!(:name => 'my-article') |
| 877 | - get :destroy, :profile => profile.identifier, :id => a.id | |
| 878 | - assert_response :success | |
| 879 | - assert_tag :tag => 'input', :attributes => {:type => 'submit', :value => 'Yes, I want.' } | |
| 877 | + post :destroy, :profile => profile.identifier, :id => a.id | |
| 878 | + assert_response :redirect | |
| 880 | 879 | end |
| 881 | 880 | |
| 882 | 881 | should 'display notify comments option' do | ... | ... |
test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -1334,4 +1334,32 @@ class ContentViewerControllerTest < ActionController::TestCase |
| 1334 | 1334 | assert_no_tag :tag => 'body', :attributes => { :class => /profile-homepage/ } |
| 1335 | 1335 | end |
| 1336 | 1336 | |
| 1337 | + should 'ask for captcha if user not logged' do | |
| 1338 | + article = profile.articles.build(:name => 'test') | |
| 1339 | + article.save! | |
| 1340 | + | |
| 1341 | + @controller.stubs(:verify_recaptcha).returns(false) | |
| 1342 | + post :view_page, :profile => profile.identifier, :page => ['test'], :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' | |
| 1343 | + assert_not_nil assigns(:comment) | |
| 1344 | + | |
| 1345 | + @controller.stubs(:verify_recaptcha).returns(true) | |
| 1346 | + post :view_page, :profile => profile.identifier, :page => ['test'], :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' | |
| 1347 | + assert_nil assigns(:comment) | |
| 1348 | + end | |
| 1349 | + | |
| 1350 | + should 'ask for captcha if environment defines even with logged user' do | |
| 1351 | + article = profile.articles.build(:name => 'test') | |
| 1352 | + article.save! | |
| 1353 | + login_as('testinguser') | |
| 1354 | + @controller.stubs(:verify_recaptcha).returns(false) | |
| 1355 | + | |
| 1356 | + post :view_page, :profile => profile.identifier, :page => ['test'], :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' | |
| 1357 | + assert_nil assigns(:comment) | |
| 1358 | + | |
| 1359 | + environment.enable('captcha_for_logged_users') | |
| 1360 | + environment.save! | |
| 1361 | + | |
| 1362 | + post :view_page, :profile => profile.identifier, :page => ['test'], :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' | |
| 1363 | + assert_not_nil assigns(:comment) | |
| 1364 | + end | |
| 1337 | 1365 | end | ... | ... |
test/unit/cms_helper_test.rb
| ... | ... | @@ -82,8 +82,9 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 82 | 82 | |
| 83 | 83 | should 'display delete_button to folder' do |
| 84 | 84 | profile = fast_create(Profile) |
| 85 | - folder = fast_create(Folder, :name => 'My folder', :profile_id => profile.id) | |
| 86 | - confirm_message = 'Are you sure that you want to remove this folder? Note that all the items inside it will also be removed!' | |
| 85 | + name = 'My folder' | |
| 86 | + folder = fast_create(Folder, :name => name, :profile_id => profile.id) | |
| 87 | + confirm_message = "Are you sure that you want to remove the folder \"#{name}\"? Note that all the items inside it will also be removed!" | |
| 87 | 88 | expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message) |
| 88 | 89 | |
| 89 | 90 | result = display_delete_button(folder) |
| ... | ... | @@ -91,8 +92,9 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 91 | 92 | |
| 92 | 93 | should 'display delete_button to article' do |
| 93 | 94 | profile = fast_create(Profile) |
| 94 | - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) | |
| 95 | - confirm_message = 'Are you sure that you want to remove this item?' | |
| 95 | + name = 'My article' | |
| 96 | + article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) | |
| 97 | + confirm_message = "Are you sure that you want to remove the item \"#{name}\"?" | |
| 96 | 98 | expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message) |
| 97 | 99 | |
| 98 | 100 | result = display_delete_button(article) | ... | ... |