Commit 9000ae3d0908139c39c2bb48b25e471615a932af
1 parent
962f6b11
Exists in
suggest_rejected_value
Organization Ratings Plugin improvements
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
3 changed files
with
8 additions
and
13 deletions
Show diff stats
plugins/organization_ratings/lib/create_organization_rating_comment.rb
| ... | ... | @@ -49,16 +49,6 @@ class CreateOrganizationRatingComment < Task |
| 49 | 49 | rating.save |
| 50 | 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 | 52 | def accept_details |
| 63 | 53 | true |
| 64 | 54 | end | ... | ... |
plugins/organization_ratings/lib/organization_rating.rb
| ... | ... | @@ -19,12 +19,18 @@ class OrganizationRating < ActiveRecord::Base |
| 19 | 19 | |
| 20 | 20 | def display_comment_to? person |
| 21 | 21 | if person.present? |
| 22 | - person.is_admin? || !comment_rejected? | |
| 22 | + person.is_admin? || !comment_rejected? || person == self.person | |
| 23 | 23 | else |
| 24 | 24 | !comment_rejected? |
| 25 | 25 | end |
| 26 | 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 | 34 | def self.average_rating organization_id |
| 29 | 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 | 25 | </div> |
| 26 | 26 | |
| 27 | 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 | 29 | <p class="comment-body"> <%= user_rate.comment.body if user_rate.display_comment_to?(user) %> </p> |
| 31 | 30 | </div> |
| 32 | 31 | <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %> | ... | ... |