Sha256: cb0149fb89e44cdae7545ec3c124f5846264f40153408dac689f79c41bf927e0

Contents?: true

Size: 855 Bytes

Versions: 42

Compression:

Stored size: 855 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, :publish], 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

42 entries across 42 versions & 1 rubygems

Version Path
tenon-1.1.8 app/models/ability.rb
tenon-1.1.7 app/models/ability.rb
tenon-1.1.6 app/models/ability.rb
tenon-1.1.5 app/models/ability.rb
tenon-1.1.4 app/models/ability.rb
tenon-1.1.3 app/models/ability.rb
tenon-1.1.2 app/models/ability.rb
tenon-1.1.1 app/models/ability.rb
tenon-1.0.76 app/models/ability.rb
tenon-1.0.75 app/models/ability.rb
tenon-1.0.74 app/models/ability.rb
tenon-1.0.73 app/models/ability.rb
tenon-1.0.72 app/models/ability.rb
tenon-1.0.71 app/models/ability.rb
tenon-1.0.70 app/models/ability.rb
tenon-1.0.69 app/models/ability.rb
tenon-1.0.68 app/models/ability.rb
tenon-1.0.67 app/models/ability.rb
tenon-1.0.66 app/models/ability.rb
tenon-1.0.65 app/models/ability.rb