Class: Bulkrax::EntriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Bulkrax::EntriesController
- Includes:
- Hyrax::ThemedLayoutController
- Defined in:
- app/controllers/bulkrax/entries_controller.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/bulkrax/entries_controller.rb', line 45 def destroy @entry = Entry.find(params[:id]) @status = "" begin work = @entry.factory&.find if work.present? work.destroy @entry.destroy @status = "Entry and work deleted" else @entry.destroy @status = "Entry deleted" end rescue StandardError => e @status = "Error: #{e.}" end item = @entry.importerexporter entry_path = item.class.to_s.include?('Importer') ? bulkrax.importer_entry_path(item.id, @entry.id) : bulkrax.exporter_entry_path(item.id, @entry.id) redirect_back fallback_location: entry_path, notice: @status end |
#show ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/bulkrax/entries_controller.rb', line 10 def show if params[:importer_id].present? show_importer elsif params[:exporter_id].present? show_exporter end end |
#update ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/bulkrax/entries_controller.rb', line 18 def update @entry = Entry.find(params[:id]) type = case @entry.type.downcase when /fileset/ 'file_set' when /collection/ 'collection' else 'work' end item = @entry.importerexporter # do not run counters as it loads the whole parser current_run = item.current_run(skip_counts: true) @entry.set_status_info('Pending', current_run) ScheduleRelationshipsJob.set(wait: 5.minutes).perform_later(importer_id: @entry.importer.id) if params[:destroy_first] "Bulkrax::DeleteAndImport#{type.camelize}Job".constantize.perform_later(@entry, current_run) else "Bulkrax::Import#{type.camelize}Job".constantize.perform_later(@entry.id, current_run.id) end entry_path = item.class.to_s.include?('Importer') ? bulkrax.importer_entry_path(item.id, @entry.id) : bulkrax.exporter_entry_path(item.id, @entry.id) redirect_back fallback_location: entry_path, notice: "Entry #{@entry.id} update has been queued" end |