Sha256: 1df5d8425849e2e55728cbc9276739914793486eeaac6179103eae2966688c98

Contents?: true

Size: 746 Bytes

Versions: 7

Compression:

Stored size: 746 Bytes

Contents

module Sufia
  ### Allows :deposit as a valid type
  class AdminSetSearchBuilder < CurationConcerns::AdminSetSearchBuilder
    # We're going to check the permission_templates
    def gated_discovery_filters
      return super if @access != :deposit
      ["{!terms f=id}#{admin_set_ids.join(',')}"]
    end

    private

      def admin_set_ids
        PermissionTemplateAccess.joins(:permission_template)
                                .where(agent_type: 'user',
                                       agent_id: user,
                                       access: ['deposit', 'manage'])
                                .pluck('DISTINCT admin_set_id')
      end

      def user
        current_ability.current_user.user_key
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sufia-7.4.1 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.4.0 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.3.1 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.3.0 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.3.0.rc3 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.3.0.rc2 app/search_builders/sufia/admin_set_search_builder.rb
sufia-7.3.0.rc1 app/search_builders/sufia/admin_set_search_builder.rb