Module: Hydra::CollectionsControllerBehavior
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
53
54
55
56
57
58
59
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 53
def after_create
respond_to do |format|
ActiveFedora::SolrService.instance.conn.commit
format.html { redirect_to collections.collection_path(@collection), notice: 'Collection was successfully created.' }
format.json { render json: @collection, status: :created, location: @collection }
end
end
|
#after_create_error ⇒ Object
61
62
63
64
65
66
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 61
def after_create_error
respond_to do |format|
format.html { render action: "new" }
format.json { render json: @collection.errors, status: :unprocessable_entity }
end
end
|
#after_destroy(id) ⇒ Object
104
105
106
107
108
109
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 104
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
111
112
113
114
115
116
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 111
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
78
79
80
81
82
83
84
85
86
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 78
def after_update
if flash[:notice].nil?
flash[:notice] = 'Collection was successfully updated.'
end
respond_to do |format|
format.html { redirect_to collections.collection_path(@collection) }
format.json { render json: @collection, status: :updated, location: @collection }
end
end
|
#after_update_error ⇒ Object
88
89
90
91
92
93
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 88
def after_update_error
respond_to do |format|
format.html { render action: "edit" }
format.json { render json: @collection.errors, status: :unprocessable_entity }
end
end
|
#collection ⇒ Object
126
127
128
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 126
def collection
@collection
end
|
#create ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 68
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
118
119
120
121
122
123
124
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 118
def destroy
if @collection.destroy
after_destroy(params[:id])
else
after_destroy_error(params[:id])
end
end
|
#edit ⇒ Object
48
49
50
51
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 48
def edit
query_collection_members
find_collections
end
|
#index ⇒ Object
34
35
36
37
38
39
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 34
def index
query = collections_search_builder.with(params).query
@response = repository.search(query)
@document_list = @response.documents
end
|
#new ⇒ Object
41
42
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 41
def new
end
|
#show ⇒ Object
44
45
46
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 44
def show
query_collection_members
end
|
#update ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'app/controllers/concerns/hydra/collections_controller_behavior.rb', line 95
def update
process_member_changes
if @collection.update(collection_params.except(:members))
after_update
else
after_update_error
end
end
|