Skip to content

Commit

Permalink
only uses admin sets if Hyrax is present (#739)
Browse files Browse the repository at this point in the history
only uses admin sets in importer creation if Bulkrax is installed in a Hyrax instance.
  • Loading branch information
sephirothkod authored Feb 14, 2023
1 parent a0f929a commit 04d1c32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/helpers/bulkrax/importers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Bulkrax
module ImportersHelper
# borrowd from batch-importer https://github.com/samvera-labs/hyrax-batch_ingest/blob/main/app/controllers/hyrax/batch_ingest/batches_controller.rb
# borrowed from batch-importer https://github.com/samvera-labs/hyrax-batch_ingest/blob/main/app/controllers/hyrax/batch_ingest/batches_controller.rb
def available_admin_sets
# Restrict available_admin_sets to only those current user can desposit to.
# Restrict available_admin_sets to only those current user can deposit to.
@available_admin_sets ||= Hyrax::Collections::PermissionsService.source_ids_for_deposit(ability: current_ability, source_type: 'admin_set').map do |admin_set_id|
[AdminSet.find(admin_set_id).title.first, admin_set_id]
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/bulkrax/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Importer < ApplicationRecord
has_many :entries, as: :importerexporter, dependent: :destroy

validates :name, presence: true
validates :admin_set_id, presence: true
validates :admin_set_id, presence: true if defined?(::Hyrax)
validates :parser_klass, presence: true

delegate :valid_import?, :write_errored_entries_file, :visibility, to: :parser
Expand Down
2 changes: 1 addition & 1 deletion app/views/bulkrax/importers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= form.input :name, input_html: { class: 'form-control' } %>
<%= form.input :admin_set_id, collection: available_admin_sets %>
<%= form.input :admin_set_id, collection: available_admin_sets if defined?(::Hyrax) %>
<%= form.hidden_field :user_id, value: current_user.id %>
Expand Down

0 comments on commit 04d1c32

Please sign in to comment.