mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Merge branch 'master' of github.com:eaterprises/openfoodweb
This commit is contained in:
@@ -28,11 +28,14 @@ module Admin
|
||||
product_distribution = ProductDistribution.where(:enterprise_fee_id => @object).first
|
||||
if product_distribution
|
||||
p = product_distribution.product
|
||||
flash[:error] = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}."
|
||||
error = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}."
|
||||
|
||||
respond_with(@object) do |format|
|
||||
format.html { redirect_to collection_url }
|
||||
format.js { render text: flash[:error], status: 403 }
|
||||
format.html do
|
||||
flash[:error] = error
|
||||
redirect_to collection_url
|
||||
end
|
||||
format.js { render text: error, status: 403 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,19 +3,18 @@ module Spree
|
||||
ShippingMethodsController.class_eval do
|
||||
before_filter :do_not_destroy_referenced_shipping_methods, :only => :destroy
|
||||
|
||||
# This method was originally written because ProductDistributions referenced shipping
|
||||
# methods, and deleting a referenced shipping method would break all the reports that
|
||||
# queried it.
|
||||
# This has changed, and now all we're protecting is Orders, which is a spree resource.
|
||||
# Do we really need to protect it ourselves? Does spree do this, or provide some means
|
||||
# of preserving the shipping method information for past orders?
|
||||
def do_not_destroy_referenced_shipping_methods
|
||||
order = Order.where(:shipping_method_id => @object).first
|
||||
if order
|
||||
flash[:error] = "That shipping method cannot be deleted as it is referenced by an order: #{order.number}."
|
||||
redirect_to collection_url and return
|
||||
end
|
||||
|
||||
product_distribution = ProductDistribution.where(:shipping_method_id => @object).first
|
||||
if product_distribution
|
||||
p = product_distribution.product
|
||||
flash[:error] = "That shipping method cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}."
|
||||
redirect_to collection_url and return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user