Class: Comable::Admin::OrdersController

Inherits:
ApplicationController show all
Includes:
PermittedAttributes
Defined in:
app/controllers/comable/admin/orders_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #respond_to_export_with

Instance Method Details

#cancelObject



38
39
40
41
42
43
# File 'app/controllers/comable/admin/orders_controller.rb', line 38

def cancel
  @order.cancel!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#cancel_paymentObject



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

def cancel_payment
  @order.payment.cancel!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#cancel_shipmentObject



73
74
75
76
77
78
# File 'app/controllers/comable/admin/orders_controller.rb', line 73

def cancel_shipment
  @order.shipment.cancel!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#editObject



18
19
# File 'app/controllers/comable/admin/orders_controller.rb', line 18

def edit
end

#exportObject



30
31
32
33
34
35
36
# File 'app/controllers/comable/admin/orders_controller.rb', line 30

def export
  q = Comable::Order.complete.ransack(params[:q])
  orders = q.result.recent.accessible_by(current_ability)
  order_items = Comable::OrderItem.joins(:order).merge(orders)

  respond_to_export_with order_items
end

#indexObject



10
11
12
13
# File 'app/controllers/comable/admin/orders_controller.rb', line 10

def index
  @q = Comable::Order.complete.ransack(params[:q])
  @orders = @q.result.page(params[:page]).per(15).recent.accessible_by(current_ability)
end

#resumeObject



45
46
47
48
49
50
# File 'app/controllers/comable/admin/orders_controller.rb', line 45

def resume
  @order.resume!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#resume_paymentObject



59
60
61
62
63
64
# File 'app/controllers/comable/admin/orders_controller.rb', line 59

def resume_payment
  @order.payment.resume!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#resume_shipmentObject



80
81
82
83
84
85
# File 'app/controllers/comable/admin/orders_controller.rb', line 80

def resume_shipment
  @order.shipment.resume!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#shipObject



66
67
68
69
70
71
# File 'app/controllers/comable/admin/orders_controller.rb', line 66

def ship
  @order.shipment.ship!
  redirect_to :back, notice: Comable.t('successful')
rescue ActiveRecord::RecordInvalid => e
  redirect_to :back, alert: e.message
end

#showObject



15
16
# File 'app/controllers/comable/admin/orders_controller.rb', line 15

def show
end

#updateObject



21
22
23
24
25
26
27
28
# File 'app/controllers/comable/admin/orders_controller.rb', line 21

def update
  if @order.update_attributes(order_params)
    redirect_to comable.admin_order_path(@order), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :edit
  end
end