show story hider count on story detail page

This commit is contained in:
joshua stein 2014-03-13 10:51:12 -05:00
parent ed71fd8d61
commit 8b60e5fd63
2 changed files with 8 additions and 0 deletions

View file

@ -225,6 +225,11 @@ class Story < ActiveRecord::Base
"hotness = '#{self.calculated_hotness}' WHERE id = #{self.id.to_i}")
end
def hider_count
@hider_count ||= Vote.where(:story_id => self.id, :comment_id => nil,
:vote => 0).count
end
def is_editable_by_user?(user)
if user && user.is_moderator?
return true

View file

@ -71,6 +71,9 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
| <%= link_to "hide", story_hide_url(story.short_id),
:class => "hider" %>
<% end %>
<% if defined?(single_story) && single_story && story.hider_count > 0 %>
(hidden by <%= pluralize(story.hider_count, "user") %>)
<% end %>
<% end %>
<% if !story.is_gone? && (@user || story.comments_count > 0) %>
<span class="comments_label">