Sha256: 2333e9178f0446222e2f60b9ba1b086ee062436014b37b82c2aa966e1e9e9178

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module Spotlight::Resources
  ##
  # Resources controller allowing curators to create new
  # exhibit resources from a list of DRUIDs.
  class DorHarvesterController < ApplicationController
    before_action :authenticate_user!
    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
    before_action :build_resource
    authorize_resource

    def create
      @resource.update(resource_params)

      if @resource.save_and_index
        redirect_to spotlight.admin_exhibit_catalog_index_path(current_exhibit)
      else
        redirect_to spotlight.new_exhibit_resource_path(current_exhibit)
      end
    end

    def update
      @resource.update(resource_params)

      if @resource.save_and_index
        redirect_to spotlight.admin_exhibit_catalog_index_path(current_exhibit)
      else
        redirect_to spotlight.new_exhibit_resource_path(current_exhibit)
      end
    end

    private

    def build_resource
      @resource = Spotlight::Resources::DorHarvester.instance(current_exhibit)
    end

    def resource_params
      params.require(:resources_dor_harvester).permit(:druid_list)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spotlight-dor-resources-1.0.1 app/controllers/spotlight/resources/dor_harvester_controller.rb
spotlight-dor-resources-1.0.0 app/controllers/spotlight/resources/dor_harvester_controller.rb
spotlight-dor-resources-0.6.2 app/controllers/spotlight/resources/dor_harvester_controller.rb
spotlight-dor-resources-0.6.1 app/controllers/spotlight/resources/dor_harvester_controller.rb