pundit: convert forum post votes to pundit.
This commit is contained in:
@@ -19,6 +19,10 @@ class ForumPostPolicy < ApplicationPolicy
|
||||
unbanned? && show? && user.is_moderator?
|
||||
end
|
||||
|
||||
def votable?
|
||||
unbanned? && show? && record.bulk_update_request.present? && record.bulk_update_request.is_pending?
|
||||
end
|
||||
|
||||
def reportable?
|
||||
unbanned? && show? && record.creator_id != user.id && !record.creator.is_moderator?
|
||||
end
|
||||
|
||||
13
app/policies/forum_post_vote_policy.rb
Normal file
13
app/policies/forum_post_vote_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class ForumPostVotePolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && policy(record.forum_post).votable?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
unbanned? && record.creator_id == user.id
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
[:score]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user