Commit c9e1cdf16a9d40c39404189f5c2ea68d37412aad

Authored by Tallys Martins
1 parent b4295dca
Exists in stable-spb-1.5

Fix organization ratings to fit noosfero 1.5

 - On 1.5, noosfero still generates html from blocks models

Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
plugins/organization_ratings/lib/average_rating_block.rb
... ... @@ -11,14 +11,16 @@ class AverageRatingBlock &lt; Block
11 11  
12 12 def content(args = {})
13 13 profile_identifier = self.owner.identifier
14   - average_rating = OrganizationRating.average_rating self.owner.id
  14 + statistics = OrganizationRating.statistics_for_profile self.owner
  15 + block = self
15 16  
16 17 proc do
17 18 render(
18 19 :file => 'blocks/display_organization_average_rating',
19 20 :locals => {
20 21 :profile_identifier => profile_identifier,
21   - :average_rating => average_rating
  22 + :average_rating => statistics[:average],
  23 + :block => block
22 24 }
23 25 )
24 26 end
... ...
plugins/organization_ratings/lib/organization_ratings_plugin.rb
... ... @@ -38,13 +38,14 @@ class OrganizationRatingsPlugin &lt; Noosfero::Plugin
38 38 # Plugin Hotspot to display the average rating
39 39 def display_organization_average_rating organization
40 40 unless organization.nil?
41   - average_rating = OrganizationRating.average_rating organization.id
  41 + average_rating = OrganizationRating.statistics_for_profile organization
42 42  
43 43 Proc::new {
44 44 render :file => 'blocks/display_organization_average_rating',
45 45 :locals => {
  46 + :statistics => average_rating,
46 47 :profile_identifier => organization.identifier,
47   - :average_rating => average_rating
  48 + :average_rating => average_rating[:average]
48 49 }
49 50 }
50 51 end
... ...
plugins/organization_ratings/views/blocks/display_organization_average_rating.html.erb
1   -<% statistics = OrganizationRating.statistics_for_profile block.owner %>
  1 +<% statistics ||= OrganizationRating.statistics_for_profile block.owner %>
2 2  
3 3 <div class="organization-average-rating-container">
4 4 <% if statistics[:average] %>
... ...