Class: Spree::Admin::PromotionActionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/promotion_actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/spree/admin/promotion_actions_controller.rb', line 2

def create
  @calculators = Spree::Promotion::Actions::CreateAdjustment.calculators
  @promotion = Spree::Promotion.find(params[:promotion_id])
  @promotion_action = params[:action_type].constantize.new(params[:promotion_action])
  @promotion_action.promotion = @promotion
  if @promotion_action.save
    flash[:success] = I18n.t(:successfully_created, :resource => I18n.t(:promotion_action))
  end
  respond_to do |format|
    format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
    format.js   { render :layout => false }
  end
end

#destroyObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/admin/promotion_actions_controller.rb', line 16

def destroy
  @promotion = Spree::Promotion.find(params[:promotion_id])
  @promotion_action = @promotion.promotion_actions.find(params[:id])
  if @promotion_action.destroy
    flash[:success] = I18n.t(:successfully_removed, :resource => I18n.t(:promotion_action))
  end
  respond_to do |format|
    format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
    format.js   { render :layout => false }
  end
end