Commit 958192ff3f1d007be26b33f6ac159f63307b0c4c
Exists in
master
and in
28 other branches
Merge branch 'ai3123' of https://gitlab.com/brauliobo/noosfero into brauliobo/noosfero-ai3123
Showing
13 changed files
with
54 additions
and
69 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -313,15 +313,9 @@ module ApplicationHelper | @@ -313,15 +313,9 @@ module ApplicationHelper | ||
313 | raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?' | 313 | raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?' |
314 | end | 314 | end |
315 | 315 | ||
316 | - def view_for_profile_actions(klass) | ||
317 | - raise ArgumentError, 'No profile actions view for this class.' if klass.nil? | ||
318 | - | ||
319 | - name = klass.name.underscore | ||
320 | - VIEW_EXTENSIONS.each do |ext| | ||
321 | - return "blocks/profile_info_actions/"+name+ext if File.exists?(File.join(RAILS_ROOT, 'app', 'views', 'blocks', 'profile_info_actions', name+ext)) | ||
322 | - end | ||
323 | - | ||
324 | - view_for_profile_actions(klass.superclass) | 316 | + def render_profile_actions klass |
317 | + name = klass.to_s.underscore | ||
318 | + render "blocks/profile_info_actions/#{name}" rescue render_profile_actions klass.superclass | ||
325 | end | 319 | end |
326 | 320 | ||
327 | def user | 321 | def user |
app/views/blocks/my_network.rhtml
@@ -11,5 +11,5 @@ | @@ -11,5 +11,5 @@ | ||
11 | </ul> | 11 | </ul> |
12 | 12 | ||
13 | <div class="my-network-actions"> | 13 | <div class="my-network-actions"> |
14 | - <%= render :file => 'blocks/profile_info_actions/' + owner.class.name.underscore %> | 14 | + <%= render_profile_actions owner.class.name.underscore %> |
15 | </div> | 15 | </div> |
app/views/blocks/profile_image.rhtml
@@ -23,6 +23,6 @@ | @@ -23,6 +23,6 @@ | ||
23 | <% end %> | 23 | <% end %> |
24 | 24 | ||
25 | <div class="profile-info-options"> | 25 | <div class="profile-info-options"> |
26 | - <%= render :file => view_for_profile_actions(block.owner.class) %> | 26 | + <%= render_profile_actions block.owner.class %> |
27 | </div> | 27 | </div> |
28 | </div><!-- end class="vcard" --> | 28 | </div><!-- end class="vcard" --> |
app/views/blocks/profile_info.rhtml
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | <% end %> | 40 | <% end %> |
41 | 41 | ||
42 | <div class="profile-info-options"> | 42 | <div class="profile-info-options"> |
43 | - <%= render :file => view_for_profile_actions(block.owner.class) %> | 43 | + <%= render_profile_actions block.owner.class %> |
44 | </div> | 44 | </div> |
45 | 45 | ||
46 | </div><!-- end class="vcard" --> | 46 | </div><!-- end class="vcard" --> |
app/views/blocks/profile_info_actions/_community.html.erb
0 → 100644
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +<ul> | ||
2 | + <li> | ||
3 | + <%= render "blocks/profile_info_actions/join_leave_community" %> | ||
4 | + </li> | ||
5 | + <% if logged_in? %> | ||
6 | + <% if profile.enable_contact? %> | ||
7 | + <li> | ||
8 | + <%= link_to content_tag('span', _('Send an e-mail')), | ||
9 | + { :profile => profile.identifier, | ||
10 | + :controller => 'contact', | ||
11 | + :action => 'new' }, | ||
12 | + {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %> | ||
13 | + </li> | ||
14 | + <% end %> | ||
15 | + | ||
16 | + <li><%= report_abuse(profile, :button) %></li> | ||
17 | + | ||
18 | + <%= render_environment_features(:profile_actions) %> | ||
19 | + <% end %> | ||
20 | +</ul> |
app/views/blocks/profile_info_actions/_enterprise.html.erb
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<ul> | ||
2 | + <%if logged_in? %> | ||
3 | + <%if !user.favorite_enterprises.include?(profile) %> | ||
4 | + <li><%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => __('Add enterprise as favorite') %></li> | ||
5 | + <% end %> | ||
6 | + <% end %> | ||
7 | + <% if profile.enable_contact? %> | ||
8 | + <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %> </li> | ||
9 | + <% end %> | ||
10 | + | ||
11 | + <li><%= report_abuse(profile, :button) %></li> | ||
12 | +</ul> |
app/views/blocks/profile_info_actions/_organization.html.erb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<ul> | ||
2 | + <%if logged_in? && (user != profile) %> | ||
3 | + | ||
4 | + <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %> | ||
5 | + <li> | ||
6 | + <%= button(:add, content_tag('span', __('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %> | ||
7 | + </li> | ||
8 | + <% end %> | ||
9 | + | ||
10 | + <% if user.is_a_friend?(profile) && profile.enable_contact? %> | ||
11 | + <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %> </li> | ||
12 | + <% end %> | ||
13 | + | ||
14 | + <li><%= report_abuse(profile, :button) %></li> | ||
15 | + <% end %> | ||
16 | +</ul> |
app/views/blocks/profile_info_actions/community.rhtml
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -<ul> | ||
2 | - <li> | ||
3 | - <%= render "blocks/profile_info_actions/join_leave_community" %> | ||
4 | - </li> | ||
5 | - <% if logged_in? %> | ||
6 | - <% if profile.enable_contact? %> | ||
7 | - <li> | ||
8 | - <%= link_to content_tag('span', _('Send an e-mail')), | ||
9 | - { :profile => profile.identifier, | ||
10 | - :controller => 'contact', | ||
11 | - :action => 'new' }, | ||
12 | - {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %> | ||
13 | - </li> | ||
14 | - <% end %> | ||
15 | - | ||
16 | - <li><%= report_abuse(profile, :button) %></li> | ||
17 | - | ||
18 | - <%= render_environment_features(:profile_actions) %> | ||
19 | - <% end %> | ||
20 | -</ul> | ||
21 | \ No newline at end of file | 0 | \ No newline at end of file |
app/views/blocks/profile_info_actions/enterprise.rhtml
@@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
1 | -<ul> | ||
2 | - <%if logged_in? %> | ||
3 | - <%if !user.favorite_enterprises.include?(profile) %> | ||
4 | - <li><%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => __('Add enterprise as favorite') %></li> | ||
5 | - <% end %> | ||
6 | - <% end %> | ||
7 | - <% if profile.enable_contact? %> | ||
8 | - <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %> </li> | ||
9 | - <% end %> | ||
10 | - | ||
11 | - <li><%= report_abuse(profile, :button) %></li> | ||
12 | -</ul> |
app/views/blocks/profile_info_actions/organization.rhtml
app/views/blocks/profile_info_actions/person.rhtml
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -<ul> | ||
2 | - <%if logged_in? && (user != profile) %> | ||
3 | - | ||
4 | - <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %> | ||
5 | - <li> | ||
6 | - <%= button(:add, content_tag('span', __('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %> | ||
7 | - </li> | ||
8 | - <% end %> | ||
9 | - | ||
10 | - <% if user.is_a_friend?(profile) && profile.enable_contact? %> | ||
11 | - <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %> </li> | ||
12 | - <% end %> | ||
13 | - | ||
14 | - <li><%= report_abuse(profile, :button) %></li> | ||
15 | - <% end %> | ||
16 | -</ul> |
test/unit/application_helper_test.rb
@@ -53,15 +53,6 @@ class ApplicationHelperTest < ActiveSupport::TestCase | @@ -53,15 +53,6 @@ class ApplicationHelperTest < ActiveSupport::TestCase | ||
53 | assert_equal 'test/application_helper_test/school/project', partial_for_class(School::Project) | 53 | assert_equal 'test/application_helper_test/school/project', partial_for_class(School::Project) |
54 | end | 54 | end |
55 | 55 | ||
56 | - should 'look for superclasses on view_for_profile actions' do | ||
57 | - File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/float.rhtml").returns(false) | ||
58 | - File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/float.html.erb").returns(false) | ||
59 | - File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/numeric.rhtml").returns(false) | ||
60 | - File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/numeric.html.erb").returns(true) | ||
61 | - | ||
62 | - assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float) | ||
63 | - end | ||
64 | - | ||
65 | should 'give error when there is no partial for class' do | 56 | should 'give error when there is no partial for class' do |
66 | assert_raises ArgumentError do | 57 | assert_raises ArgumentError do |
67 | partial_for_class(nil) | 58 | partial_for_class(nil) |