I'm doing this in preparation for the "Manager" ability, which will require even more refactors of the abilities (for example, manager can not modify their own account)
49 lines
1.3 KiB
Ruby
49 lines
1.3 KiB
Ruby
module Abilities
|
|
class Moderation
|
|
include CanCan::Ability
|
|
|
|
def initialize(user)
|
|
self.merge Abilities::Common.new(user)
|
|
|
|
can :read, Organization
|
|
can(:verify, Organization){ |o| !o.verified? }
|
|
can(:reject, Organization){ |o| !o.rejected? }
|
|
|
|
can :read, Comment
|
|
|
|
can :hide, Comment, hidden_at: nil
|
|
cannot :hide, Comment, user_id: user.id
|
|
|
|
can :ignore_flag, Comment, ignored_flag_at: nil, hidden_at: nil
|
|
cannot :ignore_flag, Comment, user_id: user.id
|
|
|
|
can :moderate, Comment
|
|
cannot :moderate, Comment, user_id: user.id
|
|
|
|
can :hide, Debate, hidden_at: nil
|
|
cannot :hide, Debate, author_id: user.id
|
|
|
|
can :ignore_flag, Debate, ignored_flag_at: nil, hidden_at: nil
|
|
cannot :ignore_flag, Debate, author_id: user.id
|
|
|
|
can :moderate, Debate
|
|
cannot :moderate, Debate, author_id: user.id
|
|
|
|
can :hide, Proposal, hidden_at: nil
|
|
cannot :hide, Proposal, author_id: user.id
|
|
|
|
can :ignore_flag, Proposal, ignored_flag_at: nil, hidden_at: nil
|
|
cannot :ignore_flag, Proposal, author_id: user.id
|
|
|
|
can :moderate, Proposal
|
|
cannot :moderate, Proposal, author_id: user.id
|
|
|
|
can :hide, User
|
|
cannot :hide, User, id: user.id
|
|
|
|
can :block, User
|
|
cannot :block, User, id: user.id
|
|
end
|
|
end
|
|
end
|