Commit 75bd98457ff89c434ccd95672738b57dd33a9074

Authored by Pedro de Lyra Pereira
Committed by Fabio Teixeira
1 parent 75a63739

Adding disabled button to community's rating page

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
plugins/communities_ratings/lib/communities_ratings_plugin.rb
@@ -27,7 +27,22 @@ class CommunitiesRatingsPlugin &lt; Noosfero::Plugin @@ -27,7 +27,22 @@ class CommunitiesRatingsPlugin &lt; Noosfero::Plugin
27 end 27 end
28 end 28 end
29 29
30 - def self.extra_blocks 30 + # Plugin Hotspot to display the average rating
  31 + def display_community_average_rating community
  32 + unless community.nil?
  33 + average_rating = CommunityRating.average_rating community.id
  34 +
  35 + Proc::new {
  36 + render :file => 'hotspots/display_community_average_rating',
  37 + :locals => {
  38 + :profile_identifier => community.identifier,
  39 + :average_rating => average_rating
  40 + }
  41 + }
  42 + end
  43 + end
  44 +
  45 + def self.extra_blocks
31 { 46 {
32 CommunitiesRatingsBlock => { :type => [Community], :position => ['1']} 47 CommunitiesRatingsBlock => { :type => [Community], :position => ['1']}
33 } 48 }
plugins/communities_ratings/style.css
@@ -38,10 +38,57 @@ @@ -38,10 +38,57 @@
38 background-image: url('public/images/small-star-positive.png'); 38 background-image: url('public/images/small-star-positive.png');
39 } 39 }
40 40
  41 +.medium-star-negative, .medium-star-positive {
  42 + background-repeat: no-repeat;
  43 + float: left;
  44 + height: 20px;
  45 + margin-right: 2px;
  46 + position: relative;
  47 + width: 20px;
  48 +}
  49 +
  50 +.medium-star-positive {
  51 + background-image: url('public/images/star-positive-medium.png');
  52 +}
  53 +
  54 +.medium-star-negative {
  55 + background-image: url('public/images/star-negative-medium.png');
  56 +}
  57 +
41 .star-hide { 58 .star-hide {
42 display: none; 59 display: none;
43 } 60 }
44 61
  62 +.community-average-rating-container {
  63 + border-top: 1px dotted #D3D6DE;
  64 + margin-top: 20px;
  65 + padding-top: 10px;
  66 +}
  67 +
  68 +.community-average-rating-container .star-rate-text {
  69 + float: left;
  70 + margin-right: 10px;
  71 + padding-top: 5px;
  72 +}
  73 +
  74 +.community-average-rating-container .rating-invitation {
  75 + font-size: 14px;
  76 + float: left;
  77 + margin-right: 10px;
  78 + padding-top: 3px;
  79 +}
  80 +
  81 +.community-average-rating-container .star-container {
  82 + float: left;
  83 + width: 120px;
  84 +}
  85 +
  86 +.community-average-rating-container .rate-this-community {
  87 + border-left: 1px dotted #D3D6DE;
  88 + float: left;
  89 + padding: 4px 0px 2px 10px;
  90 +}
  91 +
45 .star-rate-data { 92 .star-rate-data {
46 width: 100%; 93 width: 100%;
47 padding-top: 20px; 94 padding-top: 20px;
plugins/communities_ratings/views/communities_ratings_plugin_profile/_new_rating_fields.html.erb
@@ -57,11 +57,21 @@ @@ -57,11 +57,21 @@
57 57
58 <% elsif environment.communities_ratings_vote_once %> 58 <% elsif environment.communities_ratings_vote_once %>
59 <div class="star-rate-form rating-vote-once"> 59 <div class="star-rate-form rating-vote-once">
60 - <%= _("Hi, #{current_user.name}! The administrators set that you can only vote once for this community.") %> 60 + <%= _("Hi, #{current_user.name}! The administrators set that you can vote") %>
  61 +
  62 + <strong><%= 'only once' %></strong>
  63 +
  64 + <%= "for this community." %>
  65 + <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %>
61 </div> 66 </div>
62 <% else %> 67 <% else %>
63 <div class="star-rate-form rating-cooldown"> 68 <div class="star-rate-form rating-cooldown">
64 - <%= _("Hi, #{current_user.name}! The administrators set the minimum time of #{environment.communities_ratings_cooldown} hour(s) between each evaluation. You can take a ride into our web site while you wait for the next record.") %> 69 + <%= _("Hi, #{current_user.name}! The administrators set the minimum time of") %>
  70 + <strong><%= _("%s hour(s)" % environment.communities_ratings_cooldown) %></strong>
  71 + <%= _("between each evaluation.") %>
  72 +
  73 + <%= render :partial => 'shared/rating_button', :locals => { :disabled => true } %>
  74 +
65 </div> 75 </div>
66 <% end %> 76 <% end %>
67 77
plugins/communities_ratings/views/hotspots/display_community_average_rating.html.erb 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +<div class="community-average-rating-container">
  2 + <% if average_rating %>
  3 + <div class="star-rate-text">
  4 + <%= _("Rating: ") %>
  5 + </div>
  6 +
  7 + <div class="star-container">
  8 + <% (1..5).each do |star_number| %>
  9 + <% if star_number <= average_rating %>
  10 + <div class="medium-star-positive"></div>
  11 + <% else %>
  12 + <div class="medium-star-negative"></div>
  13 + <% end %>
  14 + <% end %>
  15 + </div>
  16 + <% else %>
  17 + <div class="rating-invitation">
  18 + <%= _("Be the first to rate!") %>
  19 + </div>
  20 + <% end %>
  21 +
  22 + <div class="rate-this-community">
  23 + <%= link_to _('Rate this community'), url_for(:controller => 'communities_ratings_plugin_profile', :action => 'new_rating', :profile=>profile_identifier) %>
  24 + </div>
  25 +</div>
0 \ No newline at end of file 26 \ No newline at end of file
plugins/communities_ratings/views/shared/_make_report_block.html.erb
@@ -17,13 +17,7 @@ @@ -17,13 +17,7 @@
17 <%= _('Report your experiences.') %> 17 <%= _('Report your experiences.') %>
18 </div> 18 </div>
19 19
20 - <div class="button-bar">  
21 - <% if logged_in? %>  
22 - <%= button('rate',_('Rate Community'), {:controller => 'communities_ratings_plugin_profile', :action => 'new_rating'}) %>  
23 - <% else %>  
24 - <%= button('rate',_('Rate Community'), {:controller => 'account', :action => 'login'}) %>  
25 - <% end %>  
26 - </div> 20 + <%= render :partial => 'shared/rating_button', :locals => { :disabled => false } %>
27 21
28 <% unless logged_in? %> 22 <% unless logged_in? %>
29 <div class="alert"> 23 <div class="alert">
plugins/communities_ratings/views/shared/_rating_button.html.erb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +<div class="button-bar">
  2 + <% options = disabled ? {:disabled => 'disabled', :class => 'disabled-button'} : {} %>
  3 +
  4 + <% if logged_in? %>
  5 + <%= button('rate',_('Rate Community'), {:controller => 'communities_ratings_plugin_profile', :action => 'new_rating'}, options) %>
  6 + <% else %>
  7 + <%= button('rate',_('Rate Community'), {:controller => 'account', :action => 'login'}, options) %>
  8 + <% end %>
  9 +</div>
0 \ No newline at end of file 10 \ No newline at end of file