Skip to content

Commit

Permalink
Add controller action to destroy a PromotionBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdonarski committed Jan 10, 2024
1 parent bfc25e6 commit f8a617c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/controllers/spree/admin/promotion_batches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ def update
super
end

def destroy
result = Spree::PromotionBatches::Destroy.call(promotion_batch: @promotion_batch)

if result.success?
flash[:success] = flash_message_for(@promotion_batch, :successfully_removed)
else
flash[:error] = @promotion_batch.errors.full_messages.join(', ')
end

respond_with(@promotion_batch) do |format|
format.html { redirect_to location_after_destroy }
format.js { render_js_for_destroy }
end
end

def csv_export
send_data Spree::PromotionBatches::PromotionCodesExporter.new(params).call,
filename: "promo_codes_from_batch_id_#{params[:id]}.csv",
Expand Down

0 comments on commit f8a617c

Please sign in to comment.