Class: Georgia::MediaController
Instance Method Summary
collapse
#current_ability, #current_locale
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/georgia/media_controller.rb', line 17
def create
authorize Ckeditor::Asset
begin
@assets = params[:assets].map{|asset| CreateMediaAsset.new(asset).call}
@assets = Ckeditor::AssetDecorator.decorate_collection(@assets)
rescue => ex
flash.now[:alert] = ex.message
end
render layout: false
end
|
#destroy ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'app/controllers/georgia/media_controller.rb', line 50
def destroy
@assets = Ckeditor::Asset.where(id: params[:id])
authorize @assets
if @assets.destroy_all
render_success("Assets were successfully deleted.")
else
render_error
end
end
|
#download ⇒ Object
Download multiple assets as a zip file TODO: We could send via AJAX with jquery.fileDownload plugin We could then have a download spinner while the request is processing, even a progress bar
63
64
65
66
67
68
69
|
# File 'app/controllers/georgia/media_controller.rb', line 63
def download
ids = params[:ids].split(',')
@files = Ckeditor::Asset.where(id: ids)
authorize @files
zip_file = Georgia::CompressFiles.new(@files).file
send_file zip_file.path, type: "application/zip", disposition: 'attachment', filename: zip_file.filename
end
|
#edit ⇒ Object
34
35
36
37
|
# File 'app/controllers/georgia/media_controller.rb', line 34
def edit
@asset = Ckeditor::Asset.find(params[:id])
authorize @asset
end
|
#index ⇒ Object
4
5
6
7
|
# File 'app/controllers/georgia/media_controller.rb', line 4
def index
authorize Ckeditor::Asset
redirect_to action: :search
end
|
#show ⇒ Object
28
29
30
31
32
|
# File 'app/controllers/georgia/media_controller.rb', line 28
def show
@asset = Ckeditor::Asset.find(params[:id])
authorize @asset
redirect_to edit_media_path(id: params[:id])
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/georgia/media_controller.rb', line 39
def update
@asset = Ckeditor::Asset.find(params[:id])
authorize @asset
if @asset.update_attributes(sanitized_asset_params)
render_success("Asset was successfully updated.")
else
render_error
end
end
|