Class: Spree::Admin::ShipmentsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- BaseController
- Spree::Admin::ShipmentsController
- Defined in:
- app/controllers/spree/admin/shipments_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #fire ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods included from Core::ControllerHelpers
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 23 def create build_shipment assign_inventory_units if @shipment.save flash[:notice] = (@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
59 60 61 62 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 59 def destroy @shipment.destroy respond_with(@shipment) { |format| format.js { render_js_for_destroy } } end |
#edit ⇒ Object
36 37 38 39 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 36 def edit @shipment.special_instructions = @order.special_instructions respond_with(@shipment) end |
#fire ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 64 def fire if @shipment.send("#{params[:e]}") flash.notice = t(:shipment_updated) else flash[:error] = t(:cannot_perform_operation) end respond_with(@shipment) { |format| format.html { redirect_to :back } } end |
#index ⇒ Object
10 11 12 13 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 10 def index @shipments = @order.shipments respond_with(@shipments) end |
#new ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 15 def new build_shipment @shipment.address ||= @order.ship_address @shipment.address ||= Address.new(:country_id => Spree::Config[:default_country_id]) @shipment.shipping_method = @order.shipping_method respond_with(@shipment) end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/spree/admin/shipments_controller.rb', line 41 def update assign_inventory_units if @shipment.update_attributes params[:shipment] # copy back to order if instructions are enabled @order.special_instructions = params[:shipment][:special_instructions] if Spree::Config[:shipping_instructions] @order.shipping_method = @order.shipment.shipping_method @order.save flash[:notice] = (@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 |