opensteam 0.9.0 → 0.9.1
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 +78 -0
- data/LICENSE +345 -0
- data/{README.txt → README.rdoc} +20 -17
- data/Rakefile +40 -0
- data/generators/opensteam/opensteam_generator.rb +95 -194
- data/generators/opensteam/templates/{controllers/administration → app/controllers/admin}/inventories_controller.rb +4 -4
- data/generators/opensteam/templates/app/controllers/admin/invoices_controller.rb +106 -0
- data/generators/opensteam/templates/app/controllers/admin/orders_controller.rb +113 -0
- data/generators/opensteam/templates/app/controllers/admin/search_controller.rb +17 -0
- data/generators/opensteam/templates/app/controllers/admin/shipments_controller.rb +106 -0
- data/generators/opensteam/templates/app/controllers/admin/users_controller.rb +99 -0
- data/generators/opensteam/templates/app/controllers/admin_controller.rb +40 -0
- data/generators/opensteam/templates/app/controllers/cart_controller.rb +94 -0
- data/generators/opensteam/templates/app/controllers/checkout_controller.rb +139 -0
- data/generators/opensteam/templates/app/controllers/profile/infos_controller.rb +52 -0
- data/generators/opensteam/templates/app/controllers/profile/orders_controller.rb +105 -0
- data/generators/opensteam/templates/app/controllers/profile_controller.rb +37 -0
- data/generators/opensteam/templates/app/controllers/searches_controller.rb +23 -0
- data/generators/opensteam/templates/app/controllers/user_sessions_controller.rb +38 -0
- data/generators/opensteam/templates/app/controllers/users_controller.rb +40 -0
- data/generators/opensteam/templates/{controllers → app/controllers}/webshop_controller.rb +35 -13
- data/generators/opensteam/templates/app/helpers/admin_helper.rb +40 -0
- data/generators/opensteam/templates/app/helpers/users_helper.rb +53 -0
- data/generators/opensteam/templates/app/helpers/webshop_helper.rb +91 -0
- data/generators/opensteam/templates/app/models/search.rb +36 -0
- data/generators/opensteam/templates/{views/administration → app/views/admin}/_address.html.erb +0 -0
- data/generators/opensteam/templates/app/views/admin/_nav.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/catalog.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/index.html.erb +21 -0
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/edit.html.erb +10 -9
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/index.html.erb +3 -3
- data/generators/opensteam/templates/{views/administration → app/views/admin}/inventories/new.html.erb +3 -3
- data/generators/opensteam/templates/app/views/admin/inventories/show.html.erb +46 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoices.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/invoices/index.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/invoices/new.html.erb +54 -0
- data/generators/opensteam/templates/app/views/admin/invoices/show.html.erb +55 -0
- data/generators/opensteam/templates/app/views/admin/orders/_event.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order_item.html.erb +10 -0
- data/generators/opensteam/templates/app/views/admin/orders/_orders.html.erb +19 -0
- data/generators/opensteam/templates/app/views/admin/orders/index.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/orders/livesearch.rjs +6 -0
- data/generators/opensteam/templates/app/views/admin/orders/show.html.erb +58 -0
- data/generators/opensteam/templates/app/views/admin/products.html.erb +8 -0
- data/generators/opensteam/templates/app/views/admin/properties.html.erb +7 -0
- data/generators/opensteam/templates/app/views/admin/sales.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/shipments/_shipment.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/shipments/_shipments.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/shipments/index.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/shipments/new.html.erb +51 -0
- data/generators/opensteam/templates/app/views/admin/shipments/show.html.erb +55 -0
- data/generators/opensteam/templates/app/views/admin/users/_admins.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/users/_admins_header.html.erb +10 -0
- data/generators/opensteam/templates/app/views/admin/users/_customer.html.erb +32 -0
- data/generators/opensteam/templates/app/views/admin/users/_customers.html.erb +29 -0
- data/generators/opensteam/templates/app/views/admin/users/_customers_header.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/users/_user_fields.html.erb +9 -0
- data/generators/opensteam/templates/app/views/admin/users/_users.html.erb +29 -0
- data/generators/opensteam/templates/app/views/admin/users/_users_header.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/users/edit.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/users/index.html.erb +7 -0
- data/generators/opensteam/templates/app/views/admin/users/new.html.erb +6 -0
- data/generators/opensteam/templates/app/views/admin/users/show.html.erb +34 -0
- data/generators/opensteam/templates/app/views/admin/users.html.erb +4 -0
- data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_admin.erb +0 -0
- data/generators/opensteam/templates/{views → app/views}/administration_mailer/order_customer.erb +0 -0
- data/generators/opensteam/templates/app/views/cart/_cart.html.erb +8 -0
- data/generators/opensteam/templates/{views/webshop → app/views/cart}/_cart_content.html.erb +7 -10
- data/generators/opensteam/templates/app/views/cart/index.html.erb +5 -0
- data/generators/opensteam/templates/app/views/cart/update.rjs +1 -0
- data/generators/opensteam/templates/app/views/checkout/intro.html.erb +18 -0
- data/generators/opensteam/templates/{views → app/views}/checkout/outro.html.erb +0 -1
- data/generators/opensteam/templates/{views → app/views}/checkout/payment.html.erb +0 -0
- data/generators/opensteam/templates/app/views/checkout/shipping.html.erb +45 -0
- data/generators/opensteam/templates/app/views/checkout/show_cart.html.erb +13 -0
- data/generators/opensteam/templates/{views → app/views}/checkout/update_cart_content.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/common/_cart.html.erb +2 -2
- data/generators/opensteam/templates/{views → app/views}/common/_cart_content.html.erb +1 -1
- data/generators/opensteam/templates/app/views/common/_footer.html.erb +1 -0
- data/generators/opensteam/templates/app/views/common/_header.html.erb +4 -0
- data/generators/opensteam/templates/app/views/common/_header_flash.html.erb +3 -0
- data/generators/opensteam/templates/app/views/common/_signup_fields.html.erb +16 -0
- data/generators/opensteam/templates/app/views/common/_top_links.html.erb +10 -0
- data/generators/opensteam/templates/app/views/layouts/admin.html.erb +45 -0
- data/generators/opensteam/templates/app/views/layouts/profile.html.erb +45 -0
- data/generators/opensteam/templates/app/views/layouts/webshop.html.erb +51 -0
- data/generators/opensteam/templates/app/views/profile/_customer_sidebar.html.erb +12 -0
- data/generators/opensteam/templates/app/views/profile/index.html.erb +11 -0
- data/generators/opensteam/templates/app/views/profile/infos/_customer.html.erb +5 -0
- data/generators/opensteam/templates/app/views/profile/infos/edit.html.erb +25 -0
- data/generators/opensteam/templates/app/views/profile/infos/edit_password.html.erb +26 -0
- data/generators/opensteam/templates/app/views/profile/orders/_order.html.erb +11 -0
- data/generators/opensteam/templates/app/views/profile/orders/_order_item.html.erb +10 -0
- data/generators/opensteam/templates/app/views/profile/orders/_orders.html.erb +19 -0
- data/generators/opensteam/templates/app/views/profile/orders/index.html.erb +14 -0
- data/generators/opensteam/templates/app/views/profile/orders/show.html.erb +48 -0
- data/generators/opensteam/templates/app/views/searches/_search_bar.html.erb +5 -0
- data/generators/opensteam/templates/app/views/searches/new.html.erb +23 -0
- data/generators/opensteam/templates/app/views/searches/show.html.erb +1 -0
- data/generators/opensteam/templates/app/views/user_sessions/new.html.erb +14 -0
- data/generators/opensteam/templates/app/views/users/_user_bar.html.erb +5 -0
- data/generators/opensteam/templates/app/views/users/index.html.erb +27 -0
- data/generators/opensteam/templates/app/views/users/new.html.erb +7 -0
- data/generators/opensteam/templates/app/views/users/show.html.erb +5 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/_inventory_content.html.erb +0 -0
- data/generators/opensteam/templates/app/views/webshop/_nav.html.erb +6 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/add_inventory_to_cart.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/add_to_cart_with_parameters.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/del_item.rjs +0 -0
- data/generators/opensteam/templates/app/views/webshop/index.html.erb +11 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/inventory.rjs +0 -0
- data/generators/opensteam/templates/{views → app/views}/webshop/show.html.erb +15 -15
- data/generators/opensteam/templates/config/initializers/init_states.rb +68 -0
- data/generators/opensteam/templates/{init → config/initializers}/opensteam.rb +6 -0
- data/generators/opensteam/templates/config/initializers/opensteam_model_tables.rb +57 -0
- data/generators/opensteam/templates/db/migrate/20080609095714_create_profiles.rb +14 -0
- data/generators/opensteam/templates/{migrations/create_sessions.rb → db/migrate/20080609095720_create_sessions.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080609095721_create_users.rb +29 -0
- data/generators/opensteam/templates/{migrations/create_addresses.rb → db/migrate/20080609095723_create_addresses.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_customers.rb → db/migrate/20080609095724_create_customers.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080609095725_create_dummy_users.rb +21 -0
- data/generators/opensteam/templates/{migrations/create_inventories.rb → db/migrate/20080609095726_create_inventories.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_inventories_properties.rb → db/migrate/20080609095727_create_inventories_properties.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_order_items.rb → db/migrate/20080609095728_create_order_items.rb} +5 -0
- data/generators/opensteam/templates/db/migrate/20080609095729_create_orders.rb +32 -0
- data/generators/opensteam/templates/{migrations/create_payment_types.rb → db/migrate/20080609095730_create_payment_types.rb} +0 -0
- data/generators/opensteam/templates/{migrations/create_properties.rb → db/migrate/20080609095731_create_properties.rb} +0 -0
- data/generators/opensteam/templates/db/migrate/20080623075613_create_states.rb +13 -0
- data/generators/opensteam/templates/db/migrate/20080624132807_create_searches.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080630114155_create_state_histories.rb +14 -0
- data/generators/opensteam/templates/db/migrate/20080714131513_create_invoices.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080714131650_create_shipments.rb +19 -0
- data/generators/opensteam/templates/lib/authenticated_system.rb +201 -0
- data/generators/opensteam/templates/lib/authentication/by_cookie_token.rb +90 -0
- data/generators/opensteam/templates/lib/authentication/by_password.rb +68 -0
- data/generators/opensteam/templates/lib/authentication.rb +46 -0
- data/generators/opensteam/templates/lib/states/invoice/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/invoice/payment_received.rb +8 -0
- data/generators/opensteam/templates/lib/states/invoice/pending.rb +6 -0
- data/generators/opensteam/templates/lib/states/invoice/waiting_for_payment.rb +5 -0
- data/generators/opensteam/templates/lib/states/order/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/order/pending.rb +19 -0
- data/generators/opensteam/templates/lib/states/order/processing.rb +11 -0
- data/generators/opensteam/templates/lib/states/shipment/finished.rb +6 -0
- data/generators/opensteam/templates/lib/states/shipment/pending.rb +5 -0
- data/generators/opensteam/templates/lib/tasks/opensteam.rake +114 -0
- data/generators/opensteam/templates/public/images/athmo_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/bg.jpg +0 -0
- data/generators/opensteam/templates/public/images/cart_big.gif +0 -0
- data/generators/opensteam/templates/public/images/cross.png +0 -0
- data/generators/opensteam/templates/public/images/enter.gif +0 -0
- data/generators/opensteam/templates/public/images/menu_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_background.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_logo1.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_petstore_logo1.jpg +0 -0
- data/generators/opensteam/templates/public/images/opensteam_store_logo.jpg +0 -0
- data/generators/opensteam/templates/public/images/os_logo.gif +0 -0
- data/generators/opensteam/templates/public/images/slogan.png +0 -0
- data/generators/opensteam/templates/public/images/tick.png +0 -0
- data/generators/opensteam/templates/public/images/zoom.png +0 -0
- data/generators/opensteam/templates/public/index.html +19 -36
- data/generators/opensteam/templates/public/javascripts/opensteam.js +30 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_newdesign.css +188 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_white.css +168 -0
- data/generators/opensteam/templates/public/stylesheets/webshop.css +0 -1
- data/generators/opensteam/templates/tasks/opensteam.rake +1 -1
- data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/inventories_properties.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/product_animals.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/product_dog_foods.yml +0 -0
- data/generators/opensteam/templates/{fixtures → test/fixtures}/properties.yml +0 -0
- data/generators/opensteam_product/opensteam_product_generator.rb +25 -9
- data/generators/opensteam_product/templates/controllers/product_controller.rb +5 -4
- data/generators/opensteam_product/templates/migration.rb +2 -1
- data/generators/opensteam_product/templates/models/product.rb +1 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/_attributes.html.erb +1 -1
- data/generators/opensteam_product/templates/views/{administration → admin}/_get_products.html.erb +0 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/_inventories.html.erb +2 -2
- data/generators/opensteam_product/templates/views/admin/edit.html.erb +13 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/index.html.erb +5 -5
- data/generators/opensteam_product/templates/views/admin/new.html.erb +16 -0
- data/generators/opensteam_product/templates/views/{administration → admin}/show.html.erb +2 -2
- data/generators/opensteam_property/opensteam_property_generator.rb +8 -8
- data/generators/opensteam_property/templates/controllers/property_controller.rb +6 -4
- data/generators/opensteam_property/templates/migration.rb +2 -1
- data/generators/opensteam_property/templates/models/property.rb +1 -0
- data/generators/opensteam_property/templates/views/{administration → admin}/edit.html.erb +3 -3
- data/generators/opensteam_property/templates/views/admin/index.html.erb +24 -0
- data/generators/opensteam_property/templates/views/{administration → admin}/new.html.erb +2 -2
- data/generators/opensteam_property/templates/views/admin/show.html.erb +10 -0
- data/lib/opensteam/base.rb +16 -0
- data/lib/opensteam/cart_base.rb +227 -0
- data/lib/opensteam/checkout.rb +30 -3
- data/lib/opensteam/config.rb +37 -0
- data/lib/opensteam/extension_base.rb +76 -0
- data/lib/opensteam/finder.rb +36 -5
- data/lib/opensteam/helper/configurable_table.rb +228 -0
- data/lib/opensteam/history.rb +56 -0
- data/lib/opensteam/initializer.rb +127 -0
- data/lib/opensteam/inventory_base.rb +24 -1
- data/lib/opensteam/invoice_base.rb +61 -0
- data/lib/opensteam/order_base.rb +105 -14
- data/lib/opensteam/product_base.rb +31 -3
- data/lib/opensteam/property_base.rb +16 -0
- data/lib/opensteam/shipment_base.rb +60 -0
- data/lib/opensteam/shopping_cart.rb +32 -14
- data/lib/opensteam/state_logic.rb +218 -0
- data/lib/opensteam/state_machine.rb +216 -0
- data/lib/opensteam/user_base.rb +115 -131
- data/lib/opensteam/version.rb +17 -1
- data/lib/opensteam.rb +30 -35
- metadata +245 -146
- data/History.txt +0 -0
- data/License.txt +0 -4
- data/Manifest.txt +0 -131
- data/Manifest.txt.bak +0 -132
- data/generators/opensteam/templates/controllers/administration/customers_controller.rb +0 -23
- data/generators/opensteam/templates/controllers/administration/orders_controller.rb +0 -61
- data/generators/opensteam/templates/controllers/administration_controller.rb +0 -80
- data/generators/opensteam/templates/controllers/checkout_controller.rb +0 -142
- data/generators/opensteam/templates/helpers/webshop_helper.rb +0 -29
- data/generators/opensteam/templates/migrations/create_dummy_users.rb +0 -16
- data/generators/opensteam/templates/migrations/create_orders.rb +0 -18
- data/generators/opensteam/templates/migrations/create_users.rb +0 -19
- data/generators/opensteam/templates/models/administration_mailer.rb +0 -18
- data/generators/opensteam/templates/models/inventories_property.rb +0 -10
- data/generators/opensteam/templates/models/inventory.rb +0 -57
- data/generators/opensteam/templates/public/images/rails.png +0 -0
- data/generators/opensteam/templates/views/administration/_nav.html.erb +0 -11
- data/generators/opensteam/templates/views/administration/_update_tree.html.erb +0 -18
- data/generators/opensteam/templates/views/administration/admin_info.html.erb +0 -12
- data/generators/opensteam/templates/views/administration/customers/index.html.erb +0 -27
- data/generators/opensteam/templates/views/administration/customers/show.html.erb +0 -27
- data/generators/opensteam/templates/views/administration/customers.html.erb +0 -44
- data/generators/opensteam/templates/views/administration/index.html.erb +0 -9
- data/generators/opensteam/templates/views/administration/inventories/show.html.erb +0 -45
- data/generators/opensteam/templates/views/administration/login.html.erb +0 -16
- data/generators/opensteam/templates/views/administration/order.html.erb +0 -22
- data/generators/opensteam/templates/views/administration/orders/_order_item.html.erb +0 -22
- data/generators/opensteam/templates/views/administration/orders/index.html.erb +0 -32
- data/generators/opensteam/templates/views/administration/orders/show.html.erb +0 -25
- data/generators/opensteam/templates/views/administration/orders.html.erb +0 -32
- data/generators/opensteam/templates/views/administration/products.html.erb +0 -7
- data/generators/opensteam/templates/views/administration/properties.html.erb +0 -7
- data/generators/opensteam/templates/views/administration/show_order_item.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/signup.html.erb +0 -65
- data/generators/opensteam/templates/views/administration/tree.html.erb +0 -15
- data/generators/opensteam/templates/views/administration/update_products.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/update_properties.html.erb +0 -5
- data/generators/opensteam/templates/views/administration/update_tree.rjs +0 -3
- data/generators/opensteam/templates/views/checkout/intro.html.erb +0 -5
- data/generators/opensteam/templates/views/checkout/shipping.html.erb +0 -39
- data/generators/opensteam/templates/views/checkout/show_cart.html.erb +0 -13
- data/generators/opensteam/templates/views/common/_header.html.erb +0 -15
- data/generators/opensteam/templates/views/layouts/administration.html.erb +0 -29
- data/generators/opensteam/templates/views/layouts/webshop.html.erb +0 -36
- data/generators/opensteam/templates/views/webshop/_cart.html.erb +0 -11
- data/generators/opensteam/templates/views/webshop/_header.html.erb +0 -15
- data/generators/opensteam/templates/views/webshop/index.html.erb +0 -12
- data/generators/opensteam_product/templates/views/administration/edit.html.erb +0 -13
- data/generators/opensteam_product/templates/views/administration/new.html.erb +0 -16
- data/generators/opensteam_property/templates/views/administration/index.html.erb +0 -24
- data/generators/opensteam_property/templates/views/administration/show.html.erb +0 -10
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:object => @product,
|
|
6
6
|
:locals => { :f => f, :cart_details => @cart_details } ) %>
|
|
7
7
|
<%% end %>
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
<br />
|
|
10
10
|
|
|
11
11
|
<span id="indicator" style="margin-top:0px; display:none"><%%= image_tag "indicator.gif" %>checking inventory...</span>
|
|
@@ -13,28 +13,28 @@
|
|
|
13
13
|
<%%- if @inventory.empty? -%>
|
|
14
14
|
<b>Please select a configuration</b>
|
|
15
15
|
<%%- else -%>
|
|
16
|
-
<%%= render :partial => "inventory_content", :collection => @inventory %>
|
|
16
|
+
<%%= render :partial => "<%= file_name %>/inventory_content", :collection => @inventory %>
|
|
17
17
|
<%%- end -%>
|
|
18
18
|
</div>
|
|
19
19
|
<br />
|
|
20
20
|
<br />
|
|
21
|
-
|
|
22
|
-
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
25
|
<%%- unless @cart_details -%><%%= submit_tag "add to cart" %><%%- end -%>
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
<%% end %>
|
|
28
|
-
|
|
29
|
-
<%%= observe_form "show",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
|
|
29
|
+
<%%= observe_form "show",
|
|
30
|
+
:url => { :action => :inventory },
|
|
31
|
+
:loading => "Element.show('indicator')",
|
|
32
|
+
:complete => "Element.hide('indicator')"
|
|
33
33
|
%>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<%%= link_to 'Index',
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<%%= link_to 'Index', shop_index_path %>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
40
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
if defined? RAILS_ROOT
|
|
3
|
+
|
|
4
|
+
Dir.glob("#{RAILS_ROOT}/lib/states/**/*.rb").collect { |f|
|
|
5
|
+
require f
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Order.class_eval do
|
|
14
|
+
include OrderStates::Finished
|
|
15
|
+
include OrderStates::Pending
|
|
16
|
+
include OrderStates::Processing
|
|
17
|
+
|
|
18
|
+
named_scope :open, :conditions => ["orders.state is not ?", :finished]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
initial_state :pending
|
|
22
|
+
|
|
23
|
+
observe do |record|
|
|
24
|
+
if record.shipments.all_finished? && record.invoices.all_finished? &&
|
|
25
|
+
record.order_items.all_invoiced? && record.order_items.all_shipped?
|
|
26
|
+
|
|
27
|
+
record.state = :finished unless record.state.to_sym == :finished
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# States for Opensteam::ShipmentBase::Shipment
|
|
36
|
+
Shipment.class_eval do
|
|
37
|
+
include ShipmentStates::Pending
|
|
38
|
+
include ShipmentStates::Finished
|
|
39
|
+
|
|
40
|
+
initial_state :pending
|
|
41
|
+
|
|
42
|
+
observe do |record|
|
|
43
|
+
notify :order
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# States for Opensteam::InvoiceBase::Invoice
|
|
49
|
+
Invoice.class_eval do
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
include InvoiceStates::WaitingForPayment
|
|
55
|
+
include InvoiceStates::PaymentReceived
|
|
56
|
+
include InvoiceStates::Pending
|
|
57
|
+
include InvoiceStates::Finished
|
|
58
|
+
|
|
59
|
+
initial_state :pending
|
|
60
|
+
|
|
61
|
+
observe do |record|
|
|
62
|
+
notify :order
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Order.class_eval do
|
|
2
|
+
|
|
3
|
+
include Opensteam::Helper::ConfigurableTable
|
|
4
|
+
|
|
5
|
+
configure_table :order do
|
|
6
|
+
default_sort_col :id
|
|
7
|
+
column :id, :name => "#"
|
|
8
|
+
column :order_items, :name => "OrderItems", :method => :size
|
|
9
|
+
column :customer, :name => "Customer", :method => :email
|
|
10
|
+
column :shipping_address, :name => "Shipping Address", :method => :to_s
|
|
11
|
+
column :payment_address, :name => "Payment Address", :method => :to_s
|
|
12
|
+
column :state, :name => "State"
|
|
13
|
+
column :created_at, :name => "Created"
|
|
14
|
+
column :updated_at, :name => "Updated"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Shipment.class_eval do
|
|
22
|
+
|
|
23
|
+
include Opensteam::Helper::ConfigurableTable
|
|
24
|
+
|
|
25
|
+
configure_table :shipment do
|
|
26
|
+
default_sort_col :id
|
|
27
|
+
column :id, :name => "#"
|
|
28
|
+
column :order_items, :name => "OrderItems", :method => :size
|
|
29
|
+
column :address, :name => "Address", :method => :to_s
|
|
30
|
+
column :state, :name => "State"
|
|
31
|
+
column :comment, :name => "Comment"
|
|
32
|
+
column :created_at, :name => "Created"
|
|
33
|
+
column :updated_at, :name => "Updated"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Invoice.class_eval do
|
|
41
|
+
|
|
42
|
+
include Opensteam::Helper::ConfigurableTable
|
|
43
|
+
|
|
44
|
+
configure_table :invoices do
|
|
45
|
+
default_sort_col :id
|
|
46
|
+
column :id, :name => "#"
|
|
47
|
+
column :order_items, :name => "OrderItems", :method => :size
|
|
48
|
+
column :address, :name => "Address", :method => :to_s
|
|
49
|
+
column :state, :name => "State"
|
|
50
|
+
column :comment, :name => "Comment"
|
|
51
|
+
column :price, :name => "Price"
|
|
52
|
+
column :created_at, :name => "Created"
|
|
53
|
+
column :updated_at, :name => "Updated"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table "users", :force => true do |t|
|
|
4
|
+
# t.column :login, :string, :limit => 40
|
|
5
|
+
t.column :email, :string, :limit => 100
|
|
6
|
+
t.column :crypted_password, :string, :limit => 40
|
|
7
|
+
t.column :salt, :string, :limit => 40
|
|
8
|
+
t.column :created_at, :datetime
|
|
9
|
+
t.column :updated_at, :datetime
|
|
10
|
+
t.column :remember_token, :string, :limit => 40
|
|
11
|
+
t.column :remember_token_expires_at, :datetime
|
|
12
|
+
|
|
13
|
+
# t.string :type, :default => "Customer"
|
|
14
|
+
|
|
15
|
+
t.references :profile
|
|
16
|
+
t.string :firstname, :limit => 100
|
|
17
|
+
t.string :lastname, :limit => 100
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
add_index :users, :email, :unique => true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.down
|
|
27
|
+
drop_table "users"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class CreateOrders < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :orders, :id => false, :force => true do |t|
|
|
4
|
+
t.string :id, :null => false
|
|
5
|
+
t.references :customer
|
|
6
|
+
|
|
7
|
+
t.references :payment_type
|
|
8
|
+
|
|
9
|
+
t.references :shipping_address
|
|
10
|
+
t.references :payment_address
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#t.references :state
|
|
14
|
+
t.string :state
|
|
15
|
+
|
|
16
|
+
t.integer :workflow_id
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
#
|
|
20
|
+
# t.references :fulfillment_state
|
|
21
|
+
# t.references :payment_state
|
|
22
|
+
|
|
23
|
+
t.text :description
|
|
24
|
+
|
|
25
|
+
t.timestamps
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.down
|
|
30
|
+
drop_table :orders
|
|
31
|
+
end
|
|
32
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateSearches < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :searches do |t|
|
|
4
|
+
t.string :keywords
|
|
5
|
+
t.string :properties
|
|
6
|
+
t.float :minimum_price
|
|
7
|
+
t.float :maximum_price
|
|
8
|
+
t.integer :minimum_storage
|
|
9
|
+
t.integer :maximum_storage
|
|
10
|
+
|
|
11
|
+
t.string :kind
|
|
12
|
+
t.references :customer
|
|
13
|
+
t.timestamps
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.down
|
|
18
|
+
drop_table :searches
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateInvoices < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :invoices do |t|
|
|
4
|
+
t.float :price
|
|
5
|
+
t.text :comment
|
|
6
|
+
|
|
7
|
+
t.references :customer
|
|
8
|
+
t.references :order
|
|
9
|
+
t.references :address
|
|
10
|
+
|
|
11
|
+
t.string :state
|
|
12
|
+
|
|
13
|
+
t.timestamps
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.down
|
|
18
|
+
drop_table :invoices
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class CreateShipments < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :shipments do |t|
|
|
4
|
+
t.text :comment
|
|
5
|
+
|
|
6
|
+
t.string :state
|
|
7
|
+
|
|
8
|
+
t.references :order
|
|
9
|
+
t.references :address
|
|
10
|
+
t.references :customer
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.down
|
|
17
|
+
drop_table :shipments
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# borrowed from the Restful Authentication Generator
|
|
2
|
+
# git://github.com/technoweenie/restful-authentication.git
|
|
3
|
+
|
|
4
|
+
module AuthenticatedSystem
|
|
5
|
+
protected
|
|
6
|
+
# Returns true or false if the user is logged in.
|
|
7
|
+
# Preloads @current_user with the user model if they're logged in.
|
|
8
|
+
def logged_in?
|
|
9
|
+
!!current_user
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def is_admin?
|
|
14
|
+
return false unless logged_in?
|
|
15
|
+
current_user.is_admin?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def is_customer?
|
|
20
|
+
current_user.is_customer?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Accesses the current user from the session.
|
|
24
|
+
# Future calls avoid the database because nil is not equal to false.
|
|
25
|
+
def current_user
|
|
26
|
+
@current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Store the given user id in the session.
|
|
30
|
+
def current_user=(new_user)
|
|
31
|
+
session[:user_id] = new_user ? new_user.id : nil
|
|
32
|
+
@current_user = new_user || false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Check if the user is authorized
|
|
36
|
+
#
|
|
37
|
+
# Override this method in your controllers if you want to restrict access
|
|
38
|
+
# to only a few actions or if you want to check if the user
|
|
39
|
+
# has the correct rights.
|
|
40
|
+
#
|
|
41
|
+
# Example:
|
|
42
|
+
#
|
|
43
|
+
# # only allow nonbobs
|
|
44
|
+
# def authorized?
|
|
45
|
+
# current_user.login != "bob"
|
|
46
|
+
# end
|
|
47
|
+
#
|
|
48
|
+
def authorized?(action=nil, resource=nil, *args)
|
|
49
|
+
logged_in?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Filter method to enforce a login requirement.
|
|
53
|
+
#
|
|
54
|
+
# To require logins for all actions, use this in your controllers:
|
|
55
|
+
#
|
|
56
|
+
# before_filter :login_required
|
|
57
|
+
#
|
|
58
|
+
# To require logins for specific actions, use this in your controllers:
|
|
59
|
+
#
|
|
60
|
+
# before_filter :login_required, :only => [ :edit, :update ]
|
|
61
|
+
#
|
|
62
|
+
# To skip this in a subclassed controller:
|
|
63
|
+
#
|
|
64
|
+
# skip_before_filter :login_required
|
|
65
|
+
#
|
|
66
|
+
def login_required
|
|
67
|
+
authorized? || access_denied
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Redirect as appropriate when an access request fails.
|
|
71
|
+
#
|
|
72
|
+
# The default action is to redirect to the login screen.
|
|
73
|
+
#
|
|
74
|
+
# Override this method in your controllers if you want to have special
|
|
75
|
+
# behavior in case the user is not authorized
|
|
76
|
+
# to access the requested action. For example, a popup window might
|
|
77
|
+
# simply close itself.
|
|
78
|
+
def access_denied
|
|
79
|
+
respond_to do |format|
|
|
80
|
+
format.html do
|
|
81
|
+
store_location
|
|
82
|
+
redirect_to new_user_session_path
|
|
83
|
+
end
|
|
84
|
+
# format.any doesn't work in rails version < http://dev.rubyonrails.org/changeset/8987
|
|
85
|
+
# you may want to change format.any to e.g. format.any(:js, :xml)
|
|
86
|
+
format.any do
|
|
87
|
+
request_http_basic_authentication 'Web Password'
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Store the URI of the current request in the session.
|
|
93
|
+
#
|
|
94
|
+
# We can return to this location by calling #redirect_back_or_default.
|
|
95
|
+
def store_location
|
|
96
|
+
session[:return_to] = request.request_uri
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Redirect to the URI stored by the most recent store_location call or
|
|
100
|
+
# to the passed default. Set an appropriately modified
|
|
101
|
+
# after_filter :store_location, :only => [:index, :new, :show, :edit]
|
|
102
|
+
# for any controller you want to be bounce-backable.
|
|
103
|
+
def redirect_back_or_default(default)
|
|
104
|
+
redirect_to(session[:return_to] || default)
|
|
105
|
+
session[:return_to] = nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Inclusion hook to make #current_user and #logged_in?
|
|
109
|
+
# available as ActionView helper methods.
|
|
110
|
+
def self.included(base)
|
|
111
|
+
base.send :helper_method, :current_user, :logged_in?, :authorized? if base.respond_to? :helper_method
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# Login
|
|
116
|
+
#
|
|
117
|
+
|
|
118
|
+
# Called from #current_user. First attempt to login by the user id stored in the session.
|
|
119
|
+
def login_from_session
|
|
120
|
+
self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Called from #current_user. Now, attempt to login by basic authentication information.
|
|
124
|
+
def login_from_basic_auth
|
|
125
|
+
authenticate_with_http_basic do |login, password|
|
|
126
|
+
self.current_user = User.authenticate(login, password)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
#
|
|
131
|
+
# Logout
|
|
132
|
+
#
|
|
133
|
+
|
|
134
|
+
# Called from #current_user. Finaly, attempt to login by an expiring token in the cookie.
|
|
135
|
+
# for the paranoid: we _should_ be storing user_token = hash(cookie_token, request IP)
|
|
136
|
+
def login_from_cookie
|
|
137
|
+
user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])
|
|
138
|
+
if user && user.remember_token?
|
|
139
|
+
self.current_user = user
|
|
140
|
+
handle_remember_cookie! false # freshen cookie token (keeping date)
|
|
141
|
+
self.current_user
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# This is ususally what you want; resetting the session willy-nilly wreaks
|
|
146
|
+
# havoc with forgery protection, and is only strictly necessary on login.
|
|
147
|
+
# However, **all session state variables should be unset here**.
|
|
148
|
+
def logout_keeping_session!
|
|
149
|
+
# Kill server-side auth cookie
|
|
150
|
+
@current_user.forget_me if @current_user.is_a? User
|
|
151
|
+
@current_user = false # not logged in, and don't do it for me
|
|
152
|
+
kill_remember_cookie! # Kill client-side auth cookie
|
|
153
|
+
session[:user_id] = nil # keeps the session but kill our variable
|
|
154
|
+
# explicitly kill any other session variables you set
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# The session should only be reset at the tail end of a form POST --
|
|
158
|
+
# otherwise the request forgery protection fails. It's only really necessary
|
|
159
|
+
# when you cross quarantine (logged-out to logged-in).
|
|
160
|
+
def logout_killing_session!
|
|
161
|
+
logout_keeping_session!
|
|
162
|
+
reset_session
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
#
|
|
166
|
+
# Remember_me Tokens
|
|
167
|
+
#
|
|
168
|
+
# Cookies shouldn't be allowed to persist past their freshness date,
|
|
169
|
+
# and they should be changed at each login
|
|
170
|
+
|
|
171
|
+
# Cookies shouldn't be allowed to persist past their freshness date,
|
|
172
|
+
# and they should be changed at each login
|
|
173
|
+
|
|
174
|
+
def valid_remember_cookie?
|
|
175
|
+
return nil unless @current_user
|
|
176
|
+
(@current_user.remember_token?) &&
|
|
177
|
+
(cookies[:auth_token] == @current_user.remember_token)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Refresh the cookie auth token if it exists, create it otherwise
|
|
181
|
+
def handle_remember_cookie! new_cookie_flag
|
|
182
|
+
return unless @current_user
|
|
183
|
+
case
|
|
184
|
+
when valid_remember_cookie? then @current_user.refresh_token # keeping same expiry date
|
|
185
|
+
when new_cookie_flag then @current_user.remember_me
|
|
186
|
+
else @current_user.forget_me
|
|
187
|
+
end
|
|
188
|
+
send_remember_cookie!
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def kill_remember_cookie!
|
|
192
|
+
cookies.delete :auth_token
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def send_remember_cookie!
|
|
196
|
+
cookies[:auth_token] = {
|
|
197
|
+
:value => @current_user.remember_token,
|
|
198
|
+
:expires => @current_user.remember_token_expires_at }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
end
|