Comment: don't show downvote summary if we're not showing
This commit is contained in:
parent
7855b2c3c4
commit
49dd502de2
|
@ -431,10 +431,8 @@ class Comment < ActiveRecord::Base
|
||||||
self.upvotes - self.downvotes
|
self.upvotes - self.downvotes
|
||||||
end
|
end
|
||||||
|
|
||||||
def score_for_user(user)
|
def score_for_user(u)
|
||||||
if (user && user.is_moderator?) ||
|
if self.showing_downvotes_for_user?(u)
|
||||||
(self.created_at && self.created_at < 24.hours.ago) ||
|
|
||||||
!SCORE_RANGE_TO_HIDE.include?(score)
|
|
||||||
score
|
score
|
||||||
else
|
else
|
||||||
"-"
|
"-"
|
||||||
|
@ -445,6 +443,12 @@ class Comment < ActiveRecord::Base
|
||||||
Rails.application.root_url + "c/#{self.short_id}"
|
Rails.application.root_url + "c/#{self.short_id}"
|
||||||
end
|
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
|
def to_param
|
||||||
self.short_id
|
self.short_id
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,8 +100,8 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
||||||
|
|
||||||
<span class="reason">
|
<span class="reason">
|
||||||
<% if comment.downvotes > 0 &&
|
<% if comment.downvotes > 0 &&
|
||||||
((comment.score <= 0 && comment.user_id == @user.try(:id)) ||
|
comment.showing_downvotes_for_user?(@user) &&
|
||||||
@user.try("is_moderator?")) %>
|
(comment.user_id == @user.try(:id) || @user.try("is_moderator?")) %>
|
||||||
| <%= comment.vote_summary_for_user(@user).downcase %>
|
| <%= comment.vote_summary_for_user(@user).downcase %>
|
||||||
<% elsif comment.current_vote && comment.current_vote[:vote] == -1 %>
|
<% elsif comment.current_vote && comment.current_vote[:vote] == -1 %>
|
||||||
| -1
|
| -1
|
||||||
|
|
Loading…
Reference in a new issue