Module: CurationConcerns::CollectionsControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Blacklight::AccessControls::Catalog, Blacklight::Base, SelectsCollections
- Included in:
- CollectionsController
- Defined in:
- app/controllers/concerns/curation_concerns/collections_controller_behavior.rb
Instance Method Summary
collapse
#access_levels, #collections_search_builder, #collections_search_builder_class, #find_collections, #find_collections_with_edit_access, #find_collections_with_read_access
Instance Method Details
#after_create ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 62
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
71
72
73
74
75
76
77
78
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 71
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
119
120
121
122
123
124
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 119
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
126
127
128
129
130
131
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 126
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
90
91
92
93
94
95
96
97
98
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 90
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
100
101
102
103
104
105
106
107
108
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 100
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
141
142
143
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 141
def collection
action_name == 'show' ? @presenter : @collection
end
|
#create ⇒ Object
80
81
82
83
84
85
86
87
88
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 80
def create
@collection.apply_depositor_metadata(current_user.user_key)
add_members_to_collection unless batch.empty?
if @collection.save
after_create
else
after_create_error
end
end
|
#destroy ⇒ Object
133
134
135
136
137
138
139
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 133
def destroy
if @collection.destroy
after_destroy(params[:id])
else
after_destroy_error(params[:id])
end
end
|
#edit ⇒ Object
56
57
58
59
60
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 56
def edit
query_collection_members
find_collections
form
end
|
#index ⇒ Object
40
41
42
43
44
45
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 40
def index
query = collections_search_builder.with(params).query
@response = repository.search(query)
@document_list = @response.documents
end
|
#new ⇒ Object
47
48
49
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 47
def new
form
end
|
#show ⇒ Object
51
52
53
54
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 51
def show
presenter
query_collection_members
end
|
#update ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb', line 110
def update
process_member_changes
if @collection.update(collection_params.except(:members))
after_update
else
after_update_error
end
end
|