Commit 43df1ac849a41449fa68c159c23e973688536aef

Authored by Pedro de Lyra Pereira
Committed by Álvaro Fernando Matos de Souza
1 parent 3474fc2c
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Display average rating on community's main page

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
lib/software_communities_plugin.rb
... ... @@ -70,6 +70,12 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
70 70 )
71 71 end
72 72  
  73 + module Hotspots
  74 + def display_community_average_rating community
  75 + nil
  76 + end
  77 + end
  78 +
73 79 def communities_ratings_plugin_comments_extra_fields
74 80 if context.profile.software?
75 81 Proc::new { render :file => 'comments_extra_fields' }
... ...
lib/software_information_block.rb
... ... @@ -15,12 +15,11 @@ class SoftwareInformationBlock &lt; 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 19 lambda do |object|
21 20 render(
22 21 :file => 'blocks/software_information',
23   - :locals => { :block => block, :show_name => s, :average_rating => average_rating}
  22 + :locals => { :block => block, :show_name => s}
24 23 )
25 24 end
26 25 end
... ...
views/blocks/software_information.html.erb
... ... @@ -27,27 +27,8 @@
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 30  
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>
  31 + <%= @plugins.dispatch(:display_community_average_rating, block.owner).collect { |content| instance_exec(&content) }.join("") %>
51 32 </td>
52 33 </tr>
53 34 </table>
... ...