Class: Forge::OrdersController
Instance Method Summary
collapse
#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor
#app_init
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 31
def create
@order = Order.new(params[:order])
if @order.save
flash[:notice] = 'Order was successfully created.'
redirect_to(forge_orders_path)
else
render :action => "new"
end
end
|
#destroy ⇒ Object
71
72
73
74
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 71
def destroy
@order.destroy
redirect_to(forge_orders_path)
end
|
#edit ⇒ Object
28
29
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 28
def edit
end
|
#fulfill ⇒ Object
50
51
52
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 50
def fulfill
mark_fulfillment(:action => "fulfill!", :success => "Order marked as fulfilled", :failure => "Error marking as fulfilled")
end
|
#index ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 4
def index
conditions = {"fulfill" => '=', "unfulfill" => '<>'}
unless params[:show].nil?
@orders = Order.not_pending.where("state #{conditions[params[:show]]} 'fulfilled'").order("created_at DESC") else
@orders = Order.not_pending.order("created_at DESC")
end
respond_to do |format|
format.html { @orders = @orders.paginate(:per_page => 10, :page => params[:page]).includes(:shipping_address, :billing_address) }
format.js {
@orders = @orders.where("orders.id = ? OR orders.state = ? OR addresses.first_name LIKE ? OR addresses.last_name LIKE ? OR addresses.email like ?", params[:q], params[:q], "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%").includes(:shipping_address, :billing_address)
render :partial => "order", :collection => @orders
}
end
end
|
#mark_fulfillment(opts = {}) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 58
def mark_fulfillment(opts = {})
order = Order.find(params[:id])
respond_to do |format|
if order.send(opts[:action])
format.js { render :nothing => true }
format.html { flash[:notice] = opts[:success] and redirect_to forge_orders_path }
else
format.js { render :status => 500 }
format.html { flash[:warning] = opts[:failure] and redirect_to forge_orders_path }
end
end
end
|
#new ⇒ Object
20
21
22
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 20
def new
@order = Order.new
end
|
#show ⇒ Object
24
25
26
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 24
def show
@order = Order.find(params[:id])
end
|
#unfulfill ⇒ Object
54
55
56
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 54
def unfulfill
mark_fulfillment(:action => "unfulfill!", :success => "Order no longer marked as fulfilled.", :failure => "Error marking as unfulfilled")
end
|
#update ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 41
def update
if @order.update_attributes(params[:order])
flash[:notice] = 'Order was successfully updated.'
redirect_to(forge_orders_path)
else
render :action => "edit"
end
end
|