Sha256: 51e1461db75406c84cf4ea47b8018596abe66fdf312eed482341261a3c57669e
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
module Spotlight ## # CRUD actions for exhibit resources class ResourcesController < Spotlight::ApplicationController before_action :authenticate_user!, except: [:show] load_and_authorize_resource :exhibit, class: Spotlight::Exhibit before_action :build_resource, only: [:create] load_and_authorize_resource through: :exhibit helper_method :from_popup? def new @resource.attributes = resource_params if params[:resource] @resource = @resource.becomes_provider ## TODO: in Rails 4.1, replace this with a variant if from_popup? render layout: 'spotlight/popup' else render end end # rubocop:disable Metrics/MethodLength def create @resource.attributes = resource_params @resource = @resource.becomes_provider if @resource.save_and_commit if from_popup? render layout: false, text: '<html><script>window.close();</script></html>' else redirect_to admin_exhibit_catalog_index_path(@resource.exhibit, sort: :timestamp) end else render action: 'new' end end # rubocop:enable Metrics/MethodLength def reindex_all @exhibit.reindex_later redirect_to admin_exhibit_catalog_index_path(@exhibit), notice: t(:'spotlight.resources.reindexing_in_progress') end protected def resource_params params.require(:resource).permit(:url, data: params[:resource][:data].try(:keys)) end def build_resource @resource ||= @exhibit.resources.build(resource_params).becomes_provider end def from_popup? params.fetch(:popup, false) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blacklight-spotlight-0.6.0 | app/controllers/spotlight/resources_controller.rb |
blacklight-spotlight-0.5.0 | app/controllers/spotlight/resources_controller.rb |