Class: Nquery::CollectionsController
Constant Summary
AuthorizesCollection::COLLECTION_REQUIREMENTS
Instance Method Summary
collapse
#breadcrumbs, #set_breadcrumbs
Instance Method Details
#archive ⇒ Object
63
64
65
66
|
# File 'app/controllers/nquery/collections_controller.rb', line 63
def archive
@collection.archive!
redirect_to collections_path, notice: "Collection archived."
end
|
#create ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/nquery/collections_controller.rb', line 29
def create
@collection = Collection.new(collection_params.merge(kind: "standard", parent: @parent_collection))
@parent_collections = assignable_collections
if @collection.save
redirect_to collection_path(@collection), notice: "Collection created."
else
render :new, status: :unprocessable_content
end
end
|
#destroy ⇒ Object
58
59
60
61
|
# File 'app/controllers/nquery/collections_controller.rb', line 58
def destroy
@collection.destroy
redirect_to collections_path, notice: "Collection deleted."
end
|
#edit ⇒ Object
40
41
42
|
# File 'app/controllers/nquery/collections_controller.rb', line 40
def edit
@parent_collections = assignable_collections.reject { |c| c.id == @collection.id }
end
|
#index ⇒ Object
16
17
18
|
# File 'app/controllers/nquery/collections_controller.rb', line 16
def index
@collections = viewable_collections
end
|
#new ⇒ Object
24
25
26
27
|
# File 'app/controllers/nquery/collections_controller.rb', line 24
def new
@collection = Collection.new(kind: "standard", parent: @parent_collection)
@parent_collections = assignable_collections
end
|
#show ⇒ Object
20
21
22
|
# File 'app/controllers/nquery/collections_controller.rb', line 20
def show
load_collection_contents(@collection)
end
|
#unarchive ⇒ Object
68
69
70
71
|
# File 'app/controllers/nquery/collections_controller.rb', line 68
def unarchive
@collection.unarchive!
redirect_to collection_path(@collection), notice: "Collection unarchived."
end
|
#update ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/nquery/collections_controller.rb', line 44
def update
@parent_collections = assignable_collections.reject { |c| c.id == @collection.id }
if collection_params[:parent_id].present?
parent = Collection.find_by(id: collection_params[:parent_id])
authorize_collection_access!(parent, required: :curate) if parent
end
if @collection.update(collection_params)
redirect_to collection_path(@collection), notice: "Collection updated."
else
render :edit, status: :unprocessable_content
end
end
|