opensteam 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +0 -0
- data/License.txt +4 -0
- data/Manifest.txt +131 -0
- data/Manifest.txt.bak +132 -0
- data/README.txt +92 -0
- data/generators/opensteam/opensteam_generator.rb +295 -0
- data/generators/opensteam/templates/controllers/administration/customers_controller.rb +23 -0
- data/generators/opensteam/templates/controllers/administration/inventories_controller.rb +88 -0
- data/generators/opensteam/templates/controllers/administration/orders_controller.rb +61 -0
- data/generators/opensteam/templates/controllers/administration_controller.rb +80 -0
- data/generators/opensteam/templates/controllers/checkout_controller.rb +142 -0
- data/generators/opensteam/templates/controllers/webshop_controller.rb +68 -0
- data/generators/opensteam/templates/fixtures/inventories.yml +221 -0
- data/generators/opensteam/templates/fixtures/inventories_properties.yml +127 -0
- data/generators/opensteam/templates/fixtures/product_animals.yml +73 -0
- data/generators/opensteam/templates/fixtures/product_dog_foods.yml +7 -0
- data/generators/opensteam/templates/fixtures/properties.yml +42 -0
- data/generators/opensteam/templates/helpers/webshop_helper.rb +29 -0
- data/generators/opensteam/templates/init/opensteam.rb +30 -0
- data/generators/opensteam/templates/migrations/create_addresses.rb +17 -0
- data/generators/opensteam/templates/migrations/create_customers.rb +16 -0
- data/generators/opensteam/templates/migrations/create_dummy_users.rb +16 -0
- data/generators/opensteam/templates/migrations/create_inventories.rb +20 -0
- data/generators/opensteam/templates/migrations/create_inventories_properties.rb +14 -0
- data/generators/opensteam/templates/migrations/create_order_items.rb +16 -0
- data/generators/opensteam/templates/migrations/create_orders.rb +18 -0
- data/generators/opensteam/templates/migrations/create_payment_types.rb +13 -0
- data/generators/opensteam/templates/migrations/create_properties.rb +12 -0
- data/generators/opensteam/templates/migrations/create_sessions.rb +16 -0
- data/generators/opensteam/templates/migrations/create_users.rb +19 -0
- data/generators/opensteam/templates/models/administration_mailer.rb +18 -0
- data/generators/opensteam/templates/models/inventories_property.rb +10 -0
- data/generators/opensteam/templates/models/inventory.rb +57 -0
- data/generators/opensteam/templates/public/images/bullet_arrow_down.png +0 -0
- data/generators/opensteam/templates/public/images/bullet_arrow_up.png +0 -0
- data/generators/opensteam/templates/public/images/cancel.png +0 -0
- data/generators/opensteam/templates/public/images/folder_database.png +0 -0
- data/generators/opensteam/templates/public/images/indicator.gif +0 -0
- data/generators/opensteam/templates/public/images/indicator_big.gif +0 -0
- data/generators/opensteam/templates/public/images/minus.png +0 -0
- data/generators/opensteam/templates/public/images/opensteam_logo_small.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_logo_web.jpg +0 -0
- data/generators/opensteam/templates/public/images/palette.png +0 -0
- data/generators/opensteam/templates/public/images/plus.png +0 -0
- data/generators/opensteam/templates/public/images/rails.png +0 -0
- data/generators/opensteam/templates/public/index.html +297 -0
- data/generators/opensteam/templates/public/stylesheets/webshop.css +262 -0
- data/generators/opensteam/templates/tasks/opensteam.rake +114 -0
- data/generators/opensteam/templates/views/administration/_address.html.erb +4 -0
- data/generators/opensteam/templates/views/administration/_nav.html.erb +11 -0
- data/generators/opensteam/templates/views/administration/_update_tree.html.erb +18 -0
- data/generators/opensteam/templates/views/administration/admin_info.html.erb +12 -0
- data/generators/opensteam/templates/views/administration/customers.html.erb +44 -0
- data/generators/opensteam/templates/views/administration/customers/index.html.erb +27 -0
- data/generators/opensteam/templates/views/administration/customers/show.html.erb +27 -0
- data/generators/opensteam/templates/views/administration/index.html.erb +9 -0
- data/generators/opensteam/templates/views/administration/inventories/edit.html.erb +48 -0
- data/generators/opensteam/templates/views/administration/inventories/index.html.erb +27 -0
- data/generators/opensteam/templates/views/administration/inventories/new.html.erb +41 -0
- data/generators/opensteam/templates/views/administration/inventories/show.html.erb +45 -0
- data/generators/opensteam/templates/views/administration/login.html.erb +16 -0
- data/generators/opensteam/templates/views/administration/order.html.erb +22 -0
- data/generators/opensteam/templates/views/administration/orders.html.erb +32 -0
- data/generators/opensteam/templates/views/administration/orders/_order_item.html.erb +22 -0
- data/generators/opensteam/templates/views/administration/orders/index.html.erb +32 -0
- data/generators/opensteam/templates/views/administration/orders/show.html.erb +25 -0
- data/generators/opensteam/templates/views/administration/products.html.erb +7 -0
- data/generators/opensteam/templates/views/administration/properties.html.erb +7 -0
- data/generators/opensteam/templates/views/administration/show_order_item.html.erb +5 -0
- data/generators/opensteam/templates/views/administration/signup.html.erb +65 -0
- data/generators/opensteam/templates/views/administration/tree.html.erb +15 -0
- data/generators/opensteam/templates/views/administration/update_products.html.erb +5 -0
- data/generators/opensteam/templates/views/administration/update_properties.html.erb +5 -0
- data/generators/opensteam/templates/views/administration/update_tree.rjs +3 -0
- data/generators/opensteam/templates/views/administration_mailer/order_admin.erb +27 -0
- data/generators/opensteam/templates/views/administration_mailer/order_customer.erb +24 -0
- data/generators/opensteam/templates/views/checkout/intro.html.erb +5 -0
- data/generators/opensteam/templates/views/checkout/outro.html.erb +6 -0
- data/generators/opensteam/templates/views/checkout/payment.html.erb +8 -0
- data/generators/opensteam/templates/views/checkout/shipping.html.erb +39 -0
- data/generators/opensteam/templates/views/checkout/show_cart.html.erb +13 -0
- data/generators/opensteam/templates/views/checkout/update_cart_content.rjs +2 -0
- data/generators/opensteam/templates/views/common/_cart.html.erb +11 -0
- data/generators/opensteam/templates/views/common/_cart_content.html.erb +19 -0
- data/generators/opensteam/templates/views/common/_header.html.erb +15 -0
- data/generators/opensteam/templates/views/layouts/administration.html.erb +29 -0
- data/generators/opensteam/templates/views/layouts/webshop.html.erb +36 -0
- data/generators/opensteam/templates/views/webshop/_cart.html.erb +11 -0
- data/generators/opensteam/templates/views/webshop/_cart_content.html.erb +23 -0
- data/generators/opensteam/templates/views/webshop/_header.html.erb +15 -0
- data/generators/opensteam/templates/views/webshop/_inventory_content.html.erb +12 -0
- data/generators/opensteam/templates/views/webshop/add_inventory_to_cart.rjs +2 -0
- data/generators/opensteam/templates/views/webshop/add_to_cart_with_parameters.rjs +2 -0
- data/generators/opensteam/templates/views/webshop/del_item.rjs +1 -0
- data/generators/opensteam/templates/views/webshop/index.html.erb +12 -0
- data/generators/opensteam/templates/views/webshop/inventory.rjs +2 -0
- data/generators/opensteam/templates/views/webshop/show.html.erb +40 -0
- data/generators/opensteam_product/opensteam_product_generator.rb +115 -0
- data/generators/opensteam_product/templates/controllers/product_controller.rb +104 -0
- data/generators/opensteam_product/templates/migration.rb +16 -0
- data/generators/opensteam_product/templates/models/product.rb +3 -0
- data/generators/opensteam_product/templates/views/_attr_product.html.erb +8 -0
- data/generators/opensteam_product/templates/views/_attr_property.html.erb +9 -0
- data/generators/opensteam_product/templates/views/_details.html.erb +29 -0
- data/generators/opensteam_product/templates/views/administration/_attributes.html.erb +21 -0
- data/generators/opensteam_product/templates/views/administration/_get_products.html.erb +8 -0
- data/generators/opensteam_product/templates/views/administration/_inventories.html.erb +27 -0
- data/generators/opensteam_product/templates/views/administration/edit.html.erb +13 -0
- data/generators/opensteam_product/templates/views/administration/index.html.erb +36 -0
- data/generators/opensteam_product/templates/views/administration/new.html.erb +16 -0
- data/generators/opensteam_product/templates/views/administration/show.html.erb +15 -0
- data/generators/opensteam_property/opensteam_property_generator.rb +126 -0
- data/generators/opensteam_property/templates/controllers/property_controller.rb +86 -0
- data/generators/opensteam_property/templates/migration.rb +14 -0
- data/generators/opensteam_property/templates/models/property.rb +3 -0
- data/generators/opensteam_property/templates/views/administration/edit.html.erb +19 -0
- data/generators/opensteam_property/templates/views/administration/index.html.erb +24 -0
- data/generators/opensteam_property/templates/views/administration/new.html.erb +18 -0
- data/generators/opensteam_property/templates/views/administration/show.html.erb +10 -0
- data/lib/opensteam.rb +49 -0
- data/lib/opensteam/base.rb +121 -0
- data/lib/opensteam/checkout.rb +89 -0
- data/lib/opensteam/config.rb +31 -0
- data/lib/opensteam/finder.rb +145 -0
- data/lib/opensteam/inventory_base.rb +79 -0
- data/lib/opensteam/order_base.rb +58 -0
- data/lib/opensteam/product_base.rb +222 -0
- data/lib/opensteam/property_base.rb +63 -0
- data/lib/opensteam/shopping_cart.rb +343 -0
- data/lib/opensteam/user_base.rb +165 -0
- data/lib/opensteam/version.rb +9 -0
- data/test/test_helper.rb +2 -0
- data/test/test_opensteam.rb +11 -0
- metadata +189 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
class Administration::CustomersController < AdministrationController
|
2
|
+
|
3
|
+
|
4
|
+
def index
|
5
|
+
@customers = Opensteam::UserBase::Customer.find(:all)
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @customers }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def show
|
15
|
+
@customer = Opensteam::UserBase::Customer.find( params[:id], :include => :orders )
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html # show.html.erb
|
19
|
+
format.xml { render :xml => @inventory }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class Administration::InventoriesController < AdministrationController
|
2
|
+
# GET /inventories
|
3
|
+
# GET /inventories.xml
|
4
|
+
|
5
|
+
Inventory = Opensteam::InventoryBase::Inventory
|
6
|
+
|
7
|
+
def index
|
8
|
+
@inventories = Inventory.find(:all)
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html # index.html.erb
|
12
|
+
format.xml { render :xml => @inventories }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /inventories/1
|
17
|
+
# GET /inventories/1.xml
|
18
|
+
def show
|
19
|
+
@inventory = Inventory.find(params[:id])
|
20
|
+
|
21
|
+
respond_to do |format|
|
22
|
+
format.html # show.html.erb
|
23
|
+
format.xml { render :xml => @inventory }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# GET /inventories/new
|
28
|
+
# GET /inventories/new.xml
|
29
|
+
def new
|
30
|
+
@inventory = Inventory.new
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
format.html # new.html.erb
|
34
|
+
format.xml { render :xml => @inventory }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# GET /inventories/1/edit
|
39
|
+
def edit
|
40
|
+
@inventory = Inventory.find(params[:id])
|
41
|
+
end
|
42
|
+
|
43
|
+
# POST /inventories
|
44
|
+
# POST /inventories.xml
|
45
|
+
def create
|
46
|
+
@inventory = Inventory.new(params[:inventory])
|
47
|
+
|
48
|
+
respond_to do |format|
|
49
|
+
if @inventory.save
|
50
|
+
flash[:notice] = 'Inventory was successfully created.'
|
51
|
+
format.html { redirect_to( administration_inventory_path( @inventory ) ) }
|
52
|
+
format.xml { render :xml => @inventory, :status => :created, :location => @inventory }
|
53
|
+
else
|
54
|
+
format.html { render :action => "new" }
|
55
|
+
format.xml { render :xml => @inventory.errors, :status => :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# PUT /inventories/1
|
61
|
+
# PUT /inventories/1.xml
|
62
|
+
def update
|
63
|
+
@inventory = Inventory.find(params[:id])
|
64
|
+
|
65
|
+
respond_to do |format|
|
66
|
+
if @inventory.update_attributes(params[:inventory])
|
67
|
+
flash[:notice] = 'Inventory was successfully updated.'
|
68
|
+
format.html { redirect_to( administration_inventory_path( @inventory ) ) }
|
69
|
+
format.xml { head :ok }
|
70
|
+
else
|
71
|
+
format.html { render :action => "edit" }
|
72
|
+
format.xml { render :xml => @inventory.errors, :status => :unprocessable_entity }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# DELETE /inventories/1
|
78
|
+
# DELETE /inventories/1.xml
|
79
|
+
def destroy
|
80
|
+
@inventory = Inventory.find(params[:id])
|
81
|
+
@inventory.destroy
|
82
|
+
|
83
|
+
respond_to do |format|
|
84
|
+
format.html { redirect_to(administration_inventories_url) }
|
85
|
+
format.xml { head :ok }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Administration::OrdersController < AdministrationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
conditions =
|
5
|
+
if params[:customer_id]
|
6
|
+
[ "customer_id = ?", params[:customer_id] ]
|
7
|
+
elsif params[:filter] == "unpaid"
|
8
|
+
["paid = 0"]
|
9
|
+
elsif params[:filter] == "unshipped"
|
10
|
+
["shipped = 0"]
|
11
|
+
else
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
@orders = Opensteam::OrderBase::Order.find(:all, :conditions => conditions, :include => :customer )
|
15
|
+
|
16
|
+
respond_to do |format|
|
17
|
+
format.html # index.html.erb
|
18
|
+
format.xml { render :xml => @orders }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
def show
|
25
|
+
@order = Opensteam::OrderBase::Order.find(params[:id], :include => [ :order_items, :customer, :shipping_address, :payment_address] )
|
26
|
+
|
27
|
+
respond_to do |format|
|
28
|
+
format.html # show.html.erb
|
29
|
+
format.xml { render :xml => @order }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def toggle
|
36
|
+
if params[:toggle] =~ /shipped|paid/
|
37
|
+
@order = Opensteam::OrderBase::Order.find( params[:id] )
|
38
|
+
@order.send("#{params[:toggle]}=", @order.send("#{params[:toggle]}") == 1 ? 0 : 1 )
|
39
|
+
@order.save
|
40
|
+
end
|
41
|
+
|
42
|
+
redirect_to administration_order_path( @order )
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
def show_order_item
|
49
|
+
@inventories = [ Inventory.find( Opensteam::OrderBase::OrderItem.find( params[:order_item_id] ).itemid ) ]
|
50
|
+
@product = @inventories.first.product
|
51
|
+
@product.selected_inventory = @inventories
|
52
|
+
@properties = @inventories.first.properties.to_h2 { |x| x.class.to_s.tableize }
|
53
|
+
@cart_details = true
|
54
|
+
render :action => :show_order_item, :layout => false
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
class AdministrationController < ApplicationController
|
3
|
+
layout 'administration'
|
4
|
+
before_filter :admin_required, :except => [ :login, :logout ]
|
5
|
+
|
6
|
+
|
7
|
+
include Opensteam::Finder
|
8
|
+
|
9
|
+
|
10
|
+
# show product classes
|
11
|
+
def products
|
12
|
+
@products = AdministrationController.find_product_tables #AdministrationController.find_products.collect(&:class).uniq
|
13
|
+
end
|
14
|
+
|
15
|
+
# show property classes
|
16
|
+
def properties
|
17
|
+
@properties = AdministrationController.find_property_tables #AdministrationController.find_properties.collect(&:class).uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
def signup ## with address (virtual..)
|
23
|
+
@user = Opensteam::UserBase::Customer.new(params[:customer])
|
24
|
+
if request.get?
|
25
|
+
@user.addresses.build
|
26
|
+
elsif request.post?
|
27
|
+
if @user.save
|
28
|
+
session[:user_login] = Opensteam::UserBase::User.authenticate(@user.login, @user.password)
|
29
|
+
flash[:notice] = "Signup successfull"
|
30
|
+
redirect_to :action => :index
|
31
|
+
else
|
32
|
+
flash[:warning] = "signup un-successfull"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def login
|
41
|
+
if request.post?
|
42
|
+
if session[:user_login] = Opensteam::UserBase::User.authenticate(params[:user][:login], params[:user][:password])
|
43
|
+
flash[:notice] = "login successfull"
|
44
|
+
redirect_to_stored
|
45
|
+
else
|
46
|
+
flash[:warning] = "login un-successfull"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def customers
|
53
|
+
@users = Opensteam::UserBase::Customer.find(:all)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# show admin info
|
58
|
+
def admin_info
|
59
|
+
@admin = Opensteam::UserBase::User.find_by_login("admin")
|
60
|
+
redirect_to_stored unless @admin.is_admin?
|
61
|
+
if request.put?
|
62
|
+
if @admin.update_attributes( params[:admin] )
|
63
|
+
flash[:notice] = 'Email was successfully changed.'
|
64
|
+
redirect_to :action => :index
|
65
|
+
else
|
66
|
+
render :action => :change_admin_email
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def logout
|
74
|
+
session[:user_login] = nil
|
75
|
+
flash[:notice] = "logout successfull"
|
76
|
+
redirect_to :controller => "<%= file_name %>", :action => "index"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# CheckoutController
|
2
|
+
#
|
3
|
+
# Controller to handle the checkout-process
|
4
|
+
#
|
5
|
+
require 'opensteam/shopping_cart'
|
6
|
+
require 'opensteam/checkout'
|
7
|
+
class CheckoutController < Opensteam::Checkout::CheckoutFlowController
|
8
|
+
layout "<%= file_name %>"
|
9
|
+
|
10
|
+
|
11
|
+
# initialize checkout-flow
|
12
|
+
#
|
13
|
+
def initialize
|
14
|
+
create_checkout_flow do |c|
|
15
|
+
c.on :start, :intro
|
16
|
+
c.on :finish, :controller => "<%= file_name %>", :action => "index"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# checkout intro
|
22
|
+
#
|
23
|
+
# dummy page
|
24
|
+
def intro
|
25
|
+
@user = get_user
|
26
|
+
@cart = get_cart
|
27
|
+
order = Opensteam::OrderBase::Order.create
|
28
|
+
session[:active_order] = order.id
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
# checkout outro
|
35
|
+
#
|
36
|
+
# dummy page
|
37
|
+
def outro
|
38
|
+
session[:cart] = nil
|
39
|
+
@cart = get_cart
|
40
|
+
@user = get_user
|
41
|
+
session[:active_order] = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# checkout shipping
|
48
|
+
# [POST] + [GET]
|
49
|
+
#
|
50
|
+
# saves customer-information, shipping/payment-address
|
51
|
+
#
|
52
|
+
# if customer is in the database (find_by_email), the information is updated.
|
53
|
+
# (for addresses, all fields have to match)
|
54
|
+
#
|
55
|
+
# the order is associated with the customer and the addresses.
|
56
|
+
#
|
57
|
+
# TODO : MOVE THIS INTO MODEL !!!
|
58
|
+
#
|
59
|
+
|
60
|
+
def shipping
|
61
|
+
@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
62
|
+
@cart = get_cart
|
63
|
+
|
64
|
+
@customer = Opensteam::UserBase::Customer.new
|
65
|
+
@shipping_address = Opensteam::UserBase::Address.new
|
66
|
+
@payment_address = Opensteam::UserBase::Address.new
|
67
|
+
|
68
|
+
#saving the form
|
69
|
+
if request.post?
|
70
|
+
params[:customer][:ip] = request.remote_addr
|
71
|
+
|
72
|
+
@customer = Opensteam::UserBase::Customer.find_or_initialize_by_email( params[:customer][:email] )
|
73
|
+
|
74
|
+
@payment_address = Opensteam::UserBase::Address.find( :first, :conditions => params[:payment_address].update( { :user_id => @customer.id } ) ) rescue nil
|
75
|
+
@payment_address = Opensteam::UserBase::Address.new( params[:payment_address]) if @payment_address.nil?
|
76
|
+
|
77
|
+
@shipping_address = Opensteam::UserBase::Address.find( :first, :conditions => params[:shipping_address].update( { :user_id => @customer.id } ) ) rescue nil
|
78
|
+
@shipping_address = Opensteam::UserBase::Address.new( params[:shipping_address]) if @shipping_address.nil?
|
79
|
+
|
80
|
+
status = [ @payment_address, @shipping_address, @customer].collect(&:save).inject(true) { |r,v| r && v }
|
81
|
+
|
82
|
+
if status # if form is valild
|
83
|
+
@customer.addresses << @payment_address unless @customer.addresses.exists?( @payment_address.id )
|
84
|
+
@customer.addresses << @shipping_address unless @customer.addresses.exists?( @shipping_address.id )
|
85
|
+
|
86
|
+
@order.shipping_address = @shipping_address
|
87
|
+
@order.payment_address = @payment_address
|
88
|
+
|
89
|
+
@customer.save
|
90
|
+
@order.customer = @customer
|
91
|
+
@order.save
|
92
|
+
|
93
|
+
|
94
|
+
@order.order_items.each do |oi|
|
95
|
+
returning(oi.inventory) do |i|
|
96
|
+
i.storage -= oi.quantity
|
97
|
+
i.save
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
redirect_to :action => :outro
|
102
|
+
else
|
103
|
+
render :action => :shipping
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# show cart
|
112
|
+
# [GET]
|
113
|
+
#
|
114
|
+
# show the shopping cart again
|
115
|
+
def show_cart
|
116
|
+
@cart = get_cart
|
117
|
+
@user = get_user
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
# place order
|
125
|
+
# [POST]
|
126
|
+
#
|
127
|
+
def place_order
|
128
|
+
if request.post?
|
129
|
+
|
130
|
+
@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
131
|
+
@order.copy_from_cart( get_cart )
|
132
|
+
@order.save
|
133
|
+
session[:active_order] = @order.id
|
134
|
+
|
135
|
+
redirect_to :action => :shipping
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class <%= class_name %>Controller < Opensteam::ShoppingCart::CartController
|
2
|
+
|
3
|
+
include Opensteam::Finder
|
4
|
+
|
5
|
+
# start the checkout-process
|
6
|
+
#
|
7
|
+
def start_checkout
|
8
|
+
redirect_to :controller => :checkout, :action => "invoke"
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
# index
|
13
|
+
# show shop index (all products)
|
14
|
+
def index
|
15
|
+
#todo: implement paginate for find_products
|
16
|
+
@products = <%= class_name %>Controller.find_products
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # index.html.erb
|
20
|
+
format.xml { render :xml => @products }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# get inventory object for selected product and properties
|
27
|
+
def inventory
|
28
|
+
params[:product] = frmt params[:product]
|
29
|
+
|
30
|
+
|
31
|
+
if params[:product][:properties].index("")
|
32
|
+
render :update do |page|
|
33
|
+
page.replace_html :inventory, '<span style="color:red;">Please select a ' + params[:product][:properties].index("").singularize.humanize + '</span>'
|
34
|
+
end
|
35
|
+
return
|
36
|
+
else
|
37
|
+
product = Opensteam::Find.find_product_with_inventory( params[:product] )
|
38
|
+
@inventory = product.selected_inventories
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
# show product-details
|
46
|
+
def show
|
47
|
+
unless params[:id]
|
48
|
+
@products = <%= class_name %>Controller.find_product( params[:type] )
|
49
|
+
respond_to do |format|
|
50
|
+
format.html { render :action => :index }
|
51
|
+
format.xml { render :xml => @products }
|
52
|
+
end
|
53
|
+
return
|
54
|
+
end
|
55
|
+
@product = <%= class_name %>Controller.find_product_by_id( params[:type], params[:id] )
|
56
|
+
@properties = @product.properties.to_h2 { |x| x.class.to_s.tableize }
|
57
|
+
@inventory = @product.properties.empty? ? @product.inventories : []
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
format.html # show.html.erb
|
61
|
+
format.xml { render :xml => @product }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
end
|