Sha256: afbf5a431f5625b134852db6618f5337ec855a3ed8b51495baa92cb6151bc984

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class Spree::Admin::DownloadsController < Spree::Admin::ResourceController

  def index
    @downloads = Spree::Download.all
  end

  def new
    @download = Spree::Download.new
    initialize_lists
  end

  def edit
    @download = Spree::Download.find(params[:id])
    initialize_lists
  end

  def create
    @download = Spree::Download.new(params[:download])

    if @download.save
      redirect_to(admin_downloads_url)
    else
      initialize_lists
      render :action => "new"
    end
  end

  def update
    @download = Spree::Download.find(params[:id])

    if @download.update_attributes(params[:download])
      redirect_to(admin_downloads_url)
    else
      initialize_lists
      render :action => "new"
    end
  end

  def destroy
    @download = Spree::Download.find(params[:id])
    @download.destroy

    redirect_to(admin_downloads_url)
  end


  private

  def initialize_lists
    @downloads = Spree::Download.all
    @download_categories = Spree::DownloadCategory.all
    @languages = Language::ALL_LANGUAGES
    @products = Spree::Product.where(:is_printer => true)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_downloads-1.0.1 app/controllers/spree/admin/downloads_controller.rb