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,15 @@
|
|
1
|
+
<div id="product_tree">
|
2
|
+
<% for c in @productclasses %>
|
3
|
+
<div sid="<%= c %>">
|
4
|
+
<%= link_to_remote (image_tag "/images/plus.png", :id => "tree_image_#{c}", :align => "top", :border => "0"),
|
5
|
+
:url => { :action => "update_tree", :class => c }
|
6
|
+
%>
|
7
|
+
<%= c %>
|
8
|
+
<div style="padding-left:21px;" id="product<%= c %>">
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
<br />
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
A New Order!
|
2
|
+
|
3
|
+
from: <%=h @order.customer.firstname %> <%=h @order.customer.lastname %> (<%= @order.customer.email %>)
|
4
|
+
submitted at <%=h @order.created_at %>
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
the order:
|
9
|
+
<% for order_item in @order.order_items %>
|
10
|
+
- <%= order_item.inventory.product.class.to_s %> "<%= order_item.inventory.product.name %>" x <%= order_item.quantity %>
|
11
|
+
(<%= order_item.inventory.properties.collect(&:name) * "," %>)
|
12
|
+
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
Total Price: <%= @order.order_items.collect(&:inventory).collect(&:price).inject(&:+) %>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
the Payment Address:
|
20
|
+
<%= @order.payment_address.street %>
|
21
|
+
<%= @order.payment_address.postal %> <%= @order.payment_address.city %>
|
22
|
+
<%= @order.payment_address.land %>
|
23
|
+
|
24
|
+
the Shipping Address:
|
25
|
+
<%= @order.shipping_address.street %>
|
26
|
+
<%= @order.shipping_address.postal %> <%= @order.shipping_address.city %>
|
27
|
+
<%= @order.shipping_address.land %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Dear <%=h @order.customer.firstname %> <%=h @order.customer.lastname %> (<%= @order.customer.email %>),
|
2
|
+
|
3
|
+
Thank you for you order @ the Opensteam-Petstore.
|
4
|
+
|
5
|
+
Your order:
|
6
|
+
<% for order_item in @order.order_items %>
|
7
|
+
- <%= order_item.inventory.product.class.to_s %> "<%= order_item.inventory.product.name %>" x <%= order_item.quantity %>
|
8
|
+
(<%= order_item.inventory.properties.collect(&:name) * "," %>)
|
9
|
+
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
Total Price: <%= @order.order_items.collect(&:inventory).collect(&:price).inject(&:+) %>
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
Your Payment Address:
|
17
|
+
<%= @order.payment_address.street %>
|
18
|
+
<%= @order.payment_address.postal %> <%= @order.payment_address.city %>
|
19
|
+
<%= @order.payment_address.land %>
|
20
|
+
|
21
|
+
Your Shipping Address:
|
22
|
+
<%= @order.shipping_address.street %>
|
23
|
+
<%= @order.shipping_address.postal %> <%= @order.shipping_address.city %>
|
24
|
+
<%= @order.shipping_address.land %>
|
@@ -0,0 +1,8 @@
|
|
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 %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<h1>welcome to shipping</h1>
|
2
|
+
-> session : <%=h session[:active_order] %><br />
|
3
|
+
|
4
|
+
<%= error_messages_for :customer %>
|
5
|
+
<%= error_messages_for :shipping_address %>
|
6
|
+
<%= error_messages_for :payment_address %>
|
7
|
+
|
8
|
+
|
9
|
+
<% form_for :customer, :url => { :action => :shipping } do |f| %>
|
10
|
+
<table>
|
11
|
+
<tr><td><b>Email</b></td><td><%= f.text_field :email %></td></tr>
|
12
|
+
<tr><td><b>Firstname</b></td><td><%= f.text_field :firstname %></td></tr>
|
13
|
+
<tr><td><b>Lastname</b></td><td><%= f.text_field :lastname %></td></tr>
|
14
|
+
</table>
|
15
|
+
<br />
|
16
|
+
<div id="customer_address">
|
17
|
+
<u>Shipping Address</u><br /><br />
|
18
|
+
<% fields_for :shipping_address, @shipping_address do |a| %>
|
19
|
+
<table>
|
20
|
+
<tr><td><b>Street</b></td><td><%= a.text_field :street %></td></tr>
|
21
|
+
<tr><td><b>ZIP</b></td><td><%= a.text_field :postal %></td></tr>
|
22
|
+
<tr><td><b>City</b></td><td><%= a.text_field :city %></td></tr>
|
23
|
+
<tr><td><b>Country</b></td><td><%= a.text_field :land %></td></tr>
|
24
|
+
</table>
|
25
|
+
<% end %>
|
26
|
+
<br /><br />
|
27
|
+
<u>Payment Address</u><br /><br />
|
28
|
+
<% fields_for :payment_address, @payment_address do |a| %>
|
29
|
+
<table>
|
30
|
+
<tr><td><b>Street</b></td><td><%= a.text_field :street %></td></tr>
|
31
|
+
<tr><td><b>ZIP</b></td><td><%= a.text_field :postal %></td></tr>
|
32
|
+
<tr><td><b>City</b></td><td><%= a.text_field :city %></td></tr>
|
33
|
+
<tr><td><b>Country</b></td><td><%= a.text_field :land %></td></tr>
|
34
|
+
</table>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<br /><br />
|
38
|
+
<%= link_to "prev", :action => :intro %> | <%= submit_tag "next" %>
|
39
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<b>Your Order</b>
|
2
|
+
-> session : <%%=h session[:active_order] %><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
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<b>shopping - cart </b>
|
2
|
+
<br />
|
3
|
+
<br />
|
4
|
+
<div id="cart_content">
|
5
|
+
<%= render :partial => "common/cart_content" %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<% if ! @cart.items.empty? %>
|
9
|
+
<%= button_to "checkout" , { :action => :start_checkout }, :confirm => "checkout?" %>
|
10
|
+
<%= button_to "empty cart" , { :action => :empty_cart }, :confirm => "empty cart?" %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% form_tag :action => :update_quantity 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, :action => :show_cart_item, :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 => { :action => :incr_quantity, :id => k, :type => i.product.class.to_s } -%>
|
7
|
+
<%= link_to_remote image_tag( "/images/minus.png", :border => "0"), :url => { :action => :decr_quantity, :id => k, :type => i.product.class.to_s } -%>
|
8
|
+
<%= link_to_remote image_tag( "/images/cancel.png", :border => "0"), :url => { :action => :del_item, :id => k, :type => i.product.class.to_s } %>
|
9
|
+
<br />
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
<% if ! @cart.items.empty? %>
|
13
|
+
<%= submit_tag "update" %> <br /> <br />
|
14
|
+
------
|
15
|
+
<br />
|
16
|
+
<b>Total Price</b>: <%=h @cart.total_price %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= link_to (image_tag "opensteam_logo_web.jpg", :border => "0", :align => "top"), shop_index_path %>
|
2
|
+
<% if session[:user_login] %>
|
3
|
+
logged in as <b><%=h session[:user_login] %></b>
|
4
|
+
(<%= Opensteam::UserBase::User.find(:first, :conditions => ["login = ?", session[:user_login] ]).class.to_s.demodulize %>)
|
5
|
+
| <%= link_to "logout", logout_path %>
|
6
|
+
<% if Opensteam::UserBase::User.find(:first, :conditions => ["login = ?", session[:user_login] ]).is_admin? %>
|
7
|
+
| <%= link_to "administration", administration_path %>
|
8
|
+
||
|
9
|
+
<% end %>
|
10
|
+
<% else %>
|
11
|
+
<%= link_to "login", login_path %>
|
12
|
+
<% end %>
|
13
|
+
<span style="color:red;"><%=h flash[:error] %></span>
|
14
|
+
<span style="color:green;"><%=h flash[:notice] %></span>
|
15
|
+
<span style="color:orange;"><%=h flash[:warning] %></span>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
+
<title>Products: <%%= controller.action_name %></title>
|
8
|
+
<%%= javascript_include_tag :defaults %>
|
9
|
+
<%%= stylesheet_link_tag '<%= file_name %>' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div id="indicator_center" style="display:none;"><%%= image_tag("indicator_big.gif") %></div>
|
13
|
+
<div id="header">
|
14
|
+
<%%= render :partial => "common/header" %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div id="catalog_content" style="width:80%;">
|
18
|
+
<div style="float:left;margin-left:20px;width:100%;">
|
19
|
+
<div class="sub_box" id="product_actions">
|
20
|
+
<%%= render :partial => "administration/nav" %>
|
21
|
+
</div>
|
22
|
+
<div class="sub_box" id="content">
|
23
|
+
<%%= yield %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
</body>
|
29
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
+
<title>Products: <%%= controller.action_name %></title>
|
8
|
+
<%%= javascript_include_tag :defaults %>
|
9
|
+
<%%= stylesheet_link_tag '<%= file_name %>' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<div id="header">
|
14
|
+
<%%= render :partial => "common/header" %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<br />
|
18
|
+
|
19
|
+
<div id="page">
|
20
|
+
|
21
|
+
<div id="content">
|
22
|
+
|
23
|
+
<%% if controller.controller_name == '<%= file_name %>' %>
|
24
|
+
<div id="cart">
|
25
|
+
<%%= render :partial => "common/cart", :object => @cart %>
|
26
|
+
</div>
|
27
|
+
<%% end %>
|
28
|
+
|
29
|
+
<%%= yield %>
|
30
|
+
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</div>
|
35
|
+
</body>
|
36
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<b>shopping - cart </b>
|
2
|
+
<br />
|
3
|
+
<br />
|
4
|
+
<div id="cart_content">
|
5
|
+
<%= render :partial => "cart_content" %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<% if ! @cart.items.empty? %>
|
9
|
+
<%= button_to "checkout" , { :action => :start_checkout }, :confirm => "checkout?" %>
|
10
|
+
<%= button_to "empty cart" , { :action => :empty_cart }, :confirm => "empty cart?" %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% form_tag :action => :update_quantity 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, :action => :show_cart_item, :id => k %> : <%=h i.quantity -%>
|
5
|
+
<%= text_field_tag "quantity[#{k}]", i.quantity.to_s, :id => "qunt", :size => 5 -%>
|
6
|
+
<%= link_to_remote image_tag( "/images/plus.png", :border => "0" ), :url => { :action => :incr_quantity, :id => k },
|
7
|
+
:update => :cart_content -%>
|
8
|
+
<%= link_to_remote image_tag( "/images/minus.png", :border => "0"), :url => { :action => :decr_quantity, :id => k },
|
9
|
+
:update => :cart_content -%>
|
10
|
+
<%= link_to_remote image_tag( "/images/cancel.png", :border => "0"), :url => { :action => :del_item, :id => k } %>
|
11
|
+
<br />
|
12
|
+
<%=h(k) %> => <%= h i.to_yaml %>
|
13
|
+
<br /><br />
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
<% if ! @cart.items.empty? %>
|
17
|
+
<%= submit_tag "update" %> <br /> <br />
|
18
|
+
------
|
19
|
+
<br />
|
20
|
+
<b>Total Price</b>: <%=h @cart.total_price %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= link_to (image_tag "opensteam_logo_web.jpg", :border => "0", :align => "top"), shop_index_path %>
|
2
|
+
<% if session[:user_login] %>
|
3
|
+
logged in as <b><%=h session[:user_login] %></b>
|
4
|
+
(<%= Opensteam::UserBase::User.find(:first, :conditions => ["login = ?", session[:user_login] ]).class.to_s.demodulize %>)
|
5
|
+
| <%= link_to "logout", logout_path %>
|
6
|
+
<% if Opensteam::UserBase::User.find(:first, :conditions => ["login = ?", session[:user_login] ]).is_admin? %>
|
7
|
+
| <%= link_to "administration", administration_path %>
|
8
|
+
||
|
9
|
+
<% end %>
|
10
|
+
<% else %>
|
11
|
+
<%= link_to "login", login_path %>
|
12
|
+
<% end %>
|
13
|
+
<span style="color:red;"><%=h flash[:error] %></span>
|
14
|
+
<span style="color:green;"><%=h flash[:notice] %></span>
|
15
|
+
<span style="color:orange;"><%=h flash[:warning] %></span>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%- if inventory_content.is_active? %>
|
2
|
+
<b>Price</b>: <%=h inventory_content.price %><br />
|
3
|
+
<b>Storage</b>: <%=h inventory_content.storage %><br />
|
4
|
+
<%- if inventory_content.storage <= 0 -%>
|
5
|
+
<b>Status:</b> <%= inventory_content.back_ordered ? "Back Ordered" : "Not Available" %><br />
|
6
|
+
<%- end -%>
|
7
|
+
<b>Description</b>: <%=h inventory_content.description %><br />
|
8
|
+
<%- else -%>
|
9
|
+
<span style="color:red;">Sorry, this product is currently not available</span>
|
10
|
+
<%- end -%>
|
11
|
+
|
12
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
page.replace_html :cart, :partial => "common/cart", :object => @cart
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div id="index">
|
2
|
+
<b>Product - List</b><br /><br />
|
3
|
+
<%% for product in @products %>
|
4
|
+
<div id="<%%= cycle('odd','even') %>">
|
5
|
+
<b><%%=h product.class %></b> <%%=h product.name %> --
|
6
|
+
<%%= link_to 'details', :controller => "<%= file_name %>", :action => :show, :type => product.class.to_s.demodulize, :id => product.id %>
|
7
|
+
</div>
|
8
|
+
<%% end %> <br />
|
9
|
+
<br />
|
10
|
+
<br /><br />
|
11
|
+
</div>
|
12
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<div id="details">
|
2
|
+
<%% form_remote_tag :url => { :action => :add_inventory_to_cart }, :html => { :id => "show"} do %>
|
3
|
+
<%% fields_for :product, @product do |f| %>
|
4
|
+
<%%= render( :partial => existing_partial( "#{@product.class.to_s.demodulize.tableize}/details", "#{@product.class.superclass.to_s.demodulize.tableize}/details" ),
|
5
|
+
:object => @product,
|
6
|
+
:locals => { :f => f, :cart_details => @cart_details } ) %>
|
7
|
+
<%% end %>
|
8
|
+
|
9
|
+
<br />
|
10
|
+
|
11
|
+
<span id="indicator" style="margin-top:0px; display:none"><%%= image_tag "indicator.gif" %>checking inventory...</span>
|
12
|
+
<div id="inventory">
|
13
|
+
<%%- if @inventory.empty? -%>
|
14
|
+
<b>Please select a configuration</b>
|
15
|
+
<%%- else -%>
|
16
|
+
<%%= render :partial => "inventory_content", :collection => @inventory %>
|
17
|
+
<%%- end -%>
|
18
|
+
</div>
|
19
|
+
<br />
|
20
|
+
<br />
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
<%%- unless @cart_details -%><%%= submit_tag "add to cart" %><%%- end -%>
|
26
|
+
|
27
|
+
<%% end %>
|
28
|
+
|
29
|
+
<%%= observe_form "show",
|
30
|
+
:url => { :action => :inventory },
|
31
|
+
:loading => "Element.show('indicator')",
|
32
|
+
:complete => "Element.hide('indicator')"
|
33
|
+
%>
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
<%%= link_to 'Index', <%= file_name %>_index_path %>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
class OpensteamProductGenerator < Rails::Generator::NamedBase
|
2
|
+
|
3
|
+
def initialize(runtime_args, runtime_options = {})
|
4
|
+
super
|
5
|
+
end
|
6
|
+
|
7
|
+
def manifest
|
8
|
+
record do |m|
|
9
|
+
|
10
|
+
|
11
|
+
m.class_collisions class_path, class_name, "#{class_name}Test"
|
12
|
+
|
13
|
+
### Controllers ###
|
14
|
+
# direcotries
|
15
|
+
m.directory( File.join('app/controllers', 'administration') )
|
16
|
+
|
17
|
+
# app/controllers/*
|
18
|
+
m.template("controllers/product_controller.rb", "app/controllers/administration/#{table_name}_controller.rb")
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
### Models ###
|
23
|
+
# app/models/* #
|
24
|
+
m.template("models/product.rb", "app/models/#{file_name}.rb")
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
### Views ###
|
29
|
+
m.directory( File.join('app/views', 'administration', table_name ) )
|
30
|
+
# app/views/administration/<product>/* #
|
31
|
+
%w( _attributes edit _get_products new show index ).each { |f|
|
32
|
+
m.template("views/administration/#{f}.html.erb", "app/views/administration/#{table_name}/#{f}.html.erb")
|
33
|
+
}
|
34
|
+
m.file( "views/administration/_inventories.html.erb", "app/views/administration/#{table_name}/_inventories.html.erb")
|
35
|
+
|
36
|
+
# app/views/<product>/*
|
37
|
+
m.directory( File.join('app/views', table_name ) )
|
38
|
+
%w( _details _attr_product _attr_property ).each { |f|
|
39
|
+
m.template("views/#{f}.html.erb", "app/views/#{table_name}/#{f}.html.erb")
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
### Migrations ###
|
45
|
+
unless options[:skip_migration]
|
46
|
+
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
47
|
+
:migration_name => "CreateProducts#{class_name.pluralize.gsub(/::/, '')}"
|
48
|
+
}, :migration_file_name => "create_products_#{file_path.gsub(/\//, '_').pluralize}"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def gsub_file(relative_destination, regexp, *args, &block)
|
58
|
+
path = destination_path(relative_destination)
|
59
|
+
content = File.read(path).gsub(regexp, *args, &block)
|
60
|
+
File.open(path, 'wb') { |file| file.write(content) }
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def map_add_namespace(str)
|
65
|
+
logger.route "add administration namepsace for #{file_name}"
|
66
|
+
sentinel = ' map.namespace :administration do |administration|'
|
67
|
+
|
68
|
+
unless options[:pretend]
|
69
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
70
|
+
"#{match}\n administration.resources :#{str}\n"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def map_namedroutes(name, path, *r)
|
77
|
+
route_list = r.inspect.gsub(/[\[\]{}]/, " ")
|
78
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
79
|
+
|
80
|
+
logger.route "map.#{name} \"#{path}\", #{route_list}"
|
81
|
+
unless options[:pretend]
|
82
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
83
|
+
"#{match}\n map.#{name} \"#{path}\", #{route_list}\n"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def map_customroutes
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
# Override with your own usage banner.
|
95
|
+
def banner
|
96
|
+
"Usage: #{$0} opensteam_product ProductName [column:type] "
|
97
|
+
end
|
98
|
+
|
99
|
+
def add_options!(opt)
|
100
|
+
opt.separator ''
|
101
|
+
opt.separator 'Options:'
|
102
|
+
opt.on("--skip-timestamps",
|
103
|
+
"Don't add timestamps to the migration file for this product") { |v| options[:skip_timestamps] = v }
|
104
|
+
opt.on("--skip-migration",
|
105
|
+
"Don't generate a migration file for this product") { |v| options[:skip_migration] = v }
|
106
|
+
end
|
107
|
+
|
108
|
+
def scaffold_views
|
109
|
+
%w[ index show new edit ]
|
110
|
+
end
|
111
|
+
|
112
|
+
def model_name
|
113
|
+
class_name.demodulize
|
114
|
+
end
|
115
|
+
end
|