sbdevcart 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +1 -0
  2. data/app/assets/javascripts/sbdevcart.js +3 -0
  3. data/app/assets/stylesheets/_sbdev_cart.scss +25 -0
  4. data/app/controllers/order_items_controller.rb +49 -0
  5. data/app/controllers/orders_controller.rb +64 -0
  6. data/app/controllers/payment_notifications_controller.rb +7 -0
  7. data/app/controllers/products_controller.rb +47 -0
  8. data/app/controllers/sbdevcart/application_controller_extensions.rb +21 -0
  9. data/app/mailers/cart_mailer.rb +14 -0
  10. data/app/models/order.rb +105 -0
  11. data/app/models/order_item.rb +9 -0
  12. data/app/models/payment_notification.rb +17 -0
  13. data/app/models/product.rb +13 -0
  14. data/app/views/cart_mailer/paid.erb +10 -0
  15. data/app/views/cart_mailer/shipped.erb +3 -0
  16. data/app/views/order_items/_form.html.erb +12 -0
  17. data/app/views/order_items/_show.html.erb +7 -0
  18. data/app/views/order_items/destroy.js.erb +2 -0
  19. data/app/views/order_items/edit.html.erb +8 -0
  20. data/app/views/order_items/index.html.erb +19 -0
  21. data/app/views/order_items/new.html.erb +5 -0
  22. data/app/views/order_items/show.html.erb +20 -0
  23. data/app/views/orders/_form.html.erb +12 -0
  24. data/app/views/orders/_show.html.erb +18 -0
  25. data/app/views/orders/edit.html.erb +8 -0
  26. data/app/views/orders/index.html.erb +11 -0
  27. data/app/views/orders/index.js.erb +5 -0
  28. data/app/views/orders/new.html.erb +5 -0
  29. data/app/views/orders/ship.js.erb +1 -0
  30. data/app/views/orders/show.html.erb +27 -0
  31. data/app/views/products/_form.html.erb +11 -0
  32. data/app/views/products/_show.html.erb +17 -0
  33. data/app/views/products/edit.html.erb +8 -0
  34. data/app/views/products/index.html.erb +9 -0
  35. data/app/views/products/new.html.erb +1 -0
  36. data/app/views/products/show.html.erb +16 -0
  37. data/db/migrate/20110728114008_create_products.rb +9 -0
  38. data/db/migrate/20110728131827_create_order_items.rb +10 -0
  39. data/db/migrate/20110728131950_create_orders.rb +10 -0
  40. data/db/migrate/20110823001313_create_payment_notifications.rb +9 -0
  41. data/db/seeds.rb +48 -0
  42. data/lib/generators/sbdevcart/install_generator.rb +9 -0
  43. data/lib/generators/sbdevcart/templates/certs/development/app_cert.pem +21 -0
  44. data/lib/generators/sbdevcart/templates/certs/development/app_key.pem +15 -0
  45. data/lib/generators/sbdevcart/templates/certs/development/paypal_cert.pem +23 -0
  46. data/lib/generators/sbdevcart/templates/certs/production/app_cert.pem +21 -0
  47. data/lib/generators/sbdevcart/templates/certs/production/app_key.pem +15 -0
  48. data/lib/generators/sbdevcart/templates/certs/production/paypal_cert.pem +23 -0
  49. data/lib/sbdevcart/engine.rb +18 -0
  50. data/lib/sbdevcart/version.rb +1 -1
  51. data/lib/tasks/sbdevcart_tasks.rake +6 -4
  52. data/sbdevcart.gemspec +1 -0
  53. metadata +61 -5
  54. data/config/routes.rb +0 -2
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ test/dummy/db/*.sqlite3
5
5
  test/dummy/log/*.log
6
6
  test/dummy/tmp/
7
7
  .idea/
8
+ *.gem
@@ -0,0 +1,3 @@
1
+ $(document).ready(function (){
2
+ $('#orders').tabs("#orders div.pane", {tabs: 'li.top'});
3
+ });
@@ -0,0 +1,25 @@
1
+ .product {
2
+ border: 2px solid black;
3
+ @include box-shadow($shadow-radius);
4
+ @include corners-all($corner-radius);
5
+ padding: 0 10px;
6
+
7
+ .button {
8
+ font-size: 1em;
9
+ }
10
+ }
11
+
12
+ #state_nav li {
13
+ display: inline;
14
+ }
15
+ .pane {
16
+ margin-left: 20px;
17
+ }
18
+ .pane li {
19
+ margin-left: 20px;
20
+ list-style-type: disc;
21
+ }
22
+
23
+ #orders li {
24
+ margin-top:5px;
25
+ }
@@ -0,0 +1,49 @@
1
+ class OrderItemsController < ApplicationController
2
+ def index
3
+ @order_items = OrderItem.all
4
+ end
5
+
6
+ def show
7
+ @order_item = OrderItem.find(params[:id])
8
+ end
9
+
10
+ def new
11
+ @order_item = OrderItem.new
12
+ end
13
+
14
+ def create
15
+ @order_item = @order.order_items.find_or_initialize_by_product_id(params[:order_item])
16
+ unless @order_item.new_record?
17
+ @order_item.quantity += params[:order_item][:quantity].to_i
18
+ end
19
+ if @order_item.save
20
+ redirect_to order_url(@order)
21
+ else
22
+ render :action => 'new'
23
+ end
24
+ end
25
+
26
+ def edit
27
+ @order_item = OrderItem.find(params[:id])
28
+ end
29
+
30
+ def update
31
+ @order_item = OrderItem.find(params[:id])
32
+ if @order_item.update_attributes(params[:order_item])
33
+ flash[:notice] = "Successfully updated order item."
34
+ redirect_to @order_item
35
+ else
36
+ render :action => 'edit'
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @order_item = OrderItem.find(params[:id])
42
+ @order_item.destroy
43
+ flash[:notice] = "Successfully destroyed order item."
44
+ respond_to do |format|
45
+ format.html { redirect_to order_url(@order) }
46
+ format.js {}
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,64 @@
1
+ class OrdersController < ApplicationController
2
+ before_filter :authenticate_admin!, :except => [:show, :new, :create, :paypal]
3
+ def index
4
+ search_params = {:page => params[:page], :order => 'state DESC', :conditions => ["state != 'open'"]}
5
+ search_params.merge!(:conditions => {:state => params[:state]}) if params[:state]
6
+ @orders = Order.paginate(search_params)
7
+ end
8
+
9
+ def show
10
+ @order = Order.find(params[:id])
11
+ end
12
+
13
+ def new
14
+ @order = Order.new
15
+ end
16
+
17
+ def create
18
+ @order = Order.new(params[:order])
19
+ if @order.save
20
+ flash[:notice] = "Successfully created order."
21
+ redirect_to @order
22
+ else
23
+ render :action => 'new'
24
+ end
25
+ end
26
+
27
+ def edit
28
+ @order = Order.find(params[:id])
29
+ end
30
+
31
+ def update
32
+ @order = Order.find(params[:id])
33
+ if @order.update_attributes(params[:order])
34
+ flash[:notice] = "Successfully updated order."
35
+ redirect_to @order
36
+ else
37
+ render :action => 'edit'
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @order = Order.find(params[:id])
43
+ @order.destroy
44
+ flash[:notice] = "Successfully destroyed order."
45
+ redirect_to orders_url
46
+ end
47
+
48
+ def paypal
49
+ @order = Order.find(params[:id])
50
+ @order.email = params[:email]
51
+ if @order.save
52
+ @order.ordered!
53
+ redirect_to @order.paypal_url(products_url, notify_url(:secret => APP_CONFIG[:paypal_secret]))
54
+ else
55
+ flash[:error] = 'Please provide a valid email address'
56
+ render :show
57
+ end
58
+ end
59
+
60
+ def ship
61
+ @order = Order.find(params[:id])
62
+ @order.shipped!
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ class PaymentNotificationsController < ApplicationController
2
+ protect_from_forgery :except => [:create]
3
+ def create
4
+ Order.find(params[:invoice]).payment_notifications.create!(:params => params)
5
+ render :nothing => true
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ class ProductsController < ApplicationController
2
+ before_filter :get_index, :only => [:index]
3
+ def index
4
+ @products = Product.all
5
+ end
6
+
7
+ def show
8
+ @product = Product.find(params[:id])
9
+ end
10
+
11
+ def new
12
+ @product = Product.new
13
+ render :layout => false
14
+ end
15
+
16
+ def create
17
+ @product = Product.new(params[:product])
18
+ if @product.save
19
+ flash[:notice] = "Successfully created product."
20
+ redirect_to products_url
21
+ else
22
+ render :action => 'new'
23
+ end
24
+ end
25
+
26
+ def edit
27
+ @product = Product.find(params[:id])
28
+ render :layout => false
29
+ end
30
+
31
+ def update
32
+ @product = Product.find(params[:id])
33
+ if @product.update_attributes(params[:product])
34
+ flash[:notice] = "Successfully updated product."
35
+ redirect_to products_url
36
+ else
37
+ render :action => 'edit'
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @product = Product.find(params[:id])
43
+ @product.destroy
44
+ flash[:notice] = "Successfully destroyed product."
45
+ redirect_to products_url
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ module Sbdevcart
2
+ module ApplicationControllerExtensions
3
+ def self.included(base)
4
+ base.send(:include, InstanceMethods)
5
+ base.before_filter :current_order
6
+ end
7
+ module InstanceMethods
8
+ def current_order
9
+ if session[:order_id]
10
+ @order ||= Order.find_by_id(session[:order_id])
11
+ session[:order_id] = nil unless((@order.open? || @order.payment_failed?) rescue false)
12
+ end
13
+ if session[:order_id].nil?
14
+ @order = Order.create!
15
+ session[:order_id] = @order.id
16
+ end
17
+ @order
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class CartMailer < ActionMailer::Base
2
+ default :to => APP_CONFIG[:contact_email]
3
+ default :from => APP_CONFIG[:mailer_email]
4
+
5
+ def paid(order)
6
+ @order = order
7
+ mail(:subject => "#{order.name} paid for their order.")
8
+ end
9
+
10
+ def shipped(order)
11
+ @order = order
12
+ mail(:to => order.email, :reply_to => APP_CONFIG[:contact_email], :subject => "Your order from #{APP_CONFIG[:app_name]} has been shipped.")
13
+ end
14
+ end
@@ -0,0 +1,105 @@
1
+ class Order < ActiveRecord::Base
2
+ include AASM
3
+ attr_accessible :email, :state, :purchased_at
4
+
5
+ cattr_reader :per_page
6
+ @@per_page = 10
7
+
8
+ has_many :order_items
9
+ has_many :products, :through => :order_items
10
+ has_many :payment_notifications
11
+
12
+ validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :allow_nil => true
13
+
14
+ def total
15
+ order_items.map(&:sub_total).inject(:+)
16
+ end
17
+
18
+ def payment_notification
19
+ payment_notifications.last
20
+ end
21
+
22
+ def empty?
23
+ order_items.empty?
24
+ end
25
+
26
+ def name
27
+ return "Unknown" unless payment_notification
28
+ notification = payment_notification.params
29
+ notification[:first_name] + " " + notification[:last_name] rescue "Unknown"
30
+ end
31
+
32
+ def address
33
+ return "Unknown" unless payment_notification
34
+ notification = payment_notification.params
35
+ [notification[:address_street], notification[:address_city], notification[:address_state], notification[:address_zip], notification[:address_country]].join(" ") rescue "Unknown"
36
+ end
37
+
38
+ def paypal_url(return_url, notify_url)
39
+ values = {
40
+ :business => APP_CONFIG[:paypal_email],
41
+ :cmd => "_cart",
42
+ :upload => 1,
43
+ :return => return_url,
44
+ :invoice => id,
45
+ :notify => notify_url,
46
+ :cert_id => APP_CONFIG[:paypal_cert_id],
47
+ :no_shipping => 2
48
+ }
49
+ order_items.each_with_index do |order_item, index|
50
+ values.merge!({
51
+ "amount_#{index + 1}" => order_item.product.price,
52
+ "item_name_#{index + 1}" => order_item.product.name,
53
+ "item_number_#{index + 1}" => order_item.product.id,
54
+ "quantity_#{index + 1}" => order_item.quantity
55
+ })
56
+ end
57
+ logger.info values.inspect
58
+ APP_CONFIG[:paypal_url] + {:encrypted => encrypt_for_paypal(values), :cmd => "_s-xclick"}.to_query
59
+ end
60
+
61
+ PAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/#{Rails.env.to_s}/paypal_cert.pem")
62
+ APP_CERT_PEM = File.read("#{Rails.root}/certs/#{Rails.env.to_s}/app_cert.pem")
63
+ APP_KEY_PEM = File.read("#{Rails.root}/certs/#{Rails.env.to_s}/app_key.pem")
64
+
65
+ def encrypt_for_paypal(values)
66
+ signed = OpenSSL::PKCS7::sign(OpenSSL::X509::Certificate.new(APP_CERT_PEM), OpenSSL::PKey::RSA.new(APP_KEY_PEM, ''), values.map { |k, v| "#{k}=#{v}" }.join("\n"), [], OpenSSL::PKCS7::BINARY)
67
+ OpenSSL::PKCS7::encrypt([OpenSSL::X509::Certificate.new(PAYPAL_CERT_PEM)], signed.to_der, OpenSSL::Cipher::Cipher::new("DES3"), OpenSSL::PKCS7::BINARY).to_s.gsub("\n", "")
68
+ end
69
+
70
+ aasm_column :state
71
+ aasm_initial_state :open
72
+ aasm_state :open
73
+ aasm_state :ordered, :enter => [:timestamp]
74
+ aasm_state :paid, :enter => :send_paid
75
+ aasm_state :shipped, :enter => :send_shipped
76
+ aasm_state :payment_failed
77
+
78
+ aasm_event :ordered do
79
+ transitions :to => :ordered, :from => [:open, :payment_failed]
80
+ end
81
+
82
+ aasm_event :paid do
83
+ transitions :to => :paid, :from => [:ordered]
84
+ end
85
+
86
+ aasm_event :payment_failed do
87
+ transitions :to => :payment_failed, :from => [:ordered]
88
+ end
89
+
90
+ aasm_event :shipped do
91
+ transitions :to => :shipped, :from => [:paid]
92
+ end
93
+
94
+ def timestamp
95
+ update_attribute(:purchased_at, Time.now)
96
+ end
97
+
98
+ def send_paid
99
+ CartMailer.paid(self).deliver
100
+ end
101
+
102
+ def send_shipped
103
+ CartMailer.shipped(self).deliver
104
+ end
105
+ end
@@ -0,0 +1,9 @@
1
+ class OrderItem < ActiveRecord::Base
2
+ attr_accessible :order_id, :quantity, :product_id
3
+ belongs_to :product
4
+ belongs_to :order
5
+
6
+ def sub_total
7
+ (quantity.to_i * product.price.to_i)
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ class PaymentNotification < ActiveRecord::Base
2
+ belongs_to :order
3
+ serialize :params
4
+ after_create :mark_order_as_purchased
5
+
6
+ def status
7
+ params[:payment_status]
8
+ end
9
+ private
10
+ def mark_order_as_purchased
11
+ if status == "Completed" #&& params[:secret] == APP_CONFIG[:paypal_secret]
12
+ order.paid!
13
+ else
14
+ order.payment_failed!
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ class Product < ActiveRecord::Base
2
+ attr_accessible :name, :price, :index_attributes
3
+ has_one :index, :as => :owner, :dependent => :destroy
4
+
5
+ accepts_nested_attributes_for :index, :allow_destroy => true
6
+
7
+ include ActsAsPrioritizable
8
+ # acts_as_prioritizable("index", "assets")
9
+
10
+ before_create do
11
+ build_index({:name => name}) unless index
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ An order has been paid for!
2
+
3
+ <% for order_item in @order.order_items %>
4
+ <%= order_item.quantity %> <%= order_item.product.name %>
5
+ <% end %>
6
+
7
+ Total: <%= @order.total %>
8
+ Customer Name: <%= @order.name %>
9
+ Customer Email: <%= @order.email %>
10
+ Shipping Address: <%= @order.address %>
@@ -0,0 +1,3 @@
1
+ Your order from <%= APP_CONFIG[:app_name] %> has been shipped!
2
+
3
+ Thanks
@@ -0,0 +1,12 @@
1
+ <% form_for @order_item do |f| %>
2
+ <%= f.error_messages %>
3
+ <p>
4
+ <%= f.label :order_id %><br />
5
+ <%= f.text_field :order_id %>
6
+ </p>
7
+ <p>
8
+ <%= f.label :quantity %><br />
9
+ <%= f.text_field :quantity %>
10
+ </p>
11
+ <p><%= f.submit %></p>
12
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <tr class="<%= order_item.id %>">
2
+ <td><%= order_item.product.name.titleize %></td>
3
+ <td class='justify_right'><%= number_to_currency order_item.product.price %></td>
4
+ <td class='justify_center'><%= order_item.quantity %></td>
5
+ <td class='justify_right'><%= number_to_currency order_item.sub_total %></td>
6
+ <td class='justify_center'><%= link_to "X", order_item, :class => "ajax_delete" %></td>
7
+ </tr>
@@ -0,0 +1,2 @@
1
+ $('.<%= @order_item.id %>').remove();
2
+ $('#total').html("<%= escape_javascript(number_to_currency(@order_item.order.total)) %>");
@@ -0,0 +1,8 @@
1
+ <% title "Edit Order Item" %>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <p>
6
+ <%= link_to "Show", @order_item %> |
7
+ <%= link_to "View All", order_items_path %>
8
+ </p>
@@ -0,0 +1,19 @@
1
+ <% title "Order Items" %>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Order</th>
6
+ <th>Quantity</th>
7
+ </tr>
8
+ <% for order_item in @order_items %>
9
+ <tr>
10
+ <td><%=h order_item.order_id %></td>
11
+ <td><%=h order_item.quantity %></td>
12
+ <td><%= link_to "Show", order_item %></td>
13
+ <td><%= link_to "Edit", edit_order_item_path(order_item) %></td>
14
+ <td><%= link_to "Destroy", order_item, :confirm => 'Are you sure?', :method => :delete %></td>
15
+ </tr>
16
+ <% end %>
17
+ </table>
18
+
19
+ <p><%= link_to "New Order Item", new_order_item_path %></p>
@@ -0,0 +1,5 @@
1
+ <% title "New Order Item" %>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <p><%= link_to "Back to List", order_items_path %></p>
@@ -0,0 +1,20 @@
1
+ <% title "Order Item" %>
2
+
3
+ <p>
4
+ <strong>Order:</strong>
5
+ <%=h @order_item.order_id %>
6
+ </p>
7
+ <p>
8
+ <strong>Product:</strong>
9
+ <%=h @order_item.product_id %>
10
+ </p>
11
+ <p>
12
+ <strong>Quantity:</strong>
13
+ <%=h @order_item.quantity %>
14
+ </p>
15
+
16
+ <p>
17
+ <%= link_to "Edit", edit_order_item_path(@order_item) %> |
18
+ <%= link_to "Destroy", @order_item, :confirm => 'Are you sure?', :method => :delete %> |
19
+ <%= link_to "View All", order_items_path %>
20
+ </p>
@@ -0,0 +1,12 @@
1
+ <% form_for @order do |f| %>
2
+ <%= f.error_messages %>
3
+ <p>
4
+ <%= f.label :email %><br />
5
+ <%= f.text_field :email %>
6
+ </p>
7
+ <p>
8
+ <%= f.label :state %><br />
9
+ <%= f.text_field :state %>
10
+ </p>
11
+ <p><%= f.submit %></p>
12
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div id="<%= order.id %>">
2
+ <li class='top button'>
3
+ <%=h order.state %> -
4
+ <%=h order.id %> -
5
+ <%=h order.name %> -
6
+ <%=h order.email %> -
7
+ <%=h number_to_currency order.total %>
8
+ <%= link_to "Ship!", ship_order_path(order), :class => "ajax_link" if order.paid? %>
9
+ </li>
10
+ <div class='pane'>
11
+ <%= order.address %>
12
+ <ul>
13
+ <% for item in order.order_items do %>
14
+ <li><%= item.quantity %> - <%= item.product.name %></li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ </div>
@@ -0,0 +1,8 @@
1
+ <% title "Edit Order" %>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <p>
6
+ <%= link_to "Show", @order %> |
7
+ <%= link_to "View All", orders_path %>
8
+ </p>
@@ -0,0 +1,11 @@
1
+ <div class='ajax-nav'>
2
+ <%= link_to 'all', orders_path, :class => 'ajax_link button current' %>
3
+ <%= link_to 'ordered', orders_path(:state => 'ordered'), :class => 'ajax_link button' %>
4
+ <%= link_to 'paid', orders_path(:state => 'paid'), :class => 'ajax_link button' %>
5
+ <%= link_to 'shipped', orders_path(:state => 'shipped'), :class => 'ajax_link button' %>
6
+ <%= link_to 'failed payment', orders_path(:state => 'payment_failed'), :class => 'ajax_link button' %>
7
+ </div>
8
+ <div id='orders'>
9
+ <ul><%= render :partial => 'show', :collection => @orders, :as => :order %></ul>
10
+ <%= will_paginate @orders %>
11
+ </div>
@@ -0,0 +1,5 @@
1
+ $("#orders").html("<%= escape_javascript(render :partial => ('orders/show'), :collection => @orders, :as => :order) %>");
2
+ $("#orders").append("<%= escape_javascript(will_paginate @orders) %>");
3
+ $('#orders').tabs("#orders div.pane", {tabs: 'li.top'});
4
+ paginateAjax();
5
+ $('#orders .ajax_link').ajaxLink();
@@ -0,0 +1,5 @@
1
+ <% title "New Order" %>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <p><%= link_to "Back to List", orders_path %></p>
@@ -0,0 +1 @@
1
+ $('#<%= @order.id %>').remove();
@@ -0,0 +1,27 @@
1
+ <h2>My Order</h2>
2
+ <%= link_to "Continue Shopping!", products_url, :class => 'button' %>
3
+ <table>
4
+ <tr>
5
+ <th>Product</th>
6
+ <th class='justify_right'>Price</th>
7
+ <th class='justify_center'>Quantity</th>
8
+ <th class='justify_right'>Sub Total</th>
9
+ <th class='justify_center'>Remove</th>
10
+ </tr>
11
+ <%= render :partial => "order_items/show", :collection => @order.order_items, :as => :order_item %>
12
+ <tr>
13
+ <td>Total:</td>
14
+ <td></td>
15
+ <td></td>
16
+ <td id='total' class='justify_right'><%= number_to_currency @order.total %></td>
17
+ </tr>
18
+ </table>
19
+
20
+ <%= link_to "Clear Cart", @order, :confirm => 'Are you sure?', :method => :delete %>
21
+ <%= form_tag paypal_order_path(@order), :class => "validate", :novalidate => "novalidate" %>
22
+ <p>
23
+ <%= label_tag 'Your Email Address:' %>
24
+ <%= tag(:input, {:name => "email", :type => :email, :required => true}) %>
25
+ </p>
26
+ <%= submit_tag "Checkout With PayPal!", :class => 'button' %>
27
+ <p>We will ship to the shipping address you provide in PayPal</p>
@@ -0,0 +1,11 @@
1
+ <%= form_for @product, :html => {:class => "validate", :novalidate => "novalidate"} do |f| %>
2
+ <p>
3
+ <%= f.label :name %><br />
4
+ <%= f.text_field :name, :required => true %>
5
+ </p>
6
+ <p>
7
+ <%= f.label :price %><br />
8
+ <%= f.text_field :price, :required => true %>
9
+ </p>
10
+ <p><%= f.submit %></p>
11
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <div class='product' id='<%= product.id %>'>
2
+ <h3><%= product.name.titleize %> - <%= number_to_currency product.price.to_i %></h3>
3
+ <%= form_for OrderItem.new(:quantity => 1) do |f| %>
4
+ <%= f.label :quantity %>
5
+ <%= f.text_field :quantity, :size => 5 %>
6
+ <%= f.hidden_field :product_id, :value => product.id %>
7
+ <%= f.hidden_field :order_id, :value => @order.id %>
8
+ <%= f.submit "Add To Cart", :class => 'button' %>
9
+ <% end %>
10
+ <div class='clearfix'><%= render :partial => 'indices/show', :locals => { :index => product.index } %></div>
11
+ <% if admin_signed_in? %>
12
+ <p class='asset-admin'>
13
+ <%= link_to "Edit product", edit_product_path(product), :rel=>"#overlay", :class => "overlayed" %>
14
+ <%= link_to "Remove product", product, :confirm => 'Are you sure?', :method => :delete %>
15
+ </p>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,8 @@
1
+ <% title "Edit Product" %>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <p>
6
+ <%= link_to "Show", @product %> |
7
+ <%= link_to "View All", products_path %>
8
+ </p>
@@ -0,0 +1,9 @@
1
+ <%= render :partial => "indices/show", :locals => { :index => @index } %><br />
2
+
3
+ <div id='products'>
4
+ <%= render :partial => "products/show", :as => :product, :collection => @products %>
5
+ </div>
6
+
7
+ <% if admin_signed_in? %>
8
+ <p><%= link_to "New Product", new_product_path, :rel=>"#overlay", :class => "overlayed" %></p>
9
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form' %>
@@ -0,0 +1,16 @@
1
+ <% title "Product" %>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%=h @product.name %>
6
+ </p>
7
+ <p>
8
+ <strong>Price:</strong>
9
+ <%=h @product.price %>
10
+ </p>
11
+
12
+ <p>
13
+ <%= link_to "Edit", edit_product_path(@product) %> |
14
+ <%= link_to "Destroy", @product, :confirm => 'Are you sure?', :method => :delete %> |
15
+ <%= link_to "View All", products_path %>
16
+ </p>
@@ -0,0 +1,9 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :products do |t|
4
+ t.string :name
5
+ t.string :price
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateOrderItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :order_items do |t|
4
+ t.integer :order_id
5
+ t.integer :product_id
6
+ t.integer :quantity
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :orders do |t|
4
+ t.string :email
5
+ t.string :state
6
+ t.datetime :purchased_at
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class CreatePaymentNotifications < ActiveRecord::Migration
2
+ def change
3
+ create_table :payment_notifications do |t|
4
+ t.text :params
5
+ t.integer :order_id
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'open-uri'
2
+
3
+ LOREM_LONG = <<-END_LOREM
4
+ <p>
5
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor. Cras sem magna, venenatis non pharetra ac, pellentesque at dui. Sed sit amet nulla nulla, at imperdiet lacus. Aenean tellus turpis, pretium in facilisis a, vestibulum sit amet ante. Quisque bibendum nisi ac magna blandit at eleifend turpis gravida. Curabitur quis massa ac magna molestie pharetra at a eros. Phasellus vulputate neque sit amet est faucibus mattis. Mauris adipiscing orci at augue interdum sit amet commodo tortor consectetur. Etiam eleifend congue risus vitae ultricies. Donec feugiat volutpat pharetra. Maecenas non fermentum magna. Sed facilisis vulputate dui in pellentesque. Praesent eget magna non orci posuere pretium. Ut sit amet lobortis ligula.
6
+ </p>
7
+ <p>
8
+ Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse eu felis eu turpis elementum mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi auctor hendrerit enim non aliquam. In mollis fringilla ante, sed feugiat erat pretium volutpat. Curabitur ut urna vitae magna venenatis varius sit amet in sapien. Cras nec turpis sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec consequat volutpat lectus vel mollis. Morbi iaculis, felis ut tempus placerat, tortor risus iaculis arcu, sit amet imperdiet risus lectus vel odio. Nullam in risus purus, ut tincidunt lacus.
9
+ </p>
10
+ END_LOREM
11
+
12
+ LOREM_SHORT = <<-END_LOREM
13
+ <p>
14
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor. Cras sem magna, venenatis non pharetra ac, pellentesque at dui. Sed sit amet nulla nulla, at imperdiet lacus. Aenean tellus turpis, pretium in facilisis a, vestibulum sit amet ante.
15
+ </p>
16
+ END_LOREM
17
+
18
+ LOREM_MICRO = <<-END_LOREM
19
+ <p>
20
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor.
21
+ </p>
22
+ END_LOREM
23
+
24
+ LOREM_SANS_HTML = <<-END_LOREM
25
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor.
26
+ END_LOREM
27
+
28
+ id = 0
29
+ Product.all.each(&:destroy)
30
+ %w{boat plane train}.each do |product|
31
+ attr = {
32
+ :name => product,
33
+ :price => "100",
34
+ :index_attributes => {
35
+ :name => product,
36
+ :page_title => APP_CONFIG[:app_name] + " - " + product.capitalize,
37
+ :page_description => APP_CONFIG[:app_name] + " - " + product.capitalize,
38
+ :keywords => product,
39
+ :texts_attributes => {
40
+ (id += 1).to_s =>{
41
+ :content => "#{LOREM_SHORT}",
42
+ :priority => "1"
43
+ }
44
+ }
45
+ }
46
+ }
47
+ Product.create(attr)
48
+ end
@@ -11,6 +11,15 @@ module Sbdevcart
11
11
  def set_routes
12
12
  route "Sbdevcart::Routes.draw(self)"
13
13
  end
14
+
15
+ def files
16
+ directory "certs", "config/certs", :force => true
17
+ inject_into_file "app/assets/stylesheets/sass.scss", "\n@import 'sbdev_cart';\n", :after => "@import 'sbdev_core';"
18
+ end
19
+
20
+ def seeds
21
+ Sbdevcart::Engine.load_seed
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDeDCCAuGgAwIBAgIJALGobAolwXeCMA0GCSqGSIb3DQEBBQUAMIGFMQswCQYD
3
+ VQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDjAM
4
+ BgNVBAoTBUhhdXRlMQ4wDAYDVQQLEwVzYWxlczEOMAwGA1UEAxMFaGF1dGUxITAf
5
+ BgkqhkiG9w0BCQEWEmFvc2FsaWFzQGdtYWlsLmNvbTAeFw0xMDEwMjAyMzM4NTFa
6
+ Fw0xMTEwMjAyMzM4NTFaMIGFMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAU
7
+ BgNVBAcTDVNhbiBGcmFuY2lzY28xDjAMBgNVBAoTBUhhdXRlMQ4wDAYDVQQLEwVz
8
+ YWxlczEOMAwGA1UEAxMFaGF1dGUxITAfBgkqhkiG9w0BCQEWEmFvc2FsaWFzQGdt
9
+ YWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyWG+K1VZQvA0o0D5
10
+ M6INTzRB7qiXueAonUW+3hrCAl3UZmlDuodDNnegNL6RU/cI29PTtbcM3IuefYrK
11
+ yfizXV3kh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W5kYm94X2NlcnRzMRQw
18
+ EgYDVQQDFAtzYW5kYm94X2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNv
19
+ bYIBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAFc288DYGX+GX2+W
20
+ P/dwdXwficf+rlG+0V9GBPJZYKZJQ069W/ZRkUuWFQ+Opd2yhPpneGezmw3aU222
21
+ CGrdKhOrBJRRcpoO3FjHHmXWkqgbQqDWdG7S+/l8n1QfDPp+jpULOrcnGEUY41Im
22
+ jZJTylbJQ1b5PBBjGiP0PpK48cdF
23
+ -----END CERTIFICATE-----
@@ -4,11 +4,29 @@ require 'sbdevcart'
4
4
  module Sbdevcart
5
5
  class Engine < Rails::Engine
6
6
  engine_name "sbdevcart"
7
+
8
+ config.dependency_loading = true
9
+
10
+ initializer 'sbdevcart.app_controller' do |app|
11
+ APP_CONFIG[:dynamic_pages] << "products" << "orders"
12
+ ActiveSupport.on_load(:action_controller) do
13
+ include Sbdevcart::ApplicationControllerExtensions
14
+ end
15
+ end
7
16
  end
8
17
 
9
18
  module Routes
10
19
  def self.draw(map)
11
20
  map.instance_exec do
21
+ resources :orders do
22
+ member do
23
+ post 'paypal'
24
+ get 'ship'
25
+ end
26
+ end
27
+ resources :order_items
28
+ resources :products
29
+ match 'notify' => 'payment_notifications#create', :as => :notify
12
30
  end
13
31
  end
14
32
  end
@@ -1,3 +1,3 @@
1
1
  module Sbdevcart
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,4 +1,6 @@
1
- # desc "Explaining what the task does"
2
- # task :sbdevcart do
3
- # # Task goes here
4
- # end
1
+ namespace :sbdevcart do
2
+ desc "load sbdev cart seeds"
3
+ task :seed => :environment do
4
+ Sbdevcart::Engine.load_seed
5
+ end
6
+ end
data/sbdevcart.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency('sbdevcore', ">= 0.0.8")
22
+ s.add_dependency('aasm', ">= 2.2.0")
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbdevcart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-21 00:00:00.000000000Z
12
+ date: 2011-08-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sbdevcore
16
- requirement: &2156026900 !ruby/object:Gem::Requirement
16
+ requirement: &2156828480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: 0.0.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156026900
24
+ version_requirements: *2156828480
25
+ - !ruby/object:Gem::Dependency
26
+ name: aasm
27
+ requirement: &2156827860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2156827860
25
36
  description: Sbdev Shopping Cart
26
37
  email:
27
38
  - aosalias@gmail.com
@@ -33,8 +44,53 @@ files:
33
44
  - MIT-LICENSE
34
45
  - README.rdoc
35
46
  - Rakefile
36
- - config/routes.rb
47
+ - app/assets/javascripts/sbdevcart.js
48
+ - app/assets/stylesheets/_sbdev_cart.scss
49
+ - app/controllers/order_items_controller.rb
50
+ - app/controllers/orders_controller.rb
51
+ - app/controllers/payment_notifications_controller.rb
52
+ - app/controllers/products_controller.rb
53
+ - app/controllers/sbdevcart/application_controller_extensions.rb
54
+ - app/mailers/cart_mailer.rb
55
+ - app/models/order.rb
56
+ - app/models/order_item.rb
57
+ - app/models/payment_notification.rb
58
+ - app/models/product.rb
59
+ - app/views/cart_mailer/paid.erb
60
+ - app/views/cart_mailer/shipped.erb
61
+ - app/views/order_items/_form.html.erb
62
+ - app/views/order_items/_show.html.erb
63
+ - app/views/order_items/destroy.js.erb
64
+ - app/views/order_items/edit.html.erb
65
+ - app/views/order_items/index.html.erb
66
+ - app/views/order_items/new.html.erb
67
+ - app/views/order_items/show.html.erb
68
+ - app/views/orders/_form.html.erb
69
+ - app/views/orders/_show.html.erb
70
+ - app/views/orders/edit.html.erb
71
+ - app/views/orders/index.html.erb
72
+ - app/views/orders/index.js.erb
73
+ - app/views/orders/new.html.erb
74
+ - app/views/orders/ship.js.erb
75
+ - app/views/orders/show.html.erb
76
+ - app/views/products/_form.html.erb
77
+ - app/views/products/_show.html.erb
78
+ - app/views/products/edit.html.erb
79
+ - app/views/products/index.html.erb
80
+ - app/views/products/new.html.erb
81
+ - app/views/products/show.html.erb
82
+ - db/migrate/20110728114008_create_products.rb
83
+ - db/migrate/20110728131827_create_order_items.rb
84
+ - db/migrate/20110728131950_create_orders.rb
85
+ - db/migrate/20110823001313_create_payment_notifications.rb
86
+ - db/seeds.rb
37
87
  - lib/generators/sbdevcart/install_generator.rb
88
+ - lib/generators/sbdevcart/templates/certs/development/app_cert.pem
89
+ - lib/generators/sbdevcart/templates/certs/development/app_key.pem
90
+ - lib/generators/sbdevcart/templates/certs/development/paypal_cert.pem
91
+ - lib/generators/sbdevcart/templates/certs/production/app_cert.pem
92
+ - lib/generators/sbdevcart/templates/certs/production/app_key.pem
93
+ - lib/generators/sbdevcart/templates/certs/production/paypal_cert.pem
38
94
  - lib/sbdevcart.rb
39
95
  - lib/sbdevcart/engine.rb
40
96
  - lib/sbdevcart/version.rb
data/config/routes.rb DELETED
@@ -1,2 +0,0 @@
1
- Sbdevcart::Engine.routes.draw do
2
- end