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,86 @@
|
|
1
|
+
class Administration::<%= class_name.pluralize %>Controller < AdministrationController
|
2
|
+
|
3
|
+
# GET /<%= table_name %>
|
4
|
+
# GET /<%= table_name %>.xml
|
5
|
+
def index
|
6
|
+
@<%= table_name %> = <%= class_name %>.find(:all)
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # index.html.erb
|
10
|
+
format.xml { render :xml => @<%= table_name %> }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /<%= table_name %>/1
|
15
|
+
# GET /<%= table_name %>/1.xml
|
16
|
+
def show
|
17
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.xml { render :xml => @<%= file_name %> }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /<%= table_name %>/new
|
26
|
+
# GET /<%= table_name %>/new.xml
|
27
|
+
def new
|
28
|
+
@<%= file_name %> = <%= class_name %>.new
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.html # new.html.erb
|
32
|
+
format.xml { render :xml => @<%= file_name %> }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /<%= table_name %>/1/edit
|
37
|
+
def edit
|
38
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
39
|
+
end
|
40
|
+
|
41
|
+
# POST /<%= table_name %>
|
42
|
+
# POST /<%= table_name %>.xml
|
43
|
+
def create
|
44
|
+
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
if @<%= file_name %>.save
|
48
|
+
flash[:notice] = '<%= class_name %> was successfully created.'
|
49
|
+
format.html { redirect_to([:administration, @<%= file_name %>]) }
|
50
|
+
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
51
|
+
else
|
52
|
+
format.html { render :action => "new" }
|
53
|
+
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# PUT /<%= table_name %>/1
|
59
|
+
# PUT /<%= table_name %>/1.xml
|
60
|
+
def update
|
61
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
62
|
+
|
63
|
+
respond_to do |format|
|
64
|
+
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
|
65
|
+
flash[:notice] = '<%= class_name %> was successfully updated.'
|
66
|
+
format.html { redirect_to([:administration, @<%= file_name %>]) }
|
67
|
+
format.xml { head :ok }
|
68
|
+
else
|
69
|
+
format.html { render :action => "edit" }
|
70
|
+
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# DELETE /<%= table_name %>/1
|
76
|
+
# DELETE /<%= table_name %>/1.xml
|
77
|
+
def destroy
|
78
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
79
|
+
@<%= file_name %>.destroy
|
80
|
+
|
81
|
+
respond_to do |format|
|
82
|
+
format.html { redirect_to(administration_<%= table_name %>_url) }
|
83
|
+
format.xml { head :ok }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
<% for attribute in migration_attributes -%>
|
5
|
+
add_column :properties, :<%= attribute.name %>, :<%= attribute.type %>
|
6
|
+
<% end %>
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
<% for attribute in migration_attributes -%>
|
11
|
+
remove_column :properties, :<%= attribute.name %>
|
12
|
+
<% end %>
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Editing <%= class_name %></h1>
|
2
|
+
|
3
|
+
<%%= error_messages_for :<%= singular_name %> %>
|
4
|
+
|
5
|
+
<%% form_for([:administration, @<%= singular_name %>]) do |f| %>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<b><%= attribute.column.human_name %></b><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= f.submit "Update" %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Show', [:administration, @<%= singular_name %>] %> |
|
19
|
+
<%%= link_to 'Back', administration_<%= plural_name %>_path %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<th><%= attribute.column.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<% for attribute in attributes -%>
|
13
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
+
<% end -%>
|
15
|
+
<td><%%= link_to 'Show', [:administration, <%= singular_name %>] %></td>
|
16
|
+
<td><%%= link_to 'Edit', edit_administration_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
+
<td><%%= link_to 'Destroy', [:administration, <%= singular_name %>], :confirm => 'Are you sure?', :method => :delete %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<br />
|
23
|
+
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_administration_<%= singular_name %>_path %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1>New <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%%= error_messages_for :<%= singular_name %> %>
|
4
|
+
|
5
|
+
<%% form_for([:administration, @<%= singular_name %>]) do |f| %>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<p>
|
8
|
+
<b><%= attribute.column.human_name %></b><br />
|
9
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= f.submit "Create" %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Back', administration_<%= plural_name %>_path %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.column.human_name %>:</b>
|
4
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_administration_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
10
|
+
<%%= link_to 'Back', administration_<%= plural_name %>_path %>
|
data/lib/opensteam.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module Opensteam #:nodoc:
|
4
|
+
|
5
|
+
def self._logger(args) #:nodoc:
|
6
|
+
logger = ( defined? RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
|
7
|
+
logger.info "** [openSteam] #{args}"
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# load controller specific modules and the inventory_base modules
|
14
|
+
def self.load_opensteam_controller
|
15
|
+
require 'opensteam/user_base'
|
16
|
+
require 'opensteam/shopping_cart'
|
17
|
+
require 'opensteam/checkout'
|
18
|
+
require 'opensteam/inventory_base'
|
19
|
+
|
20
|
+
Opensteam._logger "loaded!"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
require 'opensteam/version'
|
28
|
+
Opensteam._logger "v#{Opensteam::VERSION::STRING} loading .."
|
29
|
+
|
30
|
+
require 'opensteam/config'
|
31
|
+
require 'opensteam/finder'
|
32
|
+
require 'opensteam/product_base'
|
33
|
+
require 'opensteam/property_base'
|
34
|
+
require 'opensteam/base'
|
35
|
+
require 'opensteam/order_base'
|
36
|
+
|
37
|
+
|
38
|
+
# extend ActiveRecord with the "opensteam" method
|
39
|
+
ActiveRecord::Base.send(:include, Opensteam::Base::Extension )
|
40
|
+
|
41
|
+
Dir.glob("#{RAILS_ROOT}/app/models/*.rb").collect { |f| require f }
|
42
|
+
|
43
|
+
class Rails::Initializer #:nodoc:
|
44
|
+
def after_initialize_with_load_opensteam_controller
|
45
|
+
after_initialize_without_load_opensteam_controller
|
46
|
+
Opensteam.load_opensteam_controller
|
47
|
+
end
|
48
|
+
alias_method_chain :after_initialize, :load_opensteam_controller
|
49
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Opensteam
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
Base Module for openSteam
|
5
|
+
|
6
|
+
- Helper for ProductBase and PropertyBase
|
7
|
+
- Extension Module for ProductBase associations
|
8
|
+
- ActiveRecord Extension( Opensteam::Base::Extension::ActsOpensteam)
|
9
|
+
- Abstract Class for OODesign (Opensteam::Base::ProductBase)
|
10
|
+
- Base Class for Properties (STI)
|
11
|
+
|
12
|
+
=end
|
13
|
+
module Base
|
14
|
+
|
15
|
+
# Extension for the Product-Inventory association
|
16
|
+
module ExistByPropertiesExtension
|
17
|
+
|
18
|
+
# checks if an Inventory-Objects exists, which is associated with the given properties
|
19
|
+
def exist_by_properties?( p )
|
20
|
+
collect(&:properties).collect(&:sort).include?( p.kind_of?( Array ) ? p.sort : p )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Extension for the Product-Properties association
|
26
|
+
module PropertiesExtension
|
27
|
+
def push( prop ) proxy_owner.send( :add_properties, Array(prop).flatten ) ; end
|
28
|
+
alias :<< :push
|
29
|
+
def delete( prop ) proxy_owner.send( :del_properties, Array(prop).flatten ) ; end
|
30
|
+
def clear ; proxy_owner.send( :clear_properties ) ; end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
=begin rdoc
|
37
|
+
Helper Module for Opensteam Products and Properties
|
38
|
+
|
39
|
+
Defines methods to determine wether an object is a property or a product.
|
40
|
+
Included both in ProductBase and PropertyBase
|
41
|
+
(Used for security reasons)
|
42
|
+
=end
|
43
|
+
module Helper
|
44
|
+
|
45
|
+
def self.included(base) #:nodoc:
|
46
|
+
base.extend(ClassMethods)
|
47
|
+
class << base ; attr_reader :opensteam_type ; end
|
48
|
+
end
|
49
|
+
|
50
|
+
def is_property?() self.class.is_property? ; end
|
51
|
+
def is_product?() self.class.is_product? ; end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
module ClassMethods
|
56
|
+
def is_property?() self.ancestors.include? Opensteam::Base::PropertyBase ; end
|
57
|
+
def is_product?() ( self.opensteam_type || self.superclass.opensteam_type ) == :product ; end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
module Extension #:nodoc:
|
64
|
+
|
65
|
+
def self.included(base)
|
66
|
+
base.extend ActsOpensteam
|
67
|
+
end
|
68
|
+
|
69
|
+
require 'opensteam/product_base'
|
70
|
+
require 'opensteam/property_base'
|
71
|
+
|
72
|
+
# Extend ActiveRecord::Base with the opensteam method
|
73
|
+
module ActsOpensteam
|
74
|
+
|
75
|
+
# called in a model to inject product-specific methods into the class:
|
76
|
+
#
|
77
|
+
# class Product < ActiveRecord::Base
|
78
|
+
# opensteam :product
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
def opensteam(arg, *opt)
|
82
|
+
Opensteam._logger "including #{arg.to_s.humanize} Module in #{self.to_s} Model"
|
83
|
+
|
84
|
+
if arg == :product
|
85
|
+
@opensteam_type = arg
|
86
|
+
class_eval { include Opensteam::ProductBase }
|
87
|
+
else
|
88
|
+
Opensteam._logger "opensteam-method #{arg.to_s} not suppored, in #{self.to_s}"
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
# Abstract ProductBase Class
|
101
|
+
# used for ObjectOriented Design
|
102
|
+
class ProductBase < ActiveRecord::Base
|
103
|
+
self.abstract_class = true
|
104
|
+
include Opensteam::ProductBase
|
105
|
+
@opensteam_type = :product
|
106
|
+
class << self ; attr_reader :opensteam_type ; end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
# Base Class for Properties (STI)
|
112
|
+
#
|
113
|
+
class PropertyBase < ActiveRecord::Base
|
114
|
+
include Opensteam::PropertyBase
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'opensteam/shopping_cart'
|
2
|
+
|
3
|
+
module Opensteam
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
=begin rdoc
|
8
|
+
Checkout Module
|
9
|
+
|
10
|
+
Defines methods to create a simple checkout-flow
|
11
|
+
|
12
|
+
Currently only used to define a :start action and a :finish action.
|
13
|
+
The rest of the checkout-process (the intermediate steps) are handled by the steps
|
14
|
+
itself (like redirecting, errorhandling, etc)
|
15
|
+
|
16
|
+
TODO:
|
17
|
+
Implement an actual Checkout-Workflow Generator, with ErrorHandling etc
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Checkout
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
class CheckoutFlowController < Opensteam::ShoppingCart::CartController
|
26
|
+
|
27
|
+
before_filter :current_step
|
28
|
+
|
29
|
+
# save the current-action name in the sessions
|
30
|
+
def current_step
|
31
|
+
session[:current_action] = self.action_name
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# method to finish the checkout-process and redirect_to the action
|
36
|
+
# specified by :finish
|
37
|
+
def endstep
|
38
|
+
redirect_to_step(:finish)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# create the checkout flow
|
43
|
+
#
|
44
|
+
# define an init-method in your CheckoutController:
|
45
|
+
# def init
|
46
|
+
# create_checkout_flow do |c|
|
47
|
+
# c.on :start, :intro
|
48
|
+
# c.on :finish, :controller => "petstore", :action => "index"
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
def create_checkout_flow( target = self )
|
52
|
+
yield target if block_given?
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
# start the checkout process and redirect_to the action
|
57
|
+
# specified by :start
|
58
|
+
def invoke
|
59
|
+
redirect_to_step(:start)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
# define a flow step
|
64
|
+
# on :start, :intro
|
65
|
+
# on :finish, :controller => "webshop", :action => "index"
|
66
|
+
#
|
67
|
+
def on(sym, hash)
|
68
|
+
steps.store( sym, hash )
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
def redirect_to_step(sym)
|
73
|
+
if steps.fetch(sym).kind_of?(Hash)
|
74
|
+
redirect_to steps.fetch(sym)
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
redirect_to :action => steps.fetch(sym)
|
79
|
+
end
|
80
|
+
|
81
|
+
def steps()
|
82
|
+
@_steps ||= {}
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|