Class: Spree::Admin::ShipmentsController
Instance Method Summary
collapse
included
#current_ability, included, #redirect_back_or_default, #store_location, #try_spree_current_user, #unauthorized
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 18
def create
build_shipment
assign_inventory_units
if shipment.save
flash[:success] = flash_message_for(shipment, :successfully_created)
respond_with(shipment) do |format|
format.html { redirect_to edit_admin_order_shipment_path(order, shipment) }
end
else
respond_with(shipment) { |format| format.html { render :action => 'new' } }
end
end
|
#destroy ⇒ Object
54
55
56
57
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 54
def destroy
shipment.destroy
respond_with(shipment) { |format| format.js { render_js_for_destroy } }
end
|
#edit ⇒ Object
31
32
33
34
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 31
def edit
shipment.special_instructions = order.special_instructions
respond_with(shipment)
end
|
#fire ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 59
def fire
if shipment.send("#{params[:e]}")
flash[:success] = t(:shipment_updated)
else
flash[:error] = t(:cannot_perform_operation)
end
respond_with(shipment) { |format| format.html { redirect_to :back } }
end
|
#index ⇒ Object
8
9
10
11
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 8
def index
@shipments = order.shipments
respond_with(@shipments)
end
|
#new ⇒ Object
13
14
15
16
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 13
def new
build_shipment
respond_with(shipment)
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/spree/admin/shipments_controller.rb', line 36
def update
assign_inventory_units
if shipment.update_attributes params[:shipment]
order.special_instructions = params[:shipment][:special_instructions] if Spree::Config[:shipping_instructions]
order.shipping_method = order.shipment.shipping_method
order.save
flash[:success] = flash_message_for(shipment, :successfully_updated)
return_path = order.completed? ? edit_admin_order_shipment_path(order, shipment) : admin_order_adjustments_path(order)
respond_with(@object) do |format|
format.html { redirect_to return_path }
end
else
respond_with(shipment) { |format| format.html { render :action => 'edit' } }
end
end
|