app/controllers/curate/collections_controller.rb in curate-0.5.0 vs app/controllers/curate/collections_controller.rb in curate-0.5.1
- old
+ new
@@ -3,15 +3,19 @@
# Hydra::CollectionsControllerBehavior must come after Blacklight::Catalog
# so that the update method is overridden.
include Hydra::CollectionsControllerBehavior
include Hydra::AccessControlsEnforcement
include Curate::FieldsForAddToCollection
+ include Sufia::Noid
+
+ prepend_before_filter :normalize_identifier, only: [:show]
+
with_themed_layout '1_column'
add_breadcrumb 'Collections', lambda {|controller| controller.request.path }
- before_filter :authenticate_user!
+ before_filter :authenticate_user!, except: :show
before_filter :agreed_to_terms_of_service!
before_filter :force_update_user_profile!
rescue_from Hydra::AccessDenied, CanCan::AccessDenied do |exception|
case exception.action
@@ -32,11 +36,11 @@
# This applies appropriate access controls to all solr queries (the internal method of this is overidden bellow to only include edit files)
Curate::CollectionsController.solr_search_params_logic += [:add_access_controls_to_solr_params]
# This filters out objects that you want to exclude from search results, like FileAssets
Curate::CollectionsController.solr_search_params_logic += [:only_collections]
- skip_load_and_authorize_resource only: [:add_member_form, :add_member]
+ skip_load_and_authorize_resource only: [:add_member_form, :add_member, :remove_member]
before_filter :load_and_authorize_collectible, only: [:add_member_form, :add_member]
before_filter :load_and_authorize_collection, only: [:add_member_form, :add_member]
def new
@add_to_profile = params.delete(:add_to_profile)
@@ -54,9 +58,16 @@
flash[:notice] = "\"#{@collectible}\" has been added to \"#{@collection}\""
else
flash[:error] = 'Unable to add item to collection.'
end
redirect_to catalog_index_path
+ end
+
+ def remove_member
+ @collection = Collection.find(params[:id])
+ item = ActiveFedora::Base.find(params[:item_id], cast:true)
+ @collection.remove_member(item)
+ redirect_to collection_path(params[:id])
end
private
def load_and_authorize_collectible