Commit 8badd05db92ef4602dd241990a1dcb7c7135dd2b
Exists in
master
and in
1 other branch
Merge branch 'organization_ratings_improvements' into 'master'
OrganizationRating improvements Fixes organization_rating integration See merge request !262
Showing
5 changed files
with
19 additions
and
11 deletions
Show diff stats
src/noosfero-spb/gov_user/controllers/gov_user_plugin_controller.rb
... | ... | @@ -5,6 +5,12 @@ class GovUserPluginController < ApplicationController |
5 | 5 | :governmental_sphere, :governmental_power, :juridical_nature, :sisp |
6 | 6 | ] |
7 | 7 | |
8 | + before_action :require_login, :only => [:create_institution, :create_institution_admin, :create_institution_view_variables] | |
9 | + | |
10 | + def require_login | |
11 | + redirect_to :controller => "/account", :action => "login" unless user.present? | |
12 | + end | |
13 | + | |
8 | 14 | def hide_registration_incomplete_percentage |
9 | 15 | response = false |
10 | 16 | ... | ... |
src/noosfero-spb/gov_user/test/functional/gov_user_plugin_controller_test.rb
... | ... | @@ -268,8 +268,8 @@ class GovUserPluginControllerTest < ActionController::TestCase |
268 | 268 | |
269 | 269 | post :create_institution_admin |
270 | 270 | |
271 | - assert_response 403 | |
272 | - assert_template :access_denied | |
271 | + assert_response 302 | |
272 | + assert_redirected_to(controller: "/account", action: "login") | |
273 | 273 | end |
274 | 274 | |
275 | 275 | should "regular user can not access action create_institution_admin" do | ... | ... |
src/noosfero-spb/software_communities/lib/ext/search_helper.rb
... | ... | @@ -32,9 +32,9 @@ module SearchHelper |
32 | 32 | |
33 | 33 | def sort_by_average_rating list |
34 | 34 | list.sort! do |a, b| |
35 | - rating_a = OrganizationRating.average_rating(a.id) | |
35 | + rating_a = OrganizationRating.statistics_for_profile(a)[:average] | |
36 | 36 | rating_a = 0 if rating_a.nil? |
37 | - rating_b = OrganizationRating.average_rating(b.id) | |
37 | + rating_b = OrganizationRating.statistics_for_profile(b)[:average] | |
38 | 38 | rating_b = 0 if rating_b.nil? |
39 | 39 | rating_a - rating_b |
40 | 40 | end | ... | ... |
src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb
1 | 1 | <div class="aditional-informations"> |
2 | - <div class="comments-people-benefited"> | |
3 | - <span><%=_("Benefited People")%>:</span> <%= number_with_delimiter(user_rating.people_benefited, ) unless user_rating.nil? %> | |
4 | - </div> | |
2 | + <% unless user_rating.nil? %> | |
3 | + <div class="comments-people-benefited"> | |
4 | + <span><%=_("Benefited People")%>:</span> <%= user_rating.people_benefited.present? ? number_with_delimiter(user_rating.people_benefited) : _(" --- ") %> | |
5 | + </div> | |
5 | 6 | |
6 | - <div class="comments-saved-value"> | |
7 | - <span><%=_("Saved Resources")%>:</span> <%= number_to_currency(user_rating.saved_value) unless user_rating.nil? %> | |
8 | - </div> | |
7 | + <div class="comments-saved-value"> | |
8 | + <span><%=_("Saved Resources")%>:</span> <%= user_rating.saved_value.present? ? number_to_currency(user_rating.saved_value) : _(" --- ") %> | |
9 | + </div> | |
10 | + <% end %> | |
9 | 11 | </div> |
10 | 12 | ... | ... |
src/noosfero-spb/software_communities/views/shared/_organization_average_rating_block.html.erb
1 | 1 | <div class="star-container catalog_rating_block"> |
2 | 2 | <% (1..5).each do |rate_number| %> |
3 | - <% if rate_number <= OrganizationRating.average_rating(community.id) %> | |
3 | + <% if rate_number <= OrganizationRating.statistics_for_profile(community)[:average] %> | |
4 | 4 | <div class="medium-star-positive"></div> |
5 | 5 | <% else %> |
6 | 6 | <div class="medium-star-negative"></div> | ... | ... |