Skip to content

Instantly share code, notes, and snippets.

@sohara
Created April 25, 2013 18:21
Show Gist options
  • Save sohara/5461909 to your computer and use it in GitHub Desktop.
Save sohara/5461909 to your computer and use it in GitHub Desktop.
module Spree
module Admin
OrdersController.class_eval do
def other
end
def edit
raise StandarError
end
def update_cutsomer_type
logger.info "In update customer type"
end
def clone_replacement
order = Order.find_by_number!(params[:id])
order = order.clone_replacement
fire_event('spree.order.contents_changed', order: order)
redirect_to admin_order_path(order)
end
def update_and_finalize
order = Order.find_by_number!(params[:id])
order.update_attribute(:completed_at, DateTime.current)
if order.update! && order.next!
redirect_to admin_order_path(order), notice: t('update_and_finalize_success')
else
flash[:error] = t('update_and_finalize_failure')
redirect_to admin_order_path(order)
end
end
def process_shipments_csv
begin
result = CSVShippingProcessor.new(params[:csv_file]).process
flash[:notice] = "#{result[:processed]} line items processed successfully.\n #{result[:unprocessed]} line items could not be processed."
redirect_to admin_orders_path
rescue => e
logger.info "#{e.inspect}"
flash[:error] = "Your uploaded CSV file could not be parsed.".html_safe
flash[:error] += " The following problem was detected:<br><em>#{e.class}: #{e.message}</em>".html_safe unless e.message.blank?
redirect_to admin_orders_path
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment