Sha256: 62c22f0a390481c76c2059e09efeec581a184fb0b9f74a3ff79ca0f700a5232c

Contents?: true

Size: 1.28 KB

Versions: 9

Compression:

Stored size: 1.28 KB

Contents

module Spotlight
  ##
  # Default Spotlight CanCan abilities
  module Ability
    include CanCan::Ability

    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
    def initialize(user)
      user ||= ::User.new

      alias_action :process_import, to: :import

      can :manage, :all if user.superadmin?

      # exhibit admin
      can [:update, :import, :export, :destroy], Spotlight::Exhibit, id: user.admin_roles.pluck(:exhibit_id)
      can :manage, [Spotlight::BlacklightConfiguration, Spotlight::Role], exhibit_id: user.admin_roles.pluck(:exhibit_id)

      can :manage, PaperTrail::Version if user.roles.any?

      # exhibit curator
      can :manage, [
        Spotlight::Attachment,
        Spotlight::Search,
        Spotlight::Resource,
        Spotlight::Page,
        Spotlight::Contact,
        Spotlight::CustomField], exhibit_id: user.roles.pluck(:exhibit_id)

      can :manage, Spotlight::Lock, by: user

      can [:read, :curate, :tag], Spotlight::Exhibit, id: user.roles.pluck(:exhibit_id)

      # public
      can :read, Spotlight::HomePage
      can :read, Spotlight::Exhibit, published: true
      can :read, Spotlight::Page, published: true
      can :read, Spotlight::Search, published: true
    end
    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-0.12.0 app/models/spotlight/ability.rb
blacklight-spotlight-0.11.0 app/models/spotlight/ability.rb
blacklight-spotlight-0.10.3 app/models/spotlight/ability.rb
blacklight-spotlight-0.10.2 app/models/spotlight/ability.rb
blacklight-spotlight-0.10.1 app/models/spotlight/ability.rb
blacklight-spotlight-0.10.0 app/models/spotlight/ability.rb
blacklight-spotlight-0.9.2 app/models/spotlight/ability.rb
blacklight-spotlight-0.9.1 app/models/spotlight/ability.rb
blacklight-spotlight-0.9.0 app/models/spotlight/ability.rb