Commit 49dd502d authored by Carl Chenet's avatar Carl Chenet

Comment: don't show downvote summary if we're not showing

parent 7855b2c3
......@@ -431,10 +431,8 @@ class Comment < ActiveRecord::Base
self.upvotes - self.downvotes
end
def score_for_user(user)
if (user && user.is_moderator?) ||
(self.created_at && self.created_at < 24.hours.ago) ||
!SCORE_RANGE_TO_HIDE.include?(score)
def score_for_user(u)
if self.showing_downvotes_for_user?(u)
score
else
"-"
......@@ -445,6 +443,12 @@ class Comment < ActiveRecord::Base
Rails.application.root_url + "c/#{self.short_id}"
end
def showing_downvotes_for_user?(u)
return (u && u.is_moderator?) ||
(self.created_at && self.created_at < 36.hours.ago) ||
!SCORE_RANGE_TO_HIDE.include?(self.score)
end
def to_param
self.short_id
end
......
......@@ -100,8 +100,8 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<span class="reason">
<% if comment.downvotes > 0 &&
((comment.score <= 0 && comment.user_id == @user.try(:id)) ||
@user.try("is_moderator?")) %>
comment.showing_downvotes_for_user?(@user) &&
(comment.user_id == @user.try(:id) || @user.try("is_moderator?")) %>
| <%= comment.vote_summary_for_user(@user).downcase %>
<% elsif comment.current_vote && comment.current_vote[:vote] == -1 %>
| -1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment