Takes already-flagged-content out of Ability's concerns

This commit is contained in:
kikito
2015-09-01 10:33:11 +02:00
parent 27ece220f6
commit 6902d2851b
2 changed files with 7 additions and 30 deletions

View File

@@ -22,21 +22,11 @@ class Ability
can :create, Comment
can :create, Debate
can :flag, Comment do |comment|
comment.author_id != user.id && !Flag.flagged?(user, comment)
end
can [:flag, :unflag], Comment
cannot [:flag, :unflag], Comment, user_id: user.id
can :unflag, Comment do |comment|
comment.author_id != user.id && Flag.flagged?(user, comment)
end
can :flag, Debate do |debate|
debate.author_id != user.id && !Flag.flagged?(user, debate)
end
can :unflag, Debate do |debate|
debate.author_id != user.id && Flag.flagged?(user, debate)
end
can [:flag, :unflag], Debate
cannot [:flag, :unflag], Debate, author_id: user.id
unless user.organization?
can :vote, Debate