Commit c1b2bd5d6a13b014dd2786021d0c625e95256559

Authored by Braulio Bhavamitra
2 parents b9867847 858ea0f0

Merge branch 'refactor_organization_ratings' into 'master'

Refactor organization ratings

This plugin has two block for which the `content` methods were remove in favour of the structure provided by `BoxesHelper`. View renames were necessary to meet the expected standards there.

Travis build: https://travis-ci.org/rafamanzo/noosfero/builds/126873754

See merge request !884
plugins/organization_ratings/lib/average_rating_block.rb
... ... @@ -9,20 +9,20 @@ class AverageRatingBlock < Block
9 9 _('This block displays the organization average rating.')
10 10 end
11 11  
12   - def content(args = {})
13   - profile_identifier = self.owner.identifier
14   - average_rating = OrganizationRating.average_rating self.owner.id
  12 + # def content(args = {})
  13 + # profile_identifier = self.owner.identifier
  14 + # average_rating = OrganizationRating.average_rating self.owner.id
15 15  
16   - proc do
17   - render(
18   - :file => 'blocks/display_organization_average_rating',
19   - :locals => {
20   - :profile_identifier => profile_identifier,
21   - :average_rating => average_rating
22   - }
23   - )
24   - end
25   - end
  16 + # proc do
  17 + # render(
  18 + # :file => 'blocks/display_organization_average_rating',
  19 + # :locals => {
  20 + # :profile_identifier => profile_identifier,
  21 + # :average_rating => average_rating
  22 + # }
  23 + # )
  24 + # end
  25 + # end
26 26  
27 27 def cacheable?
28 28 false
... ...
plugins/organization_ratings/lib/organization_ratings_block.rb
... ... @@ -9,17 +9,6 @@ class OrganizationRatingsBlock < Block
9 9 _('This block displays the organization ratings.')
10 10 end
11 11  
12   - def content(args = {})
13   - block = self
14   -
15   - proc do
16   - render(
17   - :file => 'blocks/organization_ratings_block',
18   - :locals => {:block => block}
19   - )
20   - end
21   - end
22   -
23 12 def limit_number_of_ratings
24 13 env_organization_ratings_config.per_page
25 14 end
... ...
plugins/organization_ratings/views/blocks/average_rating.html.erb 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +<% average_rating = OrganizationRating.average_rating block.owner.id %>
  2 +
  3 +<div class="organization-average-rating-container">
  4 + <% if average_rating %>
  5 + <div class="star-rate-text">
  6 + <%= _("Rating: ") %>
  7 + </div>
  8 +
  9 + <div class="star-container">
  10 + <% (1..5).each do |star_number| %>
  11 + <% if star_number <= average_rating %>
  12 + <div class="medium-star-positive"></div>
  13 + <% else %>
  14 + <div class="medium-star-negative"></div>
  15 + <% end %>
  16 + <% end %>
  17 + </div>
  18 + <% else %>
  19 + <div class="rating-invitation">
  20 + <%= _("Be the first to rate!") %>
  21 + </div>
  22 + <% end %>
  23 +
  24 + <div class="rate-this-organization">
  25 + <%= link_to _("Rate this %s") % _(block.owner.class.name), url_for(:controller => "organization_ratings_plugin_profile", :action => "new_rating", :profile => block.owner.identifier) %>
  26 + </div>
  27 +</div>
0 28 \ No newline at end of file
... ...
plugins/organization_ratings/views/blocks/display_organization_average_rating.html.erb
... ... @@ -1,25 +0,0 @@
1   -<div class="organization-average-rating-container">
2   - <% if average_rating %>
3   - <div class="star-rate-text">
4   - <%= _("Rating: ") %>
5   - </div>
6   -
7   - <div class="star-container">
8   - <% (1..5).each do |star_number| %>
9   - <% if star_number <= average_rating %>
10   - <div class="medium-star-positive"></div>
11   - <% else %>
12   - <div class="medium-star-negative"></div>
13   - <% end %>
14   - <% end %>
15   - </div>
16   - <% else %>
17   - <div class="rating-invitation">
18   - <%= _("Be the first to rate!") %>
19   - </div>
20   - <% end %>
21   -
22   - <div class="rate-this-organization">
23   - <%= link_to _("Rate this %s") % _(profile.class.name), url_for(:controller => "organization_ratings_plugin_profile", :action => "new_rating", :profile=>profile_identifier) %>
24   - </div>
25   -</div>
26 0 \ No newline at end of file
plugins/organization_ratings/views/blocks/organization_ratings.html.erb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<div class="ratings-title">
  2 + <%= block_title(block.title, block.subtitle) %>
  3 + <% if block.get_ratings(block.owner.id).empty? %>
  4 + <div class="ratings-list">
  5 + <%= render :partial => 'shared/make_report_block' %>
  6 + </div>
  7 + <% else %>
  8 + <div class="ratings-list">
  9 + <% block.get_ratings(block.owner.id).each_with_index do |r, index| %>
  10 + <% break if index >= block.limit_number_of_ratings %>
  11 + <%= render :partial => "shared/user_rating_container", :locals => {:user_rate => r} %>
  12 + <% end %>
  13 +
  14 + <%= render :partial => 'shared/make_report_block' %>
  15 +
  16 + <div class="see-more">
  17 + <%= link_to _('See more'), url_for(:controller => 'organization_ratings_plugin_profile', :action => 'new_rating'), :class => 'icon-arrow-right-p' %>
  18 + </div>
  19 + </div>
  20 + <% end %>
  21 +</div>
... ...
plugins/organization_ratings/views/blocks/organization_ratings_block.html.erb
... ... @@ -1,21 +0,0 @@
1   -<div class="ratings-title">
2   - <%= block_title(block.title, block.subtitle) %>
3   - <% if block.get_ratings(block.owner.id).empty? %>
4   - <div class="ratings-list">
5   - <%= render :partial => 'shared/make_report_block' %>
6   - </div>
7   - <% else %>
8   - <div class="ratings-list">
9   - <% block.get_ratings(block.owner.id).each_with_index do |r, index| %>
10   - <% break if index >= block.limit_number_of_ratings %>
11   - <%= render :partial => "shared/user_rating_container", :locals => {:user_rate => r} %>
12   - <% end %>
13   -
14   - <%= render :partial => 'shared/make_report_block' %>
15   -
16   - <div class="see-more">
17   - <%= link_to _('See more'), url_for(:controller => 'organization_ratings_plugin_profile', :action => 'new_rating'), :class => 'icon-arrow-right-p' %>
18   - </div>
19   - </div>
20   - <% end %>
21   -</div>