From 633331f125b87e68c7e0f29cb3f0eaa2463d07d9 Mon Sep 17 00:00:00 2001 From: Paul Carey Date: Sun, 24 Oct 2010 19:12:00 +0100 Subject: [PATCH 1/2] added delete all variants option to admin console --- app/controllers/admin/variants_controller_decorator.rb | 7 +++++++ app/views/admin/variants/index.html.erb | 7 +++++++ config/locales/en.yml | 2 ++ 3 files changed, 16 insertions(+) diff --git a/app/controllers/admin/variants_controller_decorator.rb b/app/controllers/admin/variants_controller_decorator.rb index cdc043e..0ecfbd4 100755 --- a/app/controllers/admin/variants_controller_decorator.rb +++ b/app/controllers/admin/variants_controller_decorator.rb @@ -5,4 +5,11 @@ def regenerate product.do_create_variants(:recreate) redirect_to :action => :index, :product_id => params[:product_id] end + + def delete_all + product = Product.find_by_permalink(params[:product_id]) + product.variants.delete_all + redirect_to :action => :index, :product_id => params[:product_id] + end + end \ No newline at end of file diff --git a/app/views/admin/variants/index.html.erb b/app/views/admin/variants/index.html.erb index 1be3fb8..5311557 100755 --- a/app/views/admin/variants/index.html.erb +++ b/app/views/admin/variants/index.html.erb @@ -5,6 +5,13 @@ :confirm => t(:regenerate_confirm), :style => "float: right" %> +<%= button_link_to t(:delete_all), + {:action => :delete_all, :product_id => params[:product_id]}, + :method => :post, + :icon => 'exclamation', + :confirm => t(:delete_confirm), + :style => "float: right" +%> <%= render :partial => 'admin/shared/product_sub_menu' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 96c7e5e..0288fd3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -7,4 +7,6 @@ en: variant_price: Variant price regenerate: "regenerate variants" regenerate_confirm: "This will wipe out all your current variants\nAre you sure?" + delete_all: "Delete All" + delete_confirm: "Are you really sure you want to delete all current variants?" From 669a05ac3affde76daabd13763e175393b3c62ca Mon Sep 17 00:00:00 2001 From: Paul Carey Date: Mon, 25 Oct 2010 20:53:20 +0100 Subject: [PATCH 2/2] added fix for when not tracking inventory levels --- app/controllers/orders_controller_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/orders_controller_decorator.rb b/app/controllers/orders_controller_decorator.rb index 966b997..7da0557 100755 --- a/app/controllers/orders_controller_decorator.rb +++ b/app/controllers/orders_controller_decorator.rb @@ -29,7 +29,7 @@ def enhanced_option_create_before end if params[:option_values] if quantity > 0 && variant - if quantity > variant.on_hand + if Spree::Config[:track_inventory_levels] && quantity > variant.on_hand flash[:error] = t(:stock_to_small) % [variant.on_hand] else @order.add_variant(variant, quantity)