Fix an `undefined method post_vote_url` exception when doing `POST https://danbooru.donmai.us/posts/1/votes.json`. Also add the following API endpoints: * https://danbooru.donmai.us/post_votes/:id.json * https://danbooru.donmai.us/comment_votes/:id.json * https://danbooru.donmai.us/forum_post_votes/:id.json where `:id` is the vote ID, not the post ID.
18 lines
320 B
Ruby
18 lines
320 B
Ruby
class CommentVotePolicy < ApplicationPolicy
|
|
def create?
|
|
unbanned? && !record.comment.is_deleted?
|
|
end
|
|
|
|
def destroy?
|
|
!record.is_deleted? && (record.user_id == user.id || user.is_admin?)
|
|
end
|
|
|
|
def show?
|
|
can_see_votes? || record.user == user
|
|
end
|
|
|
|
def can_see_votes?
|
|
user.is_moderator?
|
|
end
|
|
end
|