opensteam 0.9.2 → 0.9.3
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/CHANGELOG +53 -0
- data/README.rdoc +19 -10
- data/generators/opensteam/opensteam_generator.rb +27 -3
- data/generators/opensteam/templates/app/controllers/admin/configurations_controller.rb +85 -0
- data/generators/opensteam/templates/app/controllers/admin/inventories_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/admin/invoices_controller.rb +35 -4
- data/generators/opensteam/templates/app/controllers/admin/orders_controller.rb +5 -4
- data/generators/opensteam/templates/app/controllers/admin/shipments_controller.rb +6 -3
- data/generators/opensteam/templates/app/controllers/admin/shipping_rate_groups_controller.rb +76 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_groups_controller.rb +124 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_rules_controller.rb +19 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_zones_controller.rb +118 -0
- data/generators/opensteam/templates/app/controllers/admin/users_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/admin_controller.rb +20 -0
- data/generators/opensteam/templates/app/controllers/carts_controller.rb +118 -0
- data/generators/opensteam/templates/app/controllers/checkout_controller.rb +119 -79
- data/generators/opensteam/templates/app/controllers/profile_controller.rb +2 -4
- data/generators/opensteam/templates/app/controllers/searches_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/user_sessions_controller.rb +2 -1
- data/generators/opensteam/templates/app/controllers/users_controller.rb +10 -3
- data/generators/opensteam/templates/app/helpers/admin_helper.rb +15 -1
- data/generators/opensteam/templates/app/helpers/checkout_helper.rb +38 -0
- data/generators/opensteam/templates/app/helpers/webshop_helper.rb +6 -1
- data/generators/opensteam/templates/app/models/zone.rb +18 -0
- data/generators/opensteam/templates/app/views/admin/_menu.html.erb +18 -0
- data/generators/opensteam/templates/app/views/admin/catalog.html.erb +2 -3
- data/generators/opensteam/templates/app/views/admin/configurations/edit.html.erb +20 -0
- data/generators/opensteam/templates/app/views/admin/configurations/index.html.erb +22 -0
- data/generators/opensteam/templates/app/views/admin/configurations/new.html.erb +19 -0
- data/generators/opensteam/templates/app/views/admin/configurations/show.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/filters/_filter.html.erb +1 -1
- data/generators/opensteam/templates/app/views/admin/index.html.erb +0 -19
- data/generators/opensteam/templates/app/views/admin/inventories/edit.html.erb +10 -6
- data/generators/opensteam/templates/app/views/admin/inventories/new.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/inventories/show.html.erb +10 -6
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice.html.erb +1 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice_fields.html.erb +52 -0
- data/generators/opensteam/templates/app/views/admin/invoices/new.html.erb +9 -37
- data/generators/opensteam/templates/app/views/admin/invoices/show.html.erb +10 -36
- data/generators/opensteam/templates/app/views/admin/invoices/show.pdf.prawn +59 -0
- data/generators/opensteam/templates/app/views/admin/order_config.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/order_items/_item_entry.html.erb +9 -0
- data/generators/opensteam/templates/app/views/admin/order_items/_items_table.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order.html.erb +9 -9
- data/generators/opensteam/templates/app/views/admin/orders/_orders.html.erb +1 -1
- data/generators/opensteam/templates/app/views/admin/orders/show.html.erb +25 -9
- data/generators/opensteam/templates/app/views/admin/payment_types.html.erb +27 -0
- data/generators/opensteam/templates/app/views/admin/payments/_credit_card_payment.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/payments/_credit_card_payment_info.html.erb +15 -0
- data/generators/opensteam/templates/app/views/admin/payments/_direct_debit_payment.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/shipments/new.html.erb +45 -30
- data/generators/opensteam/templates/app/views/admin/shipments/show.html.erb +3 -3
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/_payment_addition.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/_rate.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/edit.html.erb +63 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/index.html.erb +28 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/new.html.erb +60 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/show.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/system.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_attributes.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_groups.html.erb +17 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_groups_row.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_rule.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/edit.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/index.html.erb +8 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/new.html.erb +27 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/show.html.erb +28 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_attributes.html.erb +18 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_tax_zone_row.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_tax_zones.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/edit.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/index.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/new.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/show.html.erb +15 -0
- data/generators/opensteam/templates/app/views/admin/users.html.erb +0 -1
- data/generators/opensteam/templates/app/views/admin/users/show.html.erb +10 -0
- data/generators/opensteam/templates/app/views/administration_mailer/order_customer.erb +1 -1
- data/generators/opensteam/templates/app/views/carts/_cart.html.erb +7 -0
- data/generators/opensteam/templates/app/views/carts/_cart_content.html.erb +45 -0
- data/generators/opensteam/templates/app/views/carts/create.rjs +3 -0
- data/generators/opensteam/templates/app/views/{cart → carts}/index.html.erb +0 -0
- data/generators/opensteam/templates/app/views/carts/update.rjs +11 -0
- data/generators/opensteam/templates/app/views/checkout/_address.html.erb +42 -0
- data/generators/opensteam/templates/app/views/checkout/_customer.html.erb +31 -0
- data/generators/opensteam/templates/app/views/checkout/_edit_checkout.html.erb +42 -0
- data/generators/opensteam/templates/app/views/checkout/_new_checkout.html.erb +44 -0
- data/generators/opensteam/templates/app/views/checkout/_shipping_buttons.html.erb +8 -0
- data/generators/opensteam/templates/app/views/checkout/edit.html.erb +7 -0
- data/generators/opensteam/templates/app/views/checkout/new.html.erb +11 -0
- data/generators/opensteam/templates/app/views/checkout/outro.html.erb +1 -4
- data/generators/opensteam/templates/app/views/checkout/show.html.erb +63 -0
- data/generators/opensteam/templates/app/views/common/_header_admin.html.erb +5 -0
- data/generators/opensteam/templates/app/views/layouts/admin.html.erb +28 -12
- data/generators/opensteam/templates/app/views/layouts/profile.html.erb +2 -2
- data/generators/opensteam/templates/app/views/layouts/webshop.html.erb +5 -4
- data/generators/opensteam/templates/app/views/payment/_advance_payment_payment.html.erb +1 -0
- data/generators/opensteam/templates/app/views/payment/_credit_card_payment.html.erb +37 -0
- data/generators/opensteam/templates/app/views/payment/_credit_card_payment_confirmation.html.erb +20 -0
- data/generators/opensteam/templates/app/views/payment/_direct_debit_payment.html.erb +5 -0
- data/generators/opensteam/templates/app/views/payment/_direct_debit_payment_confirmation.html.erb +5 -0
- data/generators/opensteam/templates/app/views/profile/index.html.erb +1 -1
- data/generators/opensteam/templates/app/views/profile/infos/edit.html.erb +20 -12
- data/generators/opensteam/templates/app/views/profile/infos/edit_password.html.erb +16 -12
- data/generators/opensteam/templates/app/views/profile/orders/_order.html.erb +1 -1
- data/generators/opensteam/templates/app/views/profile/orders/show.html.erb +10 -7
- data/generators/opensteam/templates/app/views/webshop/_inventory_content.html.erb +1 -0
- data/generators/opensteam/templates/app/views/webshop/show.html.erb +3 -1
- data/generators/opensteam/templates/config/initializers/init_states.rb +13 -24
- data/generators/opensteam/templates/config/initializers/opensteam.rb +41 -0
- data/generators/opensteam/templates/config/initializers/opensteam_model_tables.rb +49 -10
- data/generators/opensteam/templates/config/initializers/opensteam_security.rb +8 -0
- data/generators/opensteam/templates/config/initializers/payment_process.rb +37 -0
- data/generators/opensteam/templates/db/migrate/20080609095723_create_addresses.rb +8 -2
- data/generators/opensteam/templates/db/migrate/20080609095726_create_inventories.rb +6 -3
- data/generators/opensteam/templates/db/migrate/20080609095728_create_order_items.rb +12 -1
- data/generators/opensteam/templates/db/migrate/20080609095729_create_orders.rb +8 -12
- data/generators/opensteam/templates/db/migrate/20080609095730_create_payment_types.rb +2 -0
- data/generators/opensteam/templates/db/migrate/20080714131513_create_invoices.rb +2 -1
- data/generators/opensteam/templates/db/migrate/20080714131650_create_shipments.rb +3 -1
- data/generators/opensteam/templates/db/migrate/20080808075247_create_containers.rb +30 -0
- data/generators/opensteam/templates/db/migrate/20080808083011_create_container_items.rb +25 -0
- data/generators/opensteam/templates/db/migrate/20080812102727_create_tax_zones.rb +16 -0
- data/generators/opensteam/templates/db/migrate/20080812102858_create_tax_rules.rb +15 -0
- data/generators/opensteam/templates/db/migrate/20080812102956_create_tax_groups.rb +14 -0
- data/generators/opensteam/templates/db/migrate/20080831181436_create_configurations.rb +15 -0
- data/generators/opensteam/templates/db/migrate/20080903131506_create_payments.rb +22 -0
- data/generators/opensteam/templates/db/migrate/20080904133625_create_payment_transactions.rb +24 -0
- data/generators/opensteam/templates/db/migrate/20080916102341_create_zones.rb +19 -0
- data/generators/opensteam/templates/db/migrate/20080916134340_create_region_shipping_rates.rb +18 -0
- data/generators/opensteam/templates/db/migrate/20080916134523_create_shipping_rate_groups.rb +18 -0
- data/generators/opensteam/templates/db/migrate/20080916135226_create_shipping_payment_additions.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080916135228_init_opensteam_config.rb +60 -0
- data/generators/opensteam/templates/public/images/opensteam_black.jpg +0 -0
- data/generators/opensteam/templates/public/images/pdf.png +0 -0
- data/generators/opensteam/templates/public/images/shader.png +0 -0
- data/generators/opensteam/templates/public/index.html +1 -0
- data/generators/opensteam/templates/public/javascripts/opensteam.js +21 -21
- data/generators/opensteam/templates/public/stylesheets/opensteam_admin.css +291 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_white.css +47 -11
- data/generators/opensteam/templates/tasks/opensteam.rake +2 -12
- data/generators/opensteam/templates/test/fixtures/addresses.yml +26 -0
- data/generators/opensteam/templates/test/fixtures/configurations.yml +29 -0
- data/generators/opensteam/templates/test/fixtures/inventories.yml +32 -15
- data/generators/opensteam/templates/test/fixtures/profiles.yml +21 -0
- data/generators/opensteam/templates/test/fixtures/region_shipping_rates.yml +33 -0
- data/generators/opensteam/templates/test/fixtures/shipping_payment_additions.yml +91 -0
- data/generators/opensteam/templates/test/fixtures/shipping_rate_groups.yml +25 -0
- data/generators/opensteam/templates/test/fixtures/tax_groups.yml +13 -0
- data/generators/opensteam/templates/test/fixtures/tax_rules.yml +29 -0
- data/generators/opensteam/templates/test/fixtures/tax_zones.yml +33 -0
- data/generators/opensteam/templates/test/fixtures/users.yml +26 -0
- data/generators/opensteam/templates/test/fixtures/zones.yml +2707 -0
- data/generators/opensteam/templates/test/functional/carts_controller_test.rb +103 -0
- data/generators/opensteam/templates/test/test_helper.rb +38 -0
- data/generators/opensteam/templates/test/unit/container_test.rb +71 -0
- data/generators/opensteam/templates/test/unit/order_test.rb +93 -0
- data/generators/opensteam/templates/test/unit/payment_test.rb +220 -0
- data/generators/opensteam/templates/test/unit/product_test.rb +158 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/.gitignore +3 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/MIT-LICENSE +20 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/README +12 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/Rakefile +22 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/init.rb +6 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto.rb +13 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/action_controller.rb +47 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/template_handler/base.rb +75 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/template_handler/raw.rb +54 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/tasks/prawnto_tasks.rake +4 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/action_controller_test.rb +36 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/base_template_handler_test.rb +58 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/raw_template_handler_test.rb +163 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/template_handler_test_mocks.rb +83 -0
- data/generators/opensteam_product/templates/views/admin/_attributes.html.erb +8 -3
- data/generators/opensteam_product/templates/views/admin/_inventories.html.erb +2 -0
- data/lib/opensteam.rb +0 -1
- data/lib/opensteam/base.rb +2 -1
- data/lib/opensteam/checkout.rb +3 -12
- data/lib/opensteam/config.rb +50 -2
- data/lib/opensteam/container.rb +196 -0
- data/lib/opensteam/extension_base.rb +19 -1
- data/lib/opensteam/finder.rb +1 -1
- data/lib/opensteam/helpers/config_table_helper.rb +18 -6
- data/lib/opensteam/initializer.rb +24 -4
- data/lib/opensteam/inventory_base.rb +6 -1
- data/lib/opensteam/invoice_base.rb +12 -13
- data/lib/opensteam/money.rb +230 -0
- data/lib/opensteam/order_base.rb +122 -48
- data/lib/opensteam/payment.rb +225 -0
- data/lib/opensteam/payment/advance_payment.rb +34 -0
- data/lib/opensteam/payment/credit_card_payment.rb +217 -0
- data/lib/opensteam/payment/direct_debit_payment.rb +53 -0
- data/lib/opensteam/product_base.rb +48 -12
- data/lib/opensteam/security.rb +54 -0
- data/lib/opensteam/shipment_base.rb +214 -6
- data/lib/opensteam/shopping_cart.rb +20 -300
- data/lib/opensteam/state_logic.rb +5 -3
- data/lib/opensteam/state_machine.rb +8 -3
- data/lib/opensteam/user_base.rb +48 -6
- data/lib/opensteam/version.rb +1 -1
- metadata +122 -16
- data/generators/opensteam/templates/app/controllers/cart_controller.rb +0 -94
- data/generators/opensteam/templates/app/views/admin/orders/_event.html.erb +0 -5
- data/generators/opensteam/templates/app/views/admin/orders/_order_item.html.erb +0 -10
- data/generators/opensteam/templates/app/views/cart/_cart.html.erb +0 -8
- data/generators/opensteam/templates/app/views/cart/_cart_content.html.erb +0 -20
- data/generators/opensteam/templates/app/views/cart/update.rjs +0 -1
- data/generators/opensteam/templates/app/views/checkout/payment.html.erb +0 -8
- data/generators/opensteam/templates/app/views/checkout/shipping.html.erb +0 -45
- data/generators/opensteam/templates/app/views/checkout/show_cart.html.erb +0 -13
- data/generators/opensteam/templates/app/views/checkout/update_cart_content.rjs +0 -2
- data/generators/opensteam/templates/app/views/profile/orders/_order_item.html.erb +0 -10
- data/generators/opensteam/templates/db/migrate/20080609095725_create_dummy_users.rb +0 -21
- data/lib/opensteam/cart_base.rb +0 -227
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
## TEMPLATE ##
|
|
2
|
-
class CartController < ApplicationController
|
|
3
|
-
|
|
4
|
-
layout '<%= file_name %>'
|
|
5
|
-
|
|
6
|
-
include Opensteam::CartBase::Helper
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def index
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def show
|
|
14
|
-
@inventory = [ Opensteam::InventoryBase::Inventory.find( @cart.items[ params[:id].to_i ].yamlid ) ]
|
|
15
|
-
@product = @inventory.first.product
|
|
16
|
-
@product.selected_inventory = @inventory.first
|
|
17
|
-
@properties = @product.selected_inventory.properties.to_h2 { |x| x.class.to_s.tableize }
|
|
18
|
-
@cart_details = true
|
|
19
|
-
|
|
20
|
-
render :template => "<%= file_name %>/show" # => "<%= file_name %>/show"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def create
|
|
25
|
-
params[:product] = frmt params[:product]
|
|
26
|
-
|
|
27
|
-
if params[:product][:properties] && params[:product][:properties].index("")
|
|
28
|
-
flash[:error] = "Please select a #{params[:product][:properties].index("").humanize}"
|
|
29
|
-
return
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
product = Opensteam::Find.find_product_with_inventory( params[:product] )
|
|
33
|
-
|
|
34
|
-
if product.is_available?
|
|
35
|
-
unless @cart.add product.selected_inventories.last.id
|
|
36
|
-
render :update do |page| page.alert "sorry, there are only #{product.selected_inventories.last.storage} available!" end
|
|
37
|
-
end
|
|
38
|
-
else
|
|
39
|
-
render :update do |page| page.alert "Sorry, this product is currently not available!" end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def update
|
|
46
|
-
if params[:quantity]
|
|
47
|
-
params[:quantity].each { |key,value| @cart.set_quantity(key,value) }
|
|
48
|
-
if session[:active_order]
|
|
49
|
-
redirect_to :action => 'show_cart'
|
|
50
|
-
return
|
|
51
|
-
end
|
|
52
|
-
else
|
|
53
|
-
ci = @cart.get( :cart_item_id => params[:id] )
|
|
54
|
-
if params[:incr]
|
|
55
|
-
unless ci.incr
|
|
56
|
-
render :update do |page| page.alert "Sorry, there are only #{ci.quantity} available!" end
|
|
57
|
-
return
|
|
58
|
-
end
|
|
59
|
-
elsif params[:decr]
|
|
60
|
-
( ci.quantity - 1 ) == 0 ? @cart.items.delete_at( params[:id].to_i ) : ci.decr
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
if ( session[:active_order] )
|
|
64
|
-
render :template => "checkout/update_cart_content.rjs"
|
|
65
|
-
return
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
respond_to do |format|
|
|
70
|
-
format.html { params[:redirect] || redirect_to_index }
|
|
71
|
-
format.js { render :template => "cart/update.rjs" }
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def destroy
|
|
78
|
-
if params[:id]
|
|
79
|
-
@cart.del( :cart_item_id => params[:id] )
|
|
80
|
-
@current_item = params[:id]
|
|
81
|
-
else
|
|
82
|
-
empty_cart
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
respond_to do |format|
|
|
86
|
-
format.html { redirect_to opensteam_index_path }
|
|
87
|
-
format.js { render :action => "update.rjs" }
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<div class="order_item" style="padding-left:1em;border-bottom:1px dotted black;">
|
|
2
|
-
<b>Product:</b> <%=h order_item.inventory.product.name %> (<%=h order_item.inventory.product.class %>)<br />
|
|
3
|
-
<%- unless order_item.inventory.properties.empty? -%><b>Configuration:</b> <%=h order_item.inventory.properties.collect(&:name) * "," %><br /> <%- end -%>
|
|
4
|
-
<b>Quantity:</b> <%=h order_item.quantity %><br />
|
|
5
|
-
<b>Price:</b> <%=h order_item.quantity * order_item.inventory.price %><br />
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<div id="cart_content">
|
|
2
|
-
<%%= render :partial => "cart/cart_content" %>
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
<%% if ! @cart.items.empty? %>
|
|
6
|
-
<%%= button_to "checkout" , { :controller => '<%= file_name %>', :action => :start_checkout }, :confirm => "checkout?" %>
|
|
7
|
-
<%%= button_to "empty cart" , { :controller => 'cart', :action => :destroy }, :confirm => "empty cart?" %>
|
|
8
|
-
<%% end %>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<% form_tag :url => { :controller => 'cart', :action => :update, :redirect => opensteam_index_path } do %>
|
|
2
|
-
<% @cart.items.each_with_index do |i,k| %>
|
|
3
|
-
<div class="cart_item" id="cart_item_<%=h k %>">
|
|
4
|
-
<%= i.product.class.to_s %> <%= link_to i.product.name, :controller => 'cart', :action => :show, :id => k %> : <%=h i.quantity -%>
|
|
5
|
-
<%= text_field_tag "quantity[#{k}]", i.quantity.to_s, :id => "quantity", :size => 5 -%>
|
|
6
|
-
<%= link_to_remote image_tag( "/images/plus.png", :border => "0" ), :url => { :controller => 'cart', :action => :update, :id => k, :incr => 1 } -%>
|
|
7
|
-
<%= link_to_remote image_tag( "/images/minus.png", :border => "0"), :url => { :controller => 'cart', :action => :update, :id => k, :decr => 1 } -%>
|
|
8
|
-
<%= link_to_remote image_tag( "/images/cancel.png", :border => "0"), :url => { :controller => 'cart', :action => :destroy, :id => k } -%>
|
|
9
|
-
<br />
|
|
10
|
-
</div>
|
|
11
|
-
<% end %>
|
|
12
|
-
<br /><br />
|
|
13
|
-
<% if ! @cart.items.empty? %>
|
|
14
|
-
<%= submit_tag "update" %> <br /> <br />
|
|
15
|
-
------
|
|
16
|
-
<br />
|
|
17
|
-
<b>Total Price</b>: <%=h @cart.total_price %>
|
|
18
|
-
<% end %>
|
|
19
|
-
<% end %>
|
|
20
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
page.replace_html :cart, :partial => "cart/cart", :object => @cart
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<h1>welcome to payment</h1>
|
|
2
|
-
-> session : <%=h session[:active_order] %><br />
|
|
3
|
-
|
|
4
|
-
<% form_tag :action => :payment do %>
|
|
5
|
-
Payment : <%= select_tag "paymenttype", options_for_select( [["-",""]] + PaymentType.find(:all).collect { |s| [s.name, s.id] } ) %>
|
|
6
|
-
<br />
|
|
7
|
-
<%= link_to "prev", :action => :execute_prev %> | <%= submit_tag "next" %>
|
|
8
|
-
<% end %>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<h1>welcome to shipping</h1>
|
|
2
|
-
|
|
3
|
-
<%= error_messages_for :customer %>
|
|
4
|
-
<%= error_messages_for :shipping_address %>
|
|
5
|
-
<%= error_messages_for :payment_address %>
|
|
6
|
-
|
|
7
|
-
<% form_for :order, :url => { :action => :shipping } do |f| %>
|
|
8
|
-
<% f.fields_for :customer, @customer do |c| %>
|
|
9
|
-
|
|
10
|
-
<%= c.hidden_field :password, :value => "opensteam" %>
|
|
11
|
-
<%= c.hidden_field :password_confirmation, :value => "opensteam" %>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<table>
|
|
15
|
-
<tr><td><b>Email</b></td><td><%= c.text_field :email %></td></tr>
|
|
16
|
-
<tr><td><b>Firstname</b></td><td><%= c.text_field :firstname %></td></tr>
|
|
17
|
-
<tr><td><b>Lastname</b></td><td><%= c.text_field :lastname %></td></tr>
|
|
18
|
-
</table>
|
|
19
|
-
<br />
|
|
20
|
-
<div id="customer_address">
|
|
21
|
-
<u>Shipping Address</u><br /><br />
|
|
22
|
-
<% f.fields_for :shipping_address, @shipping_address do |a| %>
|
|
23
|
-
<table>
|
|
24
|
-
<tr><td><b>Street</b></td><td><%= a.text_field :street %></td></tr>
|
|
25
|
-
<tr><td><b>ZIP</b></td><td><%= a.text_field :postal %></td></tr>
|
|
26
|
-
<tr><td><b>City</b></td><td><%= a.text_field :city %></td></tr>
|
|
27
|
-
<tr><td><b>Country</b></td><td><%= a.text_field :land %></td></tr>
|
|
28
|
-
</table>
|
|
29
|
-
<% end %>
|
|
30
|
-
<br /><br />
|
|
31
|
-
<u>Payment Address</u><br /><br />
|
|
32
|
-
<% f.fields_for :payment_address, @payment_address do |a| %>
|
|
33
|
-
<table>
|
|
34
|
-
<tr><td><b>Street</b></td><td><%= a.text_field :street %></td></tr>
|
|
35
|
-
<tr><td><b>ZIP</b></td><td><%= a.text_field :postal %></td></tr>
|
|
36
|
-
<tr><td><b>City</b></td><td><%= a.text_field :city %></td></tr>
|
|
37
|
-
<tr><td><b>Country</b></td><td><%= a.text_field :land %></td></tr>
|
|
38
|
-
</table>
|
|
39
|
-
<% end %>
|
|
40
|
-
</div>
|
|
41
|
-
<br /><br />
|
|
42
|
-
<%= link_to "prev", :action => :intro %> | <%= submit_tag "next" %>
|
|
43
|
-
<% end %>
|
|
44
|
-
|
|
45
|
-
<% end %>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<b>Your Order</b>
|
|
2
|
-
<br />
|
|
3
|
-
<b><u>Order-Items</u></b><br /><br />
|
|
4
|
-
<div id="cart_content">
|
|
5
|
-
<%= render :partial => "common/cart_content" %>
|
|
6
|
-
</div>
|
|
7
|
-
<br />
|
|
8
|
-
<br />
|
|
9
|
-
<% form_tag :action => :place_order do %>
|
|
10
|
-
<%= link_to "prev", :action => :intro %> | <%= submit_tag "next" %>
|
|
11
|
-
<br />
|
|
12
|
-
<% end %>
|
|
13
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<div class="order_item" style="padding-left:1em;border-bottom:1px dotted black;">
|
|
2
|
-
<b>Product:</b> <%=h order_item.inventory.product.name %> (<%=h order_item.inventory.product.class %>)<br />
|
|
3
|
-
<%- unless order_item.inventory.properties.empty? -%><b>Configuration:</b> <%=h order_item.inventory.properties.collect(&:name) * "," %><br /> <%- end -%>
|
|
4
|
-
<b>Quantity:</b> <%=h order_item.quantity %><br />
|
|
5
|
-
<b>Price:</b> <%=h order_item.quantity * order_item.inventory.price %><br />
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class CreateDummyUsers < ActiveRecord::Migration
|
|
2
|
-
def self.up
|
|
3
|
-
p = Opensteam::UserBase::Profile.create( :name => "Admin", :description => "Admin Profile" )
|
|
4
|
-
|
|
5
|
-
u = Opensteam::UserBase::User.create( :firstname => "admin",
|
|
6
|
-
:lastname => "admin",
|
|
7
|
-
:email => "admin@host.com",
|
|
8
|
-
:password => "opensteam",
|
|
9
|
-
:password_confirmation => "opensteam" )
|
|
10
|
-
|
|
11
|
-
u.profile = p
|
|
12
|
-
|
|
13
|
-
u.save
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.down
|
|
18
|
-
Opensteam::UserBase::User.find_by_email("admin@host.com").destroy rescue nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
data/lib/opensteam/cart_base.rb
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# openSteam - http://www.opensteam.net
|
|
2
|
-
# Copyright (C) 2008 DiamondDogs Webconsulting
|
|
3
|
-
#
|
|
4
|
-
# This program is free software; you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation; version 2 of the License.
|
|
7
|
-
#
|
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
-
# GNU General Public License for more details.
|
|
12
|
-
#
|
|
13
|
-
# You should have received a copy of the GNU General Public License along
|
|
14
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
require 'opensteam/finder'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
module Opensteam
|
|
24
|
-
|
|
25
|
-
module CartBase
|
|
26
|
-
|
|
27
|
-
module Helper
|
|
28
|
-
def self.included(base)
|
|
29
|
-
base.extend ClassMethods
|
|
30
|
-
base.class_eval do
|
|
31
|
-
include InstanceMethods
|
|
32
|
-
before_filter :set_instance_vars
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
module ClassMethods
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
module InstanceMethods
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
def empty_cart
|
|
48
|
-
wipe_cart
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def frmt(h)
|
|
52
|
-
returning(Hash.new) { |hash| h.each_pair { |k,v| k =~ /^products/ ? ( hash[:products] ||= [] ) << frmt(v) : hash[k] = v } }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def set_instance_vars
|
|
58
|
-
@cart = get_cart
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def get_cart
|
|
63
|
-
session[:cart] ||= Cart.new
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def wipe_cart
|
|
67
|
-
session[:cart] = nil
|
|
68
|
-
get_cart
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def redirect_to_index
|
|
73
|
-
redirect_to :action => :index
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class Cart
|
|
83
|
-
|
|
84
|
-
## cart_items
|
|
85
|
-
attr_accessor :items
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# intialize items array
|
|
89
|
-
def initialize
|
|
90
|
-
@items = []
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# get item from cart
|
|
96
|
-
# get( :cart_itemd_id => 1 ) # get item by internal array id
|
|
97
|
-
# get( :yamlid => 3 ) # get item by Inventory-id
|
|
98
|
-
#
|
|
99
|
-
def get( opts = {} )
|
|
100
|
-
|
|
101
|
-
if opts.has_key? :yamlid
|
|
102
|
-
@items.each do |v|
|
|
103
|
-
return v if v.yamlid == opts[:yamlid]
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
elsif opts.has_key? :cart_item_id
|
|
107
|
-
return @items[ opts[:cart_item_id].to_i ]
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
return nil
|
|
111
|
-
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# add an item to cart or increment its quantity
|
|
117
|
-
def add( yamlid )
|
|
118
|
-
item = get( :yamlid => yamlid )
|
|
119
|
-
if item.nil?
|
|
120
|
-
@items << CartItem.new( yamlid )
|
|
121
|
-
return true
|
|
122
|
-
else
|
|
123
|
-
return item.incr
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
# set quantity for item (by internal array-id)
|
|
130
|
-
def set_quantity( id, q )
|
|
131
|
-
item = @items[ id.to_i ]
|
|
132
|
-
|
|
133
|
-
return nil if item.nil?
|
|
134
|
-
|
|
135
|
-
q = q.to_i
|
|
136
|
-
if q == 0
|
|
137
|
-
@items.delete_at( id.to_i )
|
|
138
|
-
elsif q > 0
|
|
139
|
-
item.quantity = ( item.inventory.storage < q ) ? item.inventory.storage : q
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
item
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
# delete item from cart (:cart_item_id or :yamlid )
|
|
147
|
-
def del( opts = {} )
|
|
148
|
-
if opts.has_key?( :yamlid )
|
|
149
|
-
@items.delete( get( :yamlid => opts[:yamlid] ) )
|
|
150
|
-
elsif opts.has_key?( :cart_item_id )
|
|
151
|
-
@items.delete_at( opts[:cart_item_id].to_i )
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# calculate total price
|
|
158
|
-
def total_price
|
|
159
|
-
@items.collect { |x| x.price * x.quantity }.inject(&:+)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
class CartItem
|
|
167
|
-
include Opensteam::Finder
|
|
168
|
-
|
|
169
|
-
@@_load_product_on_init = false
|
|
170
|
-
cattr_accessor :_load_product_on_init
|
|
171
|
-
|
|
172
|
-
attr_reader :yamlid
|
|
173
|
-
|
|
174
|
-
attr_reader :product
|
|
175
|
-
|
|
176
|
-
attr_accessor :quantity
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
#initialize cart-item
|
|
180
|
-
def initialize(id)
|
|
181
|
-
@yamlid = id
|
|
182
|
-
@quantity = 1
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# increase quantity
|
|
186
|
-
def incr
|
|
187
|
-
if (@quantity + 1 ) > inventory.storage
|
|
188
|
-
return false
|
|
189
|
-
else
|
|
190
|
-
@quantity += 1
|
|
191
|
-
return true
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
# decrease quantity
|
|
196
|
-
def decr
|
|
197
|
-
@quantity -= 1
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
# return product
|
|
201
|
-
def product
|
|
202
|
-
return Opensteam::InventoryBase::Inventory.find( @yamlid ).product
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
# return Inventory Object
|
|
207
|
-
def inventory
|
|
208
|
-
return Opensteam::InventoryBase::Inventory.find( @yamlid )
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
# return price
|
|
212
|
-
def price
|
|
213
|
-
return Opensteam::InventoryBase::Inventory.find( @yamlid ).price
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
private
|
|
217
|
-
def load_product_object
|
|
218
|
-
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
end
|