Commit 90eebff2ed28191e0e443b896040b2f2d5bc932e

Authored by Daniela Feitosa
2 parents a56214cf 988453ca

Merge branch 'stable'

Conflicts:
	debian/changelog
	lib/noosfero.rb
	lib/noosfero/plugin.rb
app/controllers/public/account_controller.rb
@@ -224,6 +224,8 @@ class AccountController < ApplicationController @@ -224,6 +224,8 @@ class AccountController < ApplicationController
224 session[:notice] = nil # consume the notice 224 session[:notice] = nil # consume the notice
225 end 225 end
226 226
  227 + @plugins.enabled_plugins.each { |plugin| user_data.merge!(plugin.user_data_extras) }
  228 +
227 render :text => user_data.to_json, :layout => false, :content_type => "application/javascript" 229 render :text => user_data.to_json, :layout => false, :content_type => "application/javascript"
228 end 230 end
229 231
debian/changelog
  1 +noosfero (0.31.5) unstable; urgency=low
  2 +
  3 + * Bugfix version release
  4 +
  5 + -- Daniela Soares Feitosa <daniela@colivre.coop.br> Mon, 15 Aug 2011 18:20:13 -0300
  6 +
1 noosfero (0.31.4) unstable; urgency=low 7 noosfero (0.31.4) unstable; urgency=low
2 8
3 * Bugfix Version release 9 * Bugfix Version release
4 10
5 -- Rodrigo Souto <rodrigo@colivre.coop.br> Fri, 15 Jul 2011 16:40:05 -0300 11 -- Rodrigo Souto <rodrigo@colivre.coop.br> Fri, 15 Jul 2011 16:40:05 -0300
6 12
  13 +
7 noosfero (0.31.3) unstable; urgency=low 14 noosfero (0.31.3) unstable; urgency=low
8 15
9 * Bugfix Version release. 16 * Bugfix Version release.
lib/noosfero.rb
1 module Noosfero 1 module Noosfero
2 PROJECT = 'noosfero' 2 PROJECT = 'noosfero'
3 - VERSION = '0.31.4' 3 + VERSION = '0.31.5'
4 4
5 def self.pattern_for_controllers_in_directory(dir) 5 def self.pattern_for_controllers_in_directory(dir)
6 disjunction = controllers_in_directory(dir).join('|') 6 disjunction = controllers_in_directory(dir).join('|')
lib/noosfero/plugin.rb
@@ -128,6 +128,12 @@ class Noosfero::Plugin @@ -128,6 +128,12 @@ class Noosfero::Plugin
128 [] 128 []
129 end 129 end
130 130
  131 + # -> Adds stuff in user data hash
  132 + # returns = { :some_data => some_value, :another_data => another_value }
  133 + def user_data_extras
  134 + {}
  135 + end
  136 +
131 # -> Parse and possibly make changes of content (article, block, etc) during HTML rendering 137 # -> Parse and possibly make changes of content (article, block, etc) during HTML rendering
132 # returns = content as string after parser and changes 138 # returns = content as string after parser and changes
133 def parse_content(raw_content) 139 def parse_content(raw_content)
public/javascripts/application.js
@@ -475,6 +475,8 @@ jQuery(function($) { @@ -475,6 +475,8 @@ jQuery(function($) {
475 if (data.notice) { 475 if (data.notice) {
476 display_notice(data.notice); 476 display_notice(data.notice);
477 } 477 }
  478 + // Bind this event to do more actions with the user data (for example, inside plugins)
  479 + $(window).trigger("userDataLoaded", data);
478 }); 480 });
479 481
480 function loggedInDataCallBack(data) { 482 function loggedInDataCallBack(data) {
test/functional/account_controller_test.rb
@@ -670,6 +670,25 @@ class AccountControllerTest &lt; Test::Unit::TestCase @@ -670,6 +670,25 @@ class AccountControllerTest &lt; Test::Unit::TestCase
670 assert_equal 'unavailable', assigns(:status_class) 670 assert_equal 'unavailable', assigns(:status_class)
671 end 671 end
672 672
  673 + should 'merge user data with extra stuff from plugins' do
  674 + plugin1 = mock()
  675 + plugin1.stubs(:user_data_extras).returns({ :foo => 'bar' })
  676 +
  677 + plugin2 = mock()
  678 + plugin2.stubs(:user_data_extras).returns({ :test => 5 })
  679 +
  680 + enabled_plugins = [plugin1, plugin2]
  681 +
  682 + plugins = mock()
  683 + plugins.stubs(:enabled_plugins).returns(enabled_plugins)
  684 + Noosfero::Plugin::Manager.stubs(:new).returns(plugins)
  685 +
  686 + login_as 'ze'
  687 +
  688 + xhr :get, :user_data
  689 + assert_equal User.find_by_login('ze').data_hash.merge({ 'foo' => 'bar', 'test' => 5 }), ActiveSupport::JSON.decode(@response.body)
  690 + end
  691 +
673 protected 692 protected
674 def new_user(options = {}, extra_options ={}) 693 def new_user(options = {}, extra_options ={})
675 data = {:profile_data => person_data} 694 data = {:profile_data => person_data}