Sha256: f6c0c45f3332ea64111f636fd1e72e632f0c2e70ba4948c9165bff496c63d6c0

Contents?: true

Size: 845 Bytes

Versions: 41

Compression:

Stored size: 845 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(u)
    if u.is_super_admin?
      can :manage, :all
      can :publish, :all
      can :assign_roles, Tenon::User
    elsif u.is_admin?
      can :manage, :all
      can :publish, :all
      can :assign_roles, Tenon::User
      can(:destroy, Tenon::Page) { |page| page.key.blank? }

      cannot :update, Tenon::User
      can([:update], Tenon::User) do |user|
        !user.is_super_admin?
      end
      can :create, Tenon::User
    elsif u.is_contributor?
      can([:update, :edit], Tenon::User) { |user| user == u }
      can :read, :all
      can :create, Tenon::Page
      can([:update, :destroy, :edit], Tenon::Page) do |item|
        u.id == item.creator_id
      end
      can(:destroy, Tenon::Page) { |page| page.key.blank? }
    else
      can :read, :all
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
tenon-1.0.41 app/models/ability.rb
tenon-1.0.40 app/models/ability.rb
tenon-1.0.39 app/models/ability.rb
tenon-1.0.38 app/models/ability.rb
tenon-1.0.37 app/models/ability.rb
tenon-1.0.36 app/models/ability.rb
tenon-1.0.35 app/models/ability.rb
tenon-1.0.33 app/models/ability.rb
tenon-1.0.32 app/models/ability.rb
tenon-1.0.31 app/models/ability.rb
tenon-1.0.30 app/models/ability.rb
tenon-1.0.29 app/models/ability.rb
tenon-1.0.28 app/models/ability.rb
tenon-1.0.27 app/models/ability.rb
tenon-1.0.26 app/models/ability.rb
tenon-1.0.25 app/models/ability.rb
tenon-1.0.24 app/models/ability.rb
tenon-1.0.23 app/models/ability.rb
tenon-1.0.22 app/models/ability.rb
tenon-1.0.21 app/models/ability.rb