Sha256: 89052150d475957268718c0a313bcb1019a5fe791ac8006018778f1443e86fca

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

module CurationConcerns
  # Overrides FilterSuppressed filter to hide documents marked as
  # suppressed when the current user is permitted to take no workflow
  # actions for the work's current state
  #
  # Assumes presence of `blacklight_params[:id]` and a SolrDocument
  # corresponding to that `:id` value
  module FilterSuppressedWithRoles
    extend ActiveSupport::Concern
    include CurationConcerns::FilterSuppressed

    # Skip the filter if the current user is permitted to take
    # workflow actions on the work corresponding to the SolrDocument
    # with id = `blacklight_params[:id]`
    def only_active_works(solr_parameters)
      return if user_has_active_workflow_role?
      super
    end

    private

      def current_work
        SolrDocument.find(blacklight_params[:id])
      end

      def user_has_active_workflow_role?
        CurationConcerns::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(user: current_ability.current_user, entity: current_work).any?
      rescue PowerConverter::ConversionError
        # The current_work doesn't have a sipity workflow entity
        false
      end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.7 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-2.0.0 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-2.0.0.rc2 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.6 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.5 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.4 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.3 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.2 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-2.0.0.rc1 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb
curation_concerns-1.7.1 app/search_builders/curation_concerns/filter_suppressed_with_roles.rb