Permalink
Browse files
if a comment is downvoted, show the comment's user a summary of its d…
- Loading branch information...
Showing
with
18 additions
and
4 deletions.
-
+10
−0
app/models/comment.rb
-
+8
−4
app/views/comments/_comment.html.erb
|
|
@@ -79,6 +79,16 @@ def assign_votes |
|
|
|
|
|
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 %>
|
|
|
|
This comment has been minimized.
skalnikSep 3, 2012
skalnik commented onSep 3, 2012
5a72a9d