Commit 4e1edc60fc096ac60603086a84f7290d8131f341

Authored by Rodrigo Souto
2 parents 5aecb772 38b450a5

Merge branch 'stable'

app/controllers/public/content_viewer_controller.rb
... ... @@ -25,24 +25,26 @@ class ContentViewerController < ApplicationController
25 25 return
26 26 end
27 27 end
28   -
29   - # page not found, give error
30   - if @page.nil?
31   - render_not_found(@path)
32   - return
33   - end
34 28 end
35 29  
36   - if !@page.display_to?(user)
37   - if profile.display_info_to?(user) || !profile.visible?
38   - message = _('You are not allowed to view this content. You can contact the owner of this profile to request access then.')
  30 + if !@page.nil? && !@page.display_to?(user)
  31 + if !profile.public?
  32 + private_profile_partial_parameters
  33 + render :template => 'profile/_private_profile.rhtml', :status => 403
  34 + else #if !profile.visible?
  35 + message = _('You are not allowed to view this content.')
  36 + message += ' ' + _('You can contact the owner of this profile to request access then.')
39 37 render_access_denied(message)
40   - elsif !profile.public?
41   - redirect_to :controller => 'profile', :action => 'index', :profile => profile.identifier
42 38 end
43 39 return
44 40 end
45 41  
  42 + # page not found, give error
  43 + if @page.nil?
  44 + render_not_found(@path)
  45 + return
  46 + end
  47 +
46 48 if request.xhr? && params[:toolbar]
47 49 render :partial => 'article_toolbar'
48 50 return
... ...
app/controllers/public/profile_controller.rb
... ... @@ -368,14 +368,7 @@ class ProfileController < PublicController
368 368 end
369 369  
370 370 def private_profile
371   - if profile.person?
372   - @action = :add_friend
373   - @message = _("The content here is available to %s's friends only.") % profile.short_name
374   - else
375   - @action = :join
376   - @message = _('The contents in this community is available to members only.')
377   - end
378   - @no_design_blocks = true
  371 + private_profile_partial_parameters
379 372 end
380 373  
381 374 def invisible_profile
... ...
app/helpers/application_helper.rb
... ... @@ -1411,4 +1411,16 @@ module ApplicationHelper
1411 1411 options[:class] = "comment-footer comment-footer-link comment-footer-hide"
1412 1412 expirable_content_reference content, action, text, url, options
1413 1413 end
  1414 +
  1415 + def private_profile_partial_parameters
  1416 + if profile.person?
  1417 + @action = :add_friend
  1418 + @message = _("The content here is available to %s's friends only.") % profile.short_name
  1419 + else
  1420 + @action = :join
  1421 + @message = _('The contents in this community is available to members only.')
  1422 + end
  1423 + @no_design_blocks = true
  1424 + end
  1425 +
1414 1426 end
... ...
app/views/search/_product.rhtml
1   -<% extra_content = @plugins.dispatch(:asset_product_extras, product, product.enterprise).collect { |content| instance_eval(&content) } %>
  1 +<% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_eval(&content) } %>
2 2 <% extra_properties = @plugins.dispatch(:asset_product_properties, product)%>
3 3  
4 4 <li class="search-product-item <%= 'highlighted' if product.highlighted? %>">
... ...
debian/changelog
  1 +noosfero (0.39.3) unstable; urgency=low
  2 +
  3 + * Bugfixes release
  4 +
  5 + -- Rodrigo Souto <rodrigo@colivre.coop.br> Sat, 19 Jan 2013 19:27:04 +0000
  6 +
1 7 noosfero (0.39.2) unstable; urgency=low
2 8  
3 9 * Bugfixes release
... ...
lib/noosfero.rb
... ... @@ -2,7 +2,7 @@ require &#39;fast_gettext&#39;
2 2  
3 3 module Noosfero
4 4 PROJECT = 'noosfero'
5   - VERSION = '0.39.2'
  5 + VERSION = '0.39.3'
6 6  
7 7 def self.pattern_for_controllers_in_directory(dir)
8 8 disjunction = controllers_in_directory(dir).join('|')
... ...
lib/noosfero/plugin.rb
... ... @@ -161,7 +161,7 @@ class Noosfero::Plugin
161 161  
162 162 # -> Adds content to products on asset list
163 163 # returns = lambda block that creates html code
164   - def asset_product_extras(product, enterprise)
  164 + def asset_product_extras(product)
165 165 nil
166 166 end
167 167  
... ...
plugins/spaminator/lib/spaminator_plugin/scan.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +class SpaminatorPlugin::Scan
  2 + def self.run(environment_id)
  3 + environment = Environment.find(environment_id)
  4 + settings = Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin)
  5 + settings.scanning = true
  6 + settings.save!
  7 +
  8 + begin
  9 + SpaminatorPlugin::Spaminator.run(environment)
  10 + rescue Exception => exception
  11 + SpaminatorPlugin::Spaminator.log("Spaminator failed with the following error: \n ==> #{exception}\n#{exception.backtrace.join("\n")}")
  12 + end
  13 +
  14 + settings.scanning = false
  15 + SpaminatorPlugin.schedule_scan(environment) if settings.deployed
  16 + settings.save!
  17 + end
  18 +end
