Commit c9e1cdf16a9d40c39404189f5c2ea68d37412aad
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>
Showing
3 changed files
with
8 additions
and
5 deletions
Show diff stats
plugins/organization_ratings/lib/average_rating_block.rb
@@ -11,14 +11,16 @@ class AverageRatingBlock < Block | @@ -11,14 +11,16 @@ class AverageRatingBlock < Block | ||
11 | 11 | ||
12 | def content(args = {}) | 12 | def content(args = {}) |
13 | profile_identifier = self.owner.identifier | 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 | proc do | 17 | proc do |
17 | render( | 18 | render( |
18 | :file => 'blocks/display_organization_average_rating', | 19 | :file => 'blocks/display_organization_average_rating', |
19 | :locals => { | 20 | :locals => { |
20 | :profile_identifier => profile_identifier, | 21 | :profile_identifier => profile_identifier, |
21 | - :average_rating => average_rating | 22 | + :average_rating => statistics[:average], |
23 | + :block => block | ||
22 | } | 24 | } |
23 | ) | 25 | ) |
24 | end | 26 | end |
plugins/organization_ratings/lib/organization_ratings_plugin.rb
@@ -38,13 +38,14 @@ class OrganizationRatingsPlugin < Noosfero::Plugin | @@ -38,13 +38,14 @@ class OrganizationRatingsPlugin < Noosfero::Plugin | ||
38 | # Plugin Hotspot to display the average rating | 38 | # Plugin Hotspot to display the average rating |
39 | def display_organization_average_rating organization | 39 | def display_organization_average_rating organization |
40 | unless organization.nil? | 40 | unless organization.nil? |
41 | - average_rating = OrganizationRating.average_rating organization.id | 41 | + average_rating = OrganizationRating.statistics_for_profile organization |
42 | 42 | ||
43 | Proc::new { | 43 | Proc::new { |
44 | render :file => 'blocks/display_organization_average_rating', | 44 | render :file => 'blocks/display_organization_average_rating', |
45 | :locals => { | 45 | :locals => { |
46 | + :statistics => average_rating, | ||
46 | :profile_identifier => organization.identifier, | 47 | :profile_identifier => organization.identifier, |
47 | - :average_rating => average_rating | 48 | + :average_rating => average_rating[:average] |
48 | } | 49 | } |
49 | } | 50 | } |
50 | end | 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 | <div class="organization-average-rating-container"> | 3 | <div class="organization-average-rating-container"> |
4 | <% if statistics[:average] %> | 4 | <% if statistics[:average] %> |