Merge pull request #4578 from kshlyk/remove_soft_delete_from_product_and_variant_api

Removing duplicate API method soft_delete for both products and variants
This commit is contained in:
Luis Ramos
2020-01-14 11:32:10 +00:00
committed by GitHub
8 changed files with 37 additions and 114 deletions

View File

@@ -42,8 +42,8 @@ module Api
def destroy
authorize! :delete, Spree::Product
@product = find_product(params[:id])
@product.update_attribute(:deleted_at, Time.zone.now)
@product.variants_including_master.update_all(deleted_at: Time.zone.now)
authorize! :delete, @product
@product.destroy
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
end
@@ -71,14 +71,6 @@ module Api
render_paged_products @products
end
def soft_delete
authorize! :delete, Spree::Product
@product = find_product(params[:product_id])
authorize! :delete, @product
@product.destroy
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
end
# POST /api/products/:product_id/clone
#
def clone

View File

@@ -35,18 +35,12 @@ module Api
end
end
def soft_delete
@variant = scope.find(params[:variant_id])
authorize! :delete, @variant
VariantDeleter.new.delete(@variant)
render json: @variant, serializer: Api::VariantSerializer, status: :no_content
end
def destroy
authorize! :delete, Spree::Variant
@variant = scope.find(params[:id])
@variant.destroy
authorize! :delete, @variant
VariantDeleter.new.delete(@variant)
render json: @variant, serializer: Api::VariantSerializer, status: :no_content
end