if a comment is downvoted, show the comment's user a summary of its downvote reasons
This commit is contained in:
parent
49feb9ba43
commit
5a72a9d6a7
|
@ -79,6 +79,16 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
self.story.update_comment_count!
|
||||
end
|
||||
|
||||
def downvote_summary
|
||||
reasons = {}
|
||||
Vote.where(:comment_id => self.id).each do |v|
|
||||
reasons[v.reason] ||= 0
|
||||
reasons[v.reason] += 1
|
||||
end
|
||||
|
||||
reasons.map{|r,v| "#{Vote::COMMENT_REASONS[r]} (#{v})" }.join(", ")
|
||||
end
|
||||
|
||||
def is_gone?
|
||||
is_deleted?
|
||||
|
|
|
@ -29,10 +29,14 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
|||
<%= time_ago_in_words(comment.has_been_edited?? comment.updated_at :
|
||||
comment.created_at).gsub(/^about /, "") %> ago
|
||||
|
||||
<span class="reason"><%= comment.current_vote &&
|
||||
comment.current_vote[:vote] == -1 ?
|
||||
"(#{Vote::COMMENT_REASONS[comment.current_vote[:reason]].downcase})" :
|
||||
"" %></span>
|
||||
<span class="reason">
|
||||
<% if comment.downvotes > 0 && comment.user_id == @user.try(:id) %>
|
||||
(<%= comment.downvote_summary.downcase %>)
|
||||
<% elsif comment.current_vote && comment.current_vote[:vote] == -1 %>
|
||||
(<%= Vote::COMMENT_REASONS[comment.current_vote[:reason]].downcase
|
||||
%>)
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<% if !comment.previewing %>
|
||||
|
|
Loading…
Reference in New Issue