Commit 01b77ecb622ed54a508afdd0b7573ce67cb4d9fd
Committed by
Álvaro Fernando Matos de Souza
1 parent
5887d4b7
Exists in
master
and in
5 other branches
Add rating's block to software main page
Signed-off-by: Fábio Teixeira <fabio1079@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
2 changed files
with
31 additions
and
1 deletions
Show diff stats
lib/software_information_block.rb
@@ -15,10 +15,12 @@ class SoftwareInformationBlock < Block | @@ -15,10 +15,12 @@ class SoftwareInformationBlock < Block | ||
15 | def content(args={}) | 15 | def content(args={}) |
16 | block = self | 16 | block = self |
17 | s = show_name | 17 | s = show_name |
18 | + average_rating = CommunityRating.average_rating block.owner.id | ||
19 | + | ||
18 | lambda do |object| | 20 | lambda do |object| |
19 | render( | 21 | render( |
20 | :file => 'blocks/software_information', | 22 | :file => 'blocks/software_information', |
21 | - :locals => { :block => block, :show_name => s } | 23 | + :locals => { :block => block, :show_name => s, :average_rating => average_rating} |
22 | ) | 24 | ) |
23 | end | 25 | end |
24 | end | 26 | end |
@@ -26,4 +28,11 @@ class SoftwareInformationBlock < Block | @@ -26,4 +28,11 @@ class SoftwareInformationBlock < Block | ||
26 | def cacheable? | 28 | def cacheable? |
27 | false | 29 | false |
28 | end | 30 | end |
31 | + | ||
32 | + private | ||
33 | + | ||
34 | + def owner_has_ratings? | ||
35 | + ratings = CommunityRating.where(community_id: block.owner.id) | ||
36 | + !ratings.empty? | ||
37 | + end | ||
29 | end | 38 | end |
views/blocks/software_information.html.erb
@@ -27,6 +27,27 @@ | @@ -27,6 +27,27 @@ | ||
27 | <b> | 27 | <b> |
28 | <%= block.owner.software_info.finality %> | 28 | <%= block.owner.software_info.finality %> |
29 | </b> | 29 | </b> |
30 | + <div class="community-average-rating-container"> | ||
31 | + <% if average_rating %> | ||
32 | + <div class="star-rate-text"><%= _("Rate") %></div> | ||
33 | + | ||
34 | + <div class="star-container"> | ||
35 | + <% (1..5).each do |star_number| %> | ||
36 | + <% if star_number <= average_rating %> | ||
37 | + <div class="medium-star-positive"></div> | ||
38 | + <% else %> | ||
39 | + <div class="medium-star-negative"></div> | ||
40 | + <% end %> | ||
41 | + <% end %> | ||
42 | + </div> | ||
43 | + <% else %> | ||
44 | + <%= _("Be the first to rate this software") %> | ||
45 | + <% end %> | ||
46 | + | ||
47 | + <div class="rate-this-software"> | ||
48 | + <%= link_to _('Rate this software'), url_for(:controller => 'communities_ratings_plugin_profile', :action => 'new_rating', :profile=>block.owner.identifier) %> | ||
49 | + </div> | ||
50 | + </div> | ||
30 | </td> | 51 | </td> |
31 | </tr> | 52 | </tr> |
32 | </table> | 53 | </table> |