Commit 1a2ee0964c7fb35920d7036c389cdcf882254328
1 parent
095aedda
Exists in
master
and in
28 other branches
Adding hostpot for extra content on profile basic info
Showing
4 changed files
with
53 additions
and
0 deletions
Show diff stats
app/views/profile_editor/_organization.rhtml
... | ... | @@ -4,6 +4,8 @@ |
4 | 4 | |
5 | 5 | <%= required f.text_field(:name) %> |
6 | 6 | |
7 | + <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %> | |
8 | + | |
7 | 9 | <% if @environment.enabled?('enable_organization_url_change') %> |
8 | 10 | <script type="text/javascript"> |
9 | 11 | function updateUrlField(name_field, id) { | ... | ... |
app/views/profile_editor/_person.rhtml
lib/noosfero/plugin.rb
... | ... | @@ -244,6 +244,12 @@ class Noosfero::Plugin |
244 | 244 | nil |
245 | 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 | 253 | # -> Removes the invite friend button from the friends controller |
248 | 254 | # returns = boolean |
249 | 255 | def remove_invite_friends_button | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -916,4 +916,47 @@ class ProfileEditorControllerTest < ActionController::TestCase |
916 | 916 | assert_tag :tag => 'div', :attributes => { :id => 'profile_change_picture' } |
917 | 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 | 962 | end | ... | ... |