Sha256: 558060d6d6c89df6514932110dfef33d3c6caff3e3a9f7f1666f5a07dd7d0483

Contents?: true

Size: 1.07 KB

Versions: 34

Compression:

Stored size: 1.07 KB

Contents

module Hydra::AccessControlsEnforcement
  extend ActiveSupport::Concern
  include Blacklight::AccessControls::Enforcement

  protected

  def under_embargo?
    load_permissions_from_solr
    embargo_key = Hydra.config.permissions.embargo.release_date
    if @permissions_solr_document[embargo_key]
      embargo_date = Date.parse(@permissions_solr_document[embargo_key].split(/T/)[0])
      return embargo_date > Date.parse(Time.now.to_s)
    end
    false
  end

  # Which permission levels (logical OR) will grant you the ability to discover documents in a search.
  # Overrides blacklight-access_controls method.
  def discovery_permissions
    @discovery_permissions ||= ["edit","discover","read"]
  end

  # Find the name of the solr field for this type of permission.
  # e.g. "read_access_group_ssim" or "discover_access_person_ssim".
  # Used by blacklight-access_controls.
  def solr_field_for(permission_type, permission_category)
    permissions = Hydra.config.permissions[permission_type.to_sym]
    permission_category == 'group' ? permissions.group : permissions.individual
  end

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
hydra-access-controls-11.0.7 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-11.0.6 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-11.0.1 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-11.0.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-11.0.0.rc2 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.7.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.6.2 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.6.1 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.6.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.5.1 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.5.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.4.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.4.0.rc2 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.4.0.rc1 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.3.4 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.3.3 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.3.2 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.3.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.2.0 lib/hydra/access_controls_enforcement.rb
hydra-access-controls-10.1.0 lib/hydra/access_controls_enforcement.rb