Class: Admin::OrdersController

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

Instance Method Summary collapse

Instance Method Details

#fireObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/admin/orders_controller.rb', line 36

def fire
  # TODO - possible security check here but right now any admin can before any transition (and the state machine
  # itself will make sure transitions are not applied in the wrong state)
  event = params[:e]
  if @order.send("#{event}")
    flash.notice = t('order_updated')
  else
    flash[:error] = t('cannot_perform_operation')
  end
rescue Spree::GatewayError => ge
  flash[:error] = "#{ge.message}"
ensure
  redirect_to :back
end

#newObject



32
33
34
# File 'app/controllers/admin/orders_controller.rb', line 32

def new
  @order = @object = Order.create
end

#resendObject



51
52
53
54
55
# File 'app/controllers/admin/orders_controller.rb', line 51

def resend
  OrderMailer.confirm_email(@order, true).deliver
  flash.notice = t('order_email_resent')
  redirect_to :back
end

#userObject



57
58
59
60
# File 'app/controllers/admin/orders_controller.rb', line 57

def user
  @order.build_bill_address(:country_id => Spree::Config[:default_country_id]) if @order.bill_address.nil?
  @order.build_ship_address(:country_id => Spree::Config[:default_country_id]) if @order.ship_address.nil?
end