Module: CurationConcerns::CollectionsControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Blacklight::AccessControls::Catalog, Blacklight::Base
- Included in:
- CollectionsController
- Defined in:
- app/controllers/concerns/curation_concerns/collections_controller_behavior.rb
Instance Method Summary collapse
- #after_create ⇒ Object
- #after_create_error ⇒ Object
- #after_destroy(id) ⇒ Object
- #after_destroy_error(id) ⇒ Object
- #after_update ⇒ Object
- #after_update_error ⇒ Object
- #collection ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#after_create ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 82 def after_create form respond_to do |format| ActiveFedora::SolrService.instance.conn.commit format.html { redirect_to collection_path(@collection), notice: 'Collection was successfully created.' } format.json { render json: @collection, status: :created, location: @collection } end end |
#after_create_error ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 91 def after_create_error form respond_to do |format| format.html { render action: 'new' } format.json { render json: @collection.errors, status: :unprocessable_entity } end end |
#after_destroy(id) ⇒ Object
139 140 141 142 143 144 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 139 def after_destroy(id) respond_to do |format| format.html { redirect_to search_catalog_path, notice: 'Collection was successfully deleted.' } format.json { render json: { id: id }, status: :destroyed, location: @collection } end end |
#after_destroy_error(id) ⇒ Object
146 147 148 149 150 151 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 146 def after_destroy_error(id) respond_to do |format| format.html { redirect_to search_catalog_path, notice: 'Collection could not be deleted.' } format.json { render json: { id: id }, status: :destroy_error, location: @collection } end end |
#after_update ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 110 def after_update if flash[:notice].nil? flash[:notice] = 'Collection was successfully updated.' end respond_to do |format| format.html { redirect_to collection_path(@collection) } format.json { render json: @collection, status: :updated, location: @collection } end end |
#after_update_error ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 120 def after_update_error form query_collection_members respond_to do |format| format.html { render action: 'edit' } format.json { render json: @collection.errors, status: :unprocessable_entity } end end |
#collection ⇒ Object
161 162 163 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 161 def collection action_name == 'show' ? @presenter : @collection end |
#create ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 100 def create @collection.(current_user.user_key) add_members_to_collection unless batch.empty? if @collection.save after_create else after_create_error end end |
#destroy ⇒ Object
153 154 155 156 157 158 159 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 153 def destroy if @collection.destroy after_destroy(params[:id]) else after_destroy_error(params[:id]) end end |
#edit ⇒ Object
75 76 77 78 79 80 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 75 def edit query_collection_members # this is used to populate the "add to a collection" action for the members @user_collections = find_collections_for_form form end |
#index ⇒ Object
59 60 61 62 63 64 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 59 def index # run the solr query to find the collections query = list_search_builder.with(params).query @response = repository.search(query) @document_list = @response.documents end |
#new ⇒ Object
66 67 68 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 66 def new form end |
#show ⇒ Object
70 71 72 73 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 70 def show presenter query_collection_members end |
#update ⇒ Object
130 131 132 133 134 135 136 137 |
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 130 def update process_member_changes if @collection.update(collection_params.except(:members)) after_update else after_update_error end end |