Class: Gluttonberg::Admin::AssetLibrary::AssetsBulkController

Inherits:
BaseController show all
Defined in:
app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_assets_in_bulkObject

add assets from zip folder



19
20
21
# File 'app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb', line 19

def add_assets_in_bulk
  @asset = Asset.new
end

#create_assets_in_bulkObject

create assets from zip



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb', line 24

def create_assets_in_bulk
  # process new asset_collection and merge into existing collections
  AssetCollection.process_new_collection_and_merge(params, current_user)
  @asset = Asset.new(params[:asset])
  if @asset.valid?
    @new_assets = AssetBulkImport.open_zip_file_and_make_assets(params[:asset], current_user)
    if @new_assets.blank?
      flash[:error] = "The zip file you uploaded does not have any valid files."
      prepare_to_edit
      render :action => :add_assets_in_bulk
    else
      flash[:notice] = "All valid assets have been successfully saved."
    end
  else
    prepare_to_edit
    flash[:error] = "The zip file you uploaded is not valid."
    render :action => :add_assets_in_bulk
  end
end

#destroy_assets_in_bulkObject



9
10
11
12
13
14
15
16
# File 'app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb', line 9

def destroy_assets_in_bulk
  @assets = Asset.where(:id => params[:asset_ids].split(",")).all
  @assets.each do |asset|
    authorize! :destroy, asset
    asset.destroy
  end
  redirect_to admin_asset_category_path(:category => 'all' , :page => 1 )
end