diff --git a/lib/software_information_block.rb b/lib/software_information_block.rb index d6fb5cd..7a17b44 100644 --- a/lib/software_information_block.rb +++ b/lib/software_information_block.rb @@ -15,10 +15,12 @@ class SoftwareInformationBlock < Block def content(args={}) block = self s = show_name + average_rating = CommunityRating.average_rating block.owner.id + lambda do |object| render( :file => 'blocks/software_information', - :locals => { :block => block, :show_name => s } + :locals => { :block => block, :show_name => s, :average_rating => average_rating} ) end end @@ -26,4 +28,11 @@ class SoftwareInformationBlock < Block def cacheable? false end + + private + + def owner_has_ratings? + ratings = CommunityRating.where(community_id: block.owner.id) + !ratings.empty? + end end diff --git a/views/blocks/software_information.html.erb b/views/blocks/software_information.html.erb index 6e80908..70ba995 100644 --- a/views/blocks/software_information.html.erb +++ b/views/blocks/software_information.html.erb @@ -27,6 +27,27 @@ <%= block.owner.software_info.finality %> +
+ <% if average_rating %> +
<%= _("Rate") %>
+ +
+ <% (1..5).each do |star_number| %> + <% if star_number <= average_rating %> +
+ <% else %> +
+ <% end %> + <% end %> +
+ <% else %> + <%= _("Be the first to rate this software") %> + <% end %> + +
+ <%= link_to _('Rate this software'), url_for(:controller => 'communities_ratings_plugin_profile', :action => 'new_rating', :profile=>block.owner.identifier) %> +
+
-- libgit2 0.21.2