Sha256: 83f13375b534137d5c111a7d13d98510db97bc10fd56c44c123a8d276b4e1d08

Contents?: true

Size: 964 Bytes

Versions: 12

Compression:

Stored size: 964 Bytes

Contents

module EnjuEvent
  class Ability
    include CanCan::Ability
  
    def initialize(user, ip_address = nil)
      case user.try(:role).try(:name)
      when 'Administrator'
        can [:read, :create, :update], EventCategory
        can [:destroy, :delete], EventCategory do |event_category|
          !['unknown', 'closed'].include?(event_category.name)
        end
        can :manage, [
          Event,
          EventImportFile,
          EventExportFile,
          Participate
        ]
        can :read, EventImportResult
      when 'Librarian'
        can :manage, [
          Event,
          EventImportFile,
          EventExportFile,
          Participate
        ]
        can :read, [
          EventCategory,
          EventImportResult
        ]
      when 'User'
        can :read, [
          Event,
          EventCategory
        ]
      else
        can :read, [
          Event,
          EventCategory
        ]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
enju_event-0.1.19 app/models/enju_event/ability.rb
enju_event-0.1.18 app/models/enju_event/ability.rb
enju_event-0.1.17 app/models/enju_event/ability.rb
enju_event-0.1.17.pre27 app/models/enju_event/ability.rb
enju_event-0.1.17.pre26 app/models/enju_event/ability.rb
enju_event-0.1.17.pre25 app/models/enju_event/ability.rb
enju_event-0.1.17.pre24 app/models/enju_event/ability.rb
enju_event-0.1.17.pre23 app/models/enju_event/ability.rb
enju_event-0.1.17.pre22 app/models/enju_event/ability.rb
enju_event-0.1.17.pre21 app/models/enju_event/ability.rb
enju_event-0.1.17.pre20 app/models/enju_event/ability.rb
enju_event-0.1.17.pre19 app/models/enju_event/ability.rb