Class: Spree::Admin::ShipmentsController

Inherits:
BaseController show all
Defined in:
app/controllers/spree/admin/shipments_controller.rb

Instance Method Summary collapse

Methods included from Core::ControllerHelpers::Common

included

Methods included from Core::ControllerHelpers::Auth

#current_ability, included, #redirect_back_or_default, #store_location, #try_spree_current_user, #unauthorized

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



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

#fireObject



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

#indexObject



8
9
10
11
# File 'app/controllers/spree/admin/shipments_controller.rb', line 8

def index
  @shipments = order.shipments
  respond_with(@shipments)
end

#newObject



13
14
15
16
# File 'app/controllers/spree/admin/shipments_controller.rb', line 13

def new
  build_shipment
  respond_with(shipment)
end

#updateObject



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]
    # 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[: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