Commit 9000ae3d0908139c39c2bb48b25e471615a932af

Authored by Tallys Martins
1 parent 962f6b11

Organization Ratings Plugin improvements

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
plugins/organization_ratings/lib/create_organization_rating_comment.rb
@@ -49,16 +49,6 @@ class CreateOrganizationRatingComment &lt; Task @@ -49,16 +49,6 @@ class CreateOrganizationRatingComment &lt; Task
49 rating.save 49 rating.save
50 end 50 end
51 51
52 - def get_comment_message  
53 - if self.status == Status::CANCELLED  
54 - _("Comment rejected")  
55 - elsif self.status == Status::FINISHED  
56 - self.body  
57 - else  
58 - _("No comment")  
59 - end  
60 - end  
61 -  
62 def accept_details 52 def accept_details
63 true 53 true
64 end 54 end
plugins/organization_ratings/lib/organization_rating.rb
@@ -19,12 +19,18 @@ class OrganizationRating &lt; ActiveRecord::Base @@ -19,12 +19,18 @@ class OrganizationRating &lt; ActiveRecord::Base
19 19
20 def display_comment_to? person 20 def display_comment_to? person
21 if person.present? 21 if person.present?
22 - person.is_admin? || !comment_rejected? 22 + person.is_admin? || !comment_rejected? || person == self.person
23 else 23 else
24 !comment_rejected? 24 !comment_rejected?
25 end 25 end
26 end 26 end
27 27
  28 + def display_rejected_message_to? person
  29 + if person.present?
  30 + comment_rejected? && (person.is_admin? || person == self.person)
  31 + end
  32 + end
  33 +
28 def self.average_rating organization_id 34 def self.average_rating organization_id
29 average = OrganizationRating.where(organization_id: organization_id).average(:value) 35 average = OrganizationRating.where(organization_id: organization_id).average(:value)
30 36
plugins/organization_ratings/views/shared/_user_rating_container.html.erb
@@ -25,8 +25,7 @@ @@ -25,8 +25,7 @@
25 </div> 25 </div>
26 26
27 <div class="user-testimony"> 27 <div class="user-testimony">
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> 28 + <p class="comment-rejected-msg"> <%= _("Comment rejected") if user_rate.display_rejected_message_to?(user) %> </p>
30 <p class="comment-body"> <%= user_rate.comment.body if user_rate.display_comment_to?(user) %> </p> 29 <p class="comment-body"> <%= user_rate.comment.body if user_rate.display_comment_to?(user) %> </p>
31 </div> 30 </div>
32 <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %> 31 <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %>