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 | 15 | def content(args={}) |
| 16 | 16 | block = self |
| 17 | 17 | s = show_name |
| 18 | + average_rating = CommunityRating.average_rating block.owner.id | |
| 19 | + | |
| 18 | 20 | lambda do |object| |
| 19 | 21 | render( |
| 20 | 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 | 25 | end |
| 24 | 26 | end |
| ... | ... | @@ -26,4 +28,11 @@ class SoftwareInformationBlock < Block |
| 26 | 28 | def cacheable? |
| 27 | 29 | false |
| 28 | 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 | 38 | end | ... | ... |
views/blocks/software_information.html.erb
| ... | ... | @@ -27,6 +27,27 @@ |
| 27 | 27 | <b> |
| 28 | 28 | <%= block.owner.software_info.finality %> |
| 29 | 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 | 51 | </td> |
| 31 | 52 | </tr> |
| 32 | 53 | </table> | ... | ... |