Using resource controller and namespace

This commit is contained in:
Michael Gall
2011-12-19 18:46:11 +01:00
committed by future
parent 02fd4a64d1
commit 4ecf99a4ae
21 changed files with 84 additions and 69 deletions
@@ -1,10 +0,0 @@
class Admin::DigitalsController < Spree::Admin::ResourceController
index.before do
@product = Product.find_by_permalink(params[:product_id])
end
create.wants.html { redirect_to admin_product_digitals_url(@product) }
destroy.wants.html { redirect_to admin_product_digitals_url(@product) }
end
-16
View File
@@ -1,16 +0,0 @@
class DigitalsController < Spree::BaseController
ssl_required :show
def show
link = DigitalLink.find_by_secret(params[:secret])
if link.present? and link.digital.attachment.present?
attachment = link.digital.attachment
if link.authorize! and File.file?(attachment.path)
send_file attachment.path :filename => attachment.original_filename, :type => attachment.content_type and return
end
end
render :unauthorized
end
end
@@ -0,0 +1,15 @@
module Spree
class Admin::DigitalsController < Spree::Admin::ResourceController
belongs_to "spree/product", find_by: :permalink
def load_resource
@object = @product = Product.find_by_permalink(params[:product_id])
end
protected
def location_after_save
admin_product_digitals_url(@product)
end
end
end
@@ -0,0 +1,18 @@
module Spree
class DigitalsController < Spree::BaseController
ssl_required :show
def show
link = DigitalLink.find_by_secret(params[:secret])
if link.present? and link.digital.attachment.present?
attachment = link.digital.attachment
if link.authorize! and File.file?(attachment.path)
send_file attachment.path :filename => attachment.original_filename, :type => attachment.content_type and return
end
end
render :unauthorized
end
end
end