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
-
.local_prefixes ⇒ Object
This allows us to use the unauthorized template in curation_concerns/base.
Instance Method Summary collapse
-
#destroy ⇒ Object
Removes a single embargo.
- #edit ⇒ Object
- #index ⇒ Object
-
#update ⇒ Object
Updates a batch of embargos rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity.
Methods included from Collections::AcceptsBatches
#batch, #batch=, #check_for_empty_batch?
Methods included from ManagesEmbargoes
Class Method Details
.local_prefixes ⇒ Object
This allows us to use the unauthorized template in curation_concerns/base
64 65 66 |
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 64 def self.local_prefixes ['hyrax/base'] end |
Instance Method Details
#destroy ⇒ Object
Removes a single embargo
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 16 def destroy Hyrax::Actors::EmbargoActor.new(curation_concern).destroy flash[:notice] = (curation_concern).last if curation_concern.work? && work_has_file_set_members?(curation_concern) redirect_to else redirect_to end end |
#edit ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 68 def edit @curation_concern = Hyrax::Forms::WorkEmbargoForm.new(curation_concern).prepopulate! if Hyrax.config.use_valkyrie? t(:'hyrax.controls.home'), root_path t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path t(:'hyrax.embargoes.index.manage_embargoes'), hyrax. t(:'hyrax.embargoes.edit.embargo_update'), '#' end |
#index ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 8 def index t(:'hyrax.controls.home'), root_path t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path t(:'hyrax.embargoes.index.manage_embargoes'), hyrax. :index, Hydra::AccessControls::Embargo end |
#update ⇒ Object
Updates a batch of embargos rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/concerns/hyrax/embargoes_controller_behavior.rb', line 30 def update filter_docs_with_edit_access! copy_visibility = [] copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] } if params[:embargoes] resources = if Hyrax.config.use_valkyrie? Hyrax.query_service.find_many_by_ids(ids: batch) else Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: false) end resources.each do |resource| if Hyrax.config.use_valkyrie? EmbargoManager.new(resource: resource).release! Hyrax::AccessControlList(resource).save Hyrax::VisibilityPropagator.for(source: resource).propagate if copy_visibility.include?(resource.id) else Hyrax::Actors::EmbargoActor.new(resource).destroy # if the concern is a FileSet, set its visibility and visibility propagation if resource.file_set? resource.visibility = resource.to_solr["visibility_after_embargo_ssim"] resource.save! elsif copy_visibility.include?(resource.id) Hyrax::VisibilityPropagator.for(source: resource).propagate end end end redirect_to , notice: t('.embargo_deactivated') end |