Sha256: 37f579671af6e7305718355dbb85affb52ddcde2964c69e05218fc915eac1912

Contents?: true

Size: 1.8 KB

Versions: 9

Compression:

Stored size: 1.8 KB

Contents

class Admin::OrdersController < Admin::BaseController
  require 'spree/gateway_error'
  resource_controller
  before_filter :initialize_txn_partials
  before_filter :initialize_order_events
  before_filter :load_object, :only => [:fire, :resend]

  in_place_edit_for :user, :email

  def fire   
    # TODO - possible security check here but right now any admin can before any transition (and the state machine 
    # itself will make sure transitions are not applied in the wrong state)
    event = params[:e]
    Order.transaction do 
      @order.state_events.create(:name => t(event), :user => current_user, :previous_state => @order.state)
      @order.send("#{event}!")
    end
    flash[:notice] = t('order_updated')
  rescue Spree::GatewayError => ge
    flash[:error] = "#{ge.message}"
  ensure
    redirect_to :back
  end
  
  def resend
    OrderMailer.deliver_confirm(@order, true)
    flash[:notice] = t('order_email_resent')
    redirect_to :back
  end
  
  private

  def collection
    @search = Order.new_search(params[:search])

    if params[:search].nil? || params[:search][:conditions].nil?
      @search.conditions.checkout_complete = true
    end

    #set order by to default or form result
    @search.order_by ||= :created_at
    @search.order_as ||= "DESC"
    #set results per page to default or form result
    @search.per_page = Spree::Config[:orders_per_page]

    @collection = @search.find(:all, :include => [:user, :shipments, {:creditcards => :address}] )
  end

  # Allows extensions to add new forms of payment to provide their own display of transactions
  def initialize_txn_partials
    @txn_partials = []
  end
  
  # Used for extensions which need to provide their own custom event links on the order details view.
  def initialize_order_events
    @order_events = %w{cancel resume}
  end
  

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
kdmny-spree-0.0.1 app/controllers/admin/orders_controller.rb
spree-0.8.4 app/controllers/admin/orders_controller.rb
spree-0.8.5 app/controllers/admin/orders_controller.rb
spree-0.7.0 app/controllers/admin/orders_controller.rb
spree-0.7.1 app/controllers/admin/orders_controller.rb
spree-0.8.0 app/controllers/admin/orders_controller.rb
spree-0.8.1 app/controllers/admin/orders_controller.rb
spree-0.8.2 app/controllers/admin/orders_controller.rb
spree-0.8.3 app/controllers/admin/orders_controller.rb