Class: Spree::Admin::AdjustmentsController

Inherits:
ResourceController show all
Defined in:
app/controllers/spree/admin/adjustments_controller.rb

Instance Method Summary collapse

Methods inherited from ResourceController

belongs_to, create, #create, destroy, #destroy, #edit, #new, new_action, #update, update, #update_positions

Instance Method Details

#toggle_stateObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/spree/admin/adjustments_controller.rb', line 7

def toggle_state
  redirect_to admin_order_adjustments_path(@order) if @adjustment.finalized?

  if @adjustment.immutable?
    @adjustment.fire_state_event(:open)
    flash[:success] = Spree.t(:adjustment_successfully_opened)
  else
    @adjustment.fire_state_event(:close)
    flash[:success] = Spree.t(:adjustment_successfully_closed)
  end
  redirect_to admin_order_adjustments_path(@order)
end