comments: allow admins to remove comment votes (fix #4640)

Allow admins to remove comment votes by other users. This is done by
clicking the comment score to get to the comment vote list, then
clicking the Remove button on every vote.
This commit is contained in:
evazion
2021-03-29 23:08:49 -05:00
parent 6b91e55283
commit b3c1c753b3
10 changed files with 78 additions and 15 deletions

View File

@@ -28,12 +28,16 @@ class CommentComponent < ApplicationComponent
def upvoted?
return false if current_user.is_anonymous?
comment.votes.active.select(&:is_positive?).map(&:user_id).include?(current_user.id)
current_vote&.is_positive?
end
def downvoted?
return false if current_user.is_anonymous?
comment.votes.active.select(&:is_negative?).map(&:user_id).include?(current_user.id)
current_vote&.is_negative?
end
def current_vote
@current_vote ||= comment.votes.active.find { |v| v.user_id == current_user.id }
end
def reported?