Commit 63420bb0c78992c884745ef5b668b87cdebafb07
1 parent
ce0a14a2
Exists in
communities_ratings
Crate a block that displays the community average rating
Showing
5 changed files
with
63 additions
and
28 deletions
Show diff stats
... | ... | @@ -0,0 +1,30 @@ |
1 | +class AverageRatingBlock < Block | |
2 | + include RatingsHelper | |
3 | + | |
4 | + def self.description | |
5 | + _('Community Average Rating') | |
6 | + end | |
7 | + | |
8 | + def help | |
9 | + _('This block displays the community average rating.') | |
10 | + end | |
11 | + | |
12 | + def content(args = {}) | |
13 | + profile_identifier = self.owner.identifier | |
14 | + average_rating = CommunityRating.average_rating self.owner.id | |
15 | + | |
16 | + proc do | |
17 | + render( | |
18 | + :file => 'blocks/display_community_average_rating', | |
19 | + :locals => { | |
20 | + :profile_identifier => profile_identifier, | |
21 | + :average_rating => average_rating | |
22 | + } | |
23 | + ) | |
24 | + end | |
25 | + end | |
26 | + | |
27 | + def cacheable? | |
28 | + false | |
29 | + end | |
30 | +end | ... | ... |
plugins/communities_ratings/lib/communities_ratings_plugin.rb
... | ... | @@ -33,7 +33,7 @@ class CommunitiesRatingsPlugin < Noosfero::Plugin |
33 | 33 | average_rating = CommunityRating.average_rating community.id |
34 | 34 | |
35 | 35 | Proc::new { |
36 | - render :file => 'hotspots/display_community_average_rating', | |
36 | + render :file => 'blocks/display_community_average_rating', | |
37 | 37 | :locals => { |
38 | 38 | :profile_identifier => community.identifier, |
39 | 39 | :average_rating => average_rating |
... | ... | @@ -44,7 +44,8 @@ class CommunitiesRatingsPlugin < Noosfero::Plugin |
44 | 44 | |
45 | 45 | def self.extra_blocks |
46 | 46 | { |
47 | - CommunitiesRatingsBlock => { :type => [Community], :position => ['1']} | |
47 | + CommunitiesRatingsBlock => {:type => [Community], :position => ['1']}, | |
48 | + AverageRatingBlock => {:type => [Community]} | |
48 | 49 | } |
49 | 50 | end |
50 | 51 | ... | ... |
plugins/communities_ratings/style.css
plugins/communities_ratings/views/blocks/display_community_average_rating.html.erb
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +<div class="community-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-community"> | |
23 | + <%= link_to _('Rate this community'), url_for(:controller => 'communities_ratings_plugin_profile', :action => 'new_rating', :profile=>profile_identifier) %> | |
24 | + </div> | |
25 | +</div> | |
0 | 26 | \ No newline at end of file | ... | ... |
plugins/communities_ratings/views/hotspots/display_community_average_rating.html.erb
... | ... | @@ -1,25 +0,0 @@ |
1 | -<div class="community-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-community"> | |
23 | - <%= link_to _('Rate this community'), url_for(:controller => 'communities_ratings_plugin_profile', :action => 'new_rating', :profile=>profile_identifier) %> | |
24 | - </div> | |
25 | -</div> | |
26 | 0 | \ No newline at end of file |