Files
grecia/app/models/ability.rb
kikito b4b69d89e7 Updates abilities for the new organisations
Note that unverified organisations can now create debates and comments
- that is a change over the initial request
2015-08-13 20:03:38 +02:00

37 lines
701 B
Ruby

class Ability
include CanCan::Ability
def initialize(user)
# Not logged in users
can :read, Debate
if user # logged-in users
can [:read, :update], User, id: user.id
can :read, Debate
can :update, Debate do |debate|
debate.editable_by?(user)
end
can :create, Comment
can :create, Debate
unless user.organization?
can :vote, Debate
can :vote, Comment
end
if user.moderator? || user.administrator?
can :read, Organization
can(:verify, Organization){ |o| !o.verified? }
can(:reject, Organization){ |o| !o.rejected? }
elsif user.administrator?
end
end
end
end