Sha256: 827e787d21b0c9eab66be9c716a8e1ff4b5058ade28de6bc4196cf71c0551a49

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

module Caboose
  class ShippingAddressesController < Caboose::ApplicationController
            
    # GET /admin/orders/:order_id/shipping-address/json
    def admin_json
      return if !user_is_allowed('orders', 'edit')    
      order = Order.find(params[:order_id])      
      render :json => order.shipping_address      
    end
      
    # PUT /admin/orders/:order_id/shipping-address
    def admin_update
      return if !user_is_allowed('orders', 'edit')
      
      resp = Caboose::StdClass.new({'attributes' => {}})
      order = Order.find(params[:order_id])    
      sa = order.shipping_address
      
      save = true    
      params.each do |name, value|
        case name          
          when 'name'           then sa.name          = value          
          when 'first_name'     then sa.first_name    = value
          when 'last_name'      then sa.last_name     = value
          when 'street'         then sa.street        = value
          when 'address1'       then sa.address1      = value
          when 'address2'       then sa.address2      = value
          when 'company'        then sa.company       = value
          when 'city'           then sa.city          = value
          when 'state'          then sa.state         = value
          when 'province'       then sa.province      = value
          when 'province_code'  then sa.province_code = value
          when 'zip'            then sa.zip           = value
          when 'country'        then sa.country       = value
          when 'country_code'   then sa.country_code  = value
          when 'phone'          then sa.phone         = value
        end
      end                
      resp.success = save && sa.save      
      render :json => resp
    end
        
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
caboose-cms-0.5.162 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.161 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.160 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.159 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.158 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.156 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.155 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.154 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.153 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.152 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.151 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.150 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.149 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.148 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.147 app/controllers/caboose/shipping_addresses_controller.rb
caboose-cms-0.5.146 app/controllers/caboose/shipping_addresses_controller.rb