pundit: convert post flags to pundit.
This commit is contained in:
13
app/policies/post_flag_policy.rb
Normal file
13
app/policies/post_flag_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class PostFlagPolicy < ApplicationPolicy
|
||||
def can_search_flagger?
|
||||
user.is_moderator?
|
||||
end
|
||||
|
||||
def can_view_flagger?
|
||||
(user.is_moderator? || record.creator_id == user.id) && (record.post&.uploader_id != user.id)
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
[:post_id, :reason]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user