... ...
plugins/spaminator/lib/spaminator_plugin/scan_job.rb
1 1 class SpaminatorPlugin::ScanJob < Struct.new(:environment_id)
2 2 def perform
3   - fork do
4   - environment = Environment.find(environment_id)
5   - settings = Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin)
6   - settings.scanning = true
7   - settings.save!
8   -
9   - begin
10   - SpaminatorPlugin::Spaminator.run(environment)
11   - rescue Exception => exception
12   - SpaminatorPlugin::Spaminator.log("Spaminator failed with the following error: \n ==> #{exception}\n#{exception.backtrace.join("\n")}")
13   - end
14   -
15   - settings.scanning = false
16   - SpaminatorPlugin.schedule_scan(environment) if settings.deployed
17   - settings.save!
18   - end
  3 + fork {system("ruby #{File.join(SpaminatorPlugin.root_path, 'script', 'scan')} #{environment_id}") }
19 4 end
20 5 end
... ...
plugins/spaminator/script/scan 0 → 100755
... ... @@ -0,0 +1,4 @@
  1 +#!/usr/bin/env ruby
  2 +
  3 +require File.dirname(__FILE__) + '/../../../config/environment'
  4 +SpaminatorPlugin::Scan.run(ARGV[0])
... ...
plugins/stoa/lib/stoa_plugin.rb
... ... @@ -107,14 +107,14 @@ class StoaPlugin &lt; Noosfero::Plugin
107 107 def invite_controller_filters
108 108 [{ :type => 'before_filter',
109 109 :method_name => 'check_usp_id_existence',
110   - :block => lambda {render_access_denied if profile.usp_id.blank?} }]
  110 + :block => lambda {render_access_denied if !user || user.usp_id.blank?} }]
111 111 end
112 112  
113 113 def control_panel_buttons
114 114 { :title => _('Invite friends'),
115 115 :icon => 'invite-friends',
116 116 :url => {:controller => 'invite',
117   - :action => 'select_address_book'} } if !context.profile.usp_id.blank?
  117 + :action => 'select_address_book'} } if context.send(:user) && context.send(:user).usp_id.present?
118 118 end
119 119  
120 120 def remove_invite_friends_button
... ...
plugins/stoa/test/functional/invite_controller_test.rb
... ... @@ -36,5 +36,17 @@ class InviteControllerTest &lt; ActionController::TestCase
36 36 assert_response 200
37 37 end
38 38  
  39 + should 'alow invitation even in organizations' do
  40 + person_with_usp_id = User.create!(:login => 'user-with', :email => 'user-with@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 12345678}).person
  41 + organization = fast_create(Organization)
  42 + organization.add_admin(person_with_usp_id)
  43 +
  44 + login_as(person_with_usp_id.identifier)
  45 + get :select_address_book, :profile => organization.identifier
  46 + assert_response 200
  47 + get :select_friends, :profile => organization.identifier, :contact_list => ContactList.create.id
  48 + assert_response 200
  49 + end
  50 +
39 51 end
40 52  
... ...
plugins/stoa/test/unit/stoa_plugin_test.rb 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +
  3 +class StoaPluginTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @plugin = StoaPlugin.new
  7 + end
  8 +
  9 + attr_reader :plugin
  10 +
  11 + should 'display invite control panel button only to users with usp_id' do
  12 + person_with_usp_id = fast_create(Person, :usp_id => 99999999)
  13 + person_without_usp_id = fast_create(Person)
  14 + context = mock()
  15 + StoaPlugin.any_instance.stubs(:context).returns(context)
  16 +
  17 + context.stubs(:user).returns(nil)
  18 + assert_nil plugin.control_panel_buttons
  19 +
  20 + context.stubs(:user).returns(person_without_usp_id)
  21 + assert_nil plugin.control_panel_buttons
  22 +
  23 + context.stubs(:user).returns(person_with_usp_id)
  24 + assert_not_nil plugin.control_panel_buttons
  25 + end
  26 +end
  27 +
... ...
test/functional/search_controller_test.rb
... ... @@ -227,13 +227,13 @@ class SearchControllerTest &lt; ActionController::TestCase
227 227  
228 228 should 'include extra content supplied by plugins on product asset' do
229 229 class Plugin1 < Noosfero::Plugin
230   - def asset_product_extras(product, enterprise)
  230 + def asset_product_extras(product)
231 231 lambda {"<span id='plugin1'>This is Plugin1 speaking!</span>"}
232 232 end
233 233 end
234 234  
235 235 class Plugin2 < Noosfero::Plugin
236   - def asset_product_extras(product, enterprise)
  236 + def asset_product_extras(product)
237 237 lambda {"<span id='plugin2'>This is Plugin2 speaking!</span>"}
238 238 end
239 239 end
... ...
vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb
... ... @@ -235,11 +235,15 @@ module ActsAsSolr #:nodoc:
235 235 iteration_start = Time.now
236 236  
237 237 iteration_items, iteration_add_batch = queue.pop(true)
238   - if options[:delayed_job]
239   - delay.solr_add iteration_add_batch
240   - else
241   - solr_add iteration_add_batch
242   - solr_commit
  238 + begin
  239 + if options[:delayed_job]
  240 + delay.solr_add iteration_add_batch
  241 + else
  242 + solr_add iteration_add_batch
  243 + solr_commit
  244 + end
  245 + rescue Exception => exception
  246 + logger.error(exception.to_s)
243 247 end
244 248  
245 249 last_id = iteration_items.last.id
... ...