Commit cd3ce9ea644e824e1e4b3d9043bc3f6f480d759a

Authored by Tallys Martins
1 parent ef0db549

Added improvements on hotspots interfaces

- Added one hotspot for task contents and another for ratings container content
- Rejected comments now are only displayed to env admins

Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
plugins/organization_ratings/lib/create_organization_rating_comment.rb
... ... @@ -19,6 +19,7 @@ class CreateOrganizationRatingComment &lt; Task
19 19 def check_display_comment
20 20 @rating = OrganizationRating.find_by_id(self.organization_rating_id)
21 21 @rating.comment_rejected = true if self.status == Status::CANCELLED
  22 + @rating.save
22 23 end
23 24  
24 25 def update_comment_body
... ...
plugins/organization_ratings/lib/organization_rating.rb
... ... @@ -14,7 +14,15 @@ class OrganizationRating &lt; ActiveRecord::Base
14 14 :presence => true
15 15  
16 16 def comment_rejected?
17   - return comment_rejected
  17 + comment_rejected
  18 + end
  19 +
  20 + def display_comment_to? person
  21 + if person.present?
  22 + person.is_admin? || !comment_rejected?
  23 + else
  24 + !comment_rejected?
  25 + end
18 26 end
19 27  
20 28 def self.average_rating organization_id
... ...
plugins/organization_ratings/lib/organization_ratings_plugin.rb
... ... @@ -22,7 +22,11 @@ class OrganizationRatingsPlugin &lt; Noosfero::Plugin
22 22 nil
23 23 end
24 24  
25   - def organization_ratings_plugin_extra_fields_show_data user_rating
  25 + def organization_ratings_plugin_task_extra_fields user_rating
  26 + nil
  27 + end
  28 +
  29 + def organization_ratings_plugin_container_extra_fields user_rating
26 30 nil
27 31 end
28 32  
... ...
plugins/organization_ratings/test/test_helper.rb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +class TestOrganizationRating
  2 +
  3 +
  4 +end
... ...
plugins/organization_ratings/test/unit/organization_rating_test.rb
... ... @@ -21,6 +21,11 @@ class OrganizationRatingTest &lt; ActiveSupport::TestCase
21 21 assert_equal false, organization_rating2.errors[:value].include?("must be between 1 and 5")
22 22 end
23 23  
  24 + test "display rating comment to env admin" do
  25 + p = fast_create(OrganizationRating)
  26 +
  27 + end
  28 +
24 29 test "Create task for create a rating comment" do
25 30 person = create_user('molly').person
26 31 person.email = "person@email.com"
... ...
plugins/organization_ratings/views/shared/_user_rating_container.html.erb
... ... @@ -25,10 +25,10 @@
25 25 </div>
26 26  
27 27 <div class="user-testimony">
28   -
29   - <%= user_rate.comment.nil? ? _("No comment") : (user_rate.comment_rejected? ? "" : user_rate.comment.body) %>
  28 + <p class="no-comment"> <%= _("No comment") if user_rate.comment.nil? %> <p>
  29 + <p class="comment-rejected-msg"> <%= _("Comment rejected") if user_rate.comment_rejected? %> </p>
  30 + <p class="comment-body"> <%= user_rate.comment.body if user_rate.display_comment_to?(user) %> </p>
30 31 </div>
31   -
32   - <%= @plugins.dispatch(:organization_ratings_plugin_extra_fields_show_data, user_rate).collect { |content| instance_exec(&content) }.join("") %>
  32 + <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %>
33 33 </div>
34 34 </div>
... ...
plugins/organization_ratings/views/tasks/_create_organization_rating_comment_accept_details.html.erb
1 1 <div class="organization-rating-comment-body">
  2 + <% rating = OrganizationRating.find(task.organization_rating_id) %>
  3 + <%= @plugins.dispatch(:organization_ratings_plugin_task_extra_fields, rating).collect{ |content| instance_exec(&content) }.join("") %>
2 4 <div class="task-comment">
3 5 <%= _("Comment:")%>
4 6 <%= "\"#{task.body}\""%>\
5 7 </div>
6 8  
7   - <% rating = OrganizationRating.find(task.organization_rating_id) %>
8   - <%= @plugins.dispatch(:organization_ratings_plugin_extra_fields_show_data, rating).collect{ |content| instance_exec(&content) }.join("") %>
9   -
10 9 <span class="rating-notice"><%="* "+_("The rating score is not moderated")%></span>
11 10 <div class="task-star-container">
12 11 <% (1..5).each do |star_number| %>
... ...