Sha256: dc4c41ee94fa3b4e6a77b1d809a94ec3b1e5e302017296d82930ad5b229925b8

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Spotlight::Ability
  include CanCan::Ability

  def initialize(user)
    user ||= ::User.new

    alias_action :process_import, to: :import
    alias_action :edit_metadata_fields, :edit_facet_fields, :metadata_fields, :available_configurations, to: :update

    if user.superadmin?
      can :manage, :all
    end

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

    # 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 :update, Spotlight::BlacklightConfiguration, exhibit_id: user.roles.pluck(:exhibit_id)

    can [:curate, :tag], Spotlight::Exhibit, id: user.roles.pluck(:exhibit_id)
    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, on_landing_page: true

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.2.0 app/models/spotlight/ability.rb