Commit bd32f803f429d7e9ea89d8f002039f3d32409bf6
1 parent
e3b23cb0
Exists in
suggest_rejected_value
Display rejected rating comments only to env admins
Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br> Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com>
Showing
4 changed files
with
18 additions
and
4 deletions
Show diff stats
plugins/organization_ratings/db/migrate/20151117232133_add_display_comment_to_organization_rating.rb
0 → 100644
plugins/organization_ratings/lib/create_organization_rating_comment.rb
... | ... | @@ -9,19 +9,24 @@ class CreateOrganizationRatingComment < Task |
9 | 9 | attr_accessible :organization_rating_id, :body, :requestor |
10 | 10 | attr_accessible :reject_explanation, :target |
11 | 11 | |
12 | - before_save :update_comment_body | |
12 | + before_save :update_comment_body, :check_display_comment | |
13 | 13 | |
14 | 14 | DATA_FIELDS = ['body'] |
15 | 15 | DATA_FIELDS.each do |field| |
16 | 16 | settings_items field.to_sym |
17 | 17 | end |
18 | 18 | |
19 | + def check_display_comment | |
20 | + @rating = OrganizationRating.find_by_id(self.organization_rating_id) | |
21 | + @rating.comment_rejected = true if self.status == Status::CANCELLED | |
22 | + end | |
23 | + | |
19 | 24 | def update_comment_body |
20 | 25 | if self.organization_rating_comment_id.nil? |
21 | 26 | create_comment |
22 | 27 | else |
23 | 28 | comment = Comment.find_by_id(self.organization_rating_comment_id) |
24 | - comment.body = get_comment_message | |
29 | + comment.body = self.body | |
25 | 30 | comment.save |
26 | 31 | end |
27 | 32 | end | ... | ... |
plugins/organization_ratings/lib/organization_rating.rb
... | ... | @@ -3,7 +3,7 @@ class OrganizationRating < ActiveRecord::Base |
3 | 3 | belongs_to :organization |
4 | 4 | belongs_to :comment |
5 | 5 | |
6 | - attr_accessible :value, :person, :organization, :comment | |
6 | + attr_accessible :value, :person, :organization, :comment, :comment_rejected | |
7 | 7 | |
8 | 8 | validates :value, |
9 | 9 | :presence => true, :inclusion => { |
... | ... | @@ -13,6 +13,9 @@ class OrganizationRating < ActiveRecord::Base |
13 | 13 | validates :organization_id, :person_id, |
14 | 14 | :presence => true |
15 | 15 | |
16 | + def comment_rejected? | |
17 | + return comment_rejected | |
18 | + end | |
16 | 19 | |
17 | 20 | def self.average_rating organization_id |
18 | 21 | average = OrganizationRating.where(organization_id: organization_id).average(:value) | ... | ... |
plugins/organization_ratings/views/shared/_user_rating_container.html.erb
... | ... | @@ -25,7 +25,8 @@ |
25 | 25 | </div> |
26 | 26 | |
27 | 27 | <div class="user-testimony"> |
28 | - <%= user_rate.comment.nil? ? _("No comment") : user_rate.comment.body %> | |
28 | + | |
29 | + <%= user_rate.comment.nil? ? _("No comment") : (user_rate.comment_rejected? ? "" : user_rate.comment.body) %> | |
29 | 30 | </div> |
30 | 31 | |
31 | 32 | <%= @plugins.dispatch(:organization_ratings_plugin_extra_fields_show_data, user_rate).collect { |content| instance_exec(&content) }.join("") %> | ... | ... |