Allow admins to remove votes on posts. This is for fixing vote abuse. Votes can be removed by going to the vote list on the /post_votes page, or by clicking on a post's score, then using the "Remove" option in the "..." dropdown menu next to the vote. Votes are soft-deleted - they're marked as deleted in the database, but not fully deleted. Removed votes are only visible to admins, not to regular users. When a vote is removed by an admin, it leaves a mod action. Technically it's possible to undelete votes, but there's no UI for it.
24 lines
468 B
Ruby
24 lines
468 B
Ruby
class PostVotePolicy < ApplicationPolicy
|
|
def create?
|
|
unbanned? && user.is_member?
|
|
end
|
|
|
|
def destroy?
|
|
record.user == user || user.is_admin?
|
|
end
|
|
|
|
def show?
|
|
user.is_admin? || record.user == user || (record.is_positive? && !record.is_deleted? && !record.user.enable_private_favorites?)
|
|
end
|
|
|
|
def can_see_voter?
|
|
show?
|
|
end
|
|
|
|
def api_attributes
|
|
attributes = super
|
|
attributes -= [:user_id] unless can_see_voter?
|
|
attributes
|
|
end
|
|
end
|