Module: Hyrax::EmbargoesControllerBehavior

Extended by:
ActiveSupport::Concern
Includes:
Collections::AcceptsBatches, ManagesEmbargoes
Included in:
EmbargoesController
Defined in:
app/controllers/concerns/hyrax/embargoes_controller_behavior.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Collections::AcceptsBatches

#batch, #batch=, #check_for_empty_batch?

Methods included from ManagesEmbargoes

#deny_access

Class Method Details

.local_prefixesObject

This allows us to use the unauthorized template in curation_concerns/base



43
44
45
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 43

def self.local_prefixes
  ['hyrax/base']
end

Instance Method Details

#destroyObject

Removes a single embargo



15
16
17
18
19
20
21
22
23
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 15

def destroy
  Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
  flash[:notice] = curation_concern.embargo_history.last
  if curation_concern.work? && curation_concern.file_sets.present?
    redirect_to confirm_permission_path
  else
    redirect_to edit_embargo_path
  end
end

#editObject



47
48
49
50
51
52
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 47

def edit
  add_breadcrumb t(:'hyrax.controls.home'), root_path
  add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
  add_breadcrumb t(:'hyrax.embargoes.index.manage_embargoes'), hyrax.embargoes_path
  add_breadcrumb t(:'hyrax.embargoes.edit.embargo_update'), '#'
end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 7

def index
  add_breadcrumb t(:'hyrax.controls.home'), root_path
  add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
  add_breadcrumb t(:'hyrax.embargoes.index.manage_embargoes'), hyrax.embargoes_path
  authorize! :index, Hydra::AccessControls::Embargo
end

#updateObject

Updates a batch of embargos



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 26

def update
  filter_docs_with_edit_access!
  copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] }
  ActiveFedora::Base.find(batch).each do |curation_concern|
    Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
    # if the concern is a FileSet, set its visibility and skip the copy_visibility_to_files, which is built for Works
    if curation_concern.file_set?
      curation_concern.visibility = curation_concern.to_solr["visibility_after_embargo_ssim"]
      curation_concern.save!
    elsif copy_visibility.include?(curation_concern.id)
      curation_concern.copy_visibility_to_files
    end
  end
  redirect_to embargoes_path, notice: t('.embargo_deactivated')
end