Commit 1a2ee0964c7fb35920d7036c389cdcf882254328

Authored by Rodrigo Souto
1 parent 095aedda

Adding hostpot for extra content on profile basic info

app/views/profile_editor/_organization.rhtml
@@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
4 4
5 <%= required f.text_field(:name) %> 5 <%= required f.text_field(:name) %>
6 6
  7 + <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %>
  8 +
7 <% if @environment.enabled?('enable_organization_url_change') %> 9 <% if @environment.enabled?('enable_organization_url_change') %>
8 <script type="text/javascript"> 10 <script type="text/javascript">
9 function updateUrlField(name_field, id) { 11 function updateUrlField(name_field, id) {
app/views/profile_editor/_person.rhtml
@@ -6,4 +6,6 @@ @@ -6,4 +6,6 @@
6 6
7 <%= required f.text_field(:email) %> 7 <%= required f.text_field(:email) %>
8 8
  9 + <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %>
  10 +
9 <%= render :partial => 'person_form', :locals => {:f => f} %> 11 <%= render :partial => 'person_form', :locals => {:f => f} %>
lib/noosfero/plugin.rb
@@ -244,6 +244,12 @@ class Noosfero::Plugin @@ -244,6 +244,12 @@ class Noosfero::Plugin
244 nil 244 nil
245 end 245 end
246 246
  247 + # -> Adds adicional content to profile info
  248 + # returns = lambda block that creates a html code
  249 + def profile_info_extra_contents
  250 + nil
  251 + end
  252 +
247 # -> Removes the invite friend button from the friends controller 253 # -> Removes the invite friend button from the friends controller
248 # returns = boolean 254 # returns = boolean
249 def remove_invite_friends_button 255 def remove_invite_friends_button
test/functional/profile_editor_controller_test.rb
@@ -916,4 +916,47 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -916,4 +916,47 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
916 assert_tag :tag => 'div', :attributes => { :id => 'profile_change_picture' } 916 assert_tag :tag => 'div', :attributes => { :id => 'profile_change_picture' }
917 end 917 end
918 918
  919 + should 'add extra content on person info from plugins' do
  920 + class Plugin1 < Noosfero::Plugin
  921 + def profile_info_extra_contents
  922 + lambda {"<strong>Plugin1 text</strong>"}
  923 + end
  924 + end
  925 + class Plugin2 < Noosfero::Plugin
  926 + def profile_info_extra_contents
  927 + lambda {"<strong>Plugin2 text</strong>"}
  928 + end
  929 + end
  930 +
  931 + Environment.default.enable_plugin(Plugin1)
  932 + Environment.default.enable_plugin(Plugin2)
  933 +
  934 + get :edit, :profile => profile.identifier
  935 +
  936 + assert_tag :tag => 'strong', :content => 'Plugin1 text'
  937 + assert_tag :tag => 'strong', :content => 'Plugin2 text'
  938 + end
  939 +
  940 + should 'add extra content on organization info from plugins' do
  941 + class Plugin1 < Noosfero::Plugin
  942 + def profile_info_extra_contents
  943 + lambda {"<strong>Plugin1 text</strong>"}
  944 + end
  945 + end
  946 + class Plugin2 < Noosfero::Plugin
  947 + def profile_info_extra_contents
  948 + lambda {"<strong>Plugin2 text</strong>"}
  949 + end
  950 + end
  951 +
  952 + Environment.default.enable_plugin(Plugin1)
  953 + Environment.default.enable_plugin(Plugin2)
  954 + organization = fast_create(Community)
  955 +
  956 + get :edit, :profile => organization.identifier
  957 +
  958 + assert_tag :tag => 'strong', :content => 'Plugin1 text'
  959 + assert_tag :tag => 'strong', :content => 'Plugin2 text'
  960 + end
  961 +
919 end 962 end