app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.0.0.rc2 vs app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.0.0.rc3
- old
+ new
@@ -3,13 +3,12 @@
module Spotlight
##
# CRUD actions for curating browse categories (see
# {Spotlight::BrowseController} for the end-user read and index actions)
class SearchesController < Spotlight::ApplicationController
- load_resource :exhibit, class: 'Spotlight::Exhibit'
+ load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit', parent_action: :curate
before_action :authenticate_user!
- before_action :only_curators!
before_action :create_or_load_resource, only: [:create]
load_and_authorize_resource through: :exhibit
before_action :attach_breadcrumbs, only: %i[index edit], unless: -> { request.format.json? }
include Spotlight::Base
@@ -26,10 +25,11 @@
redirect_back fallback_location: fallback_url, alert: @search.errors.full_messages.join('<br>'.html_safe)
end
end
def index
+ @groups = @exhibit.groups
respond_to do |format|
format.html
format.json do
render json: @searches.as_json(methods: %i[full_title count thumbnail_image_url]), root: false
end
@@ -48,10 +48,11 @@
end
end
end
def edit
+ @groups = @exhibit.groups
add_breadcrumb @search.full_title, edit_exhibit_search_path(@search.exhibit, @search)
@exhibit = @search.exhibit
end
def update
@@ -107,31 +108,17 @@
:title,
:subtitle,
:long_description,
:search_box,
:default_index_view_type,
+ group_ids: [],
masthead_attributes: featured_image_params,
thumbnail_attributes: featured_image_params
)
end
def query_params
params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
- end
-
- def featured_image_params
- %i[
- iiif_region iiif_tilesource
- iiif_manifest_url iiif_canvas_id iiif_image_id
- display
- source
- image
- document_global_id
- ]
- end
-
- def only_curators!
- authorize! :curate, @exhibit if @exhibit
end
def blacklisted_search_session_params
%i[id commit counter total search_id page per_page authenticity_token utf8 action controller]
end