radiant-shop-extension 0.11.6 → 0.90.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/HISTORY.md +21 -3
  2. data/LICENSE +42 -0
  3. data/README.md +62 -25
  4. data/Rakefile +4 -5
  5. data/VERSION +1 -1
  6. data/app/controllers/admin/shop/categories_controller.rb +1 -0
  7. data/app/controllers/admin/shop/orders_controller.rb +1 -1
  8. data/app/controllers/admin/shop/products_controller.rb +18 -7
  9. data/app/helpers/shop_helper.rb +8 -0
  10. data/app/models/form_address.rb +5 -5
  11. data/app/models/form_checkout.rb +25 -17
  12. data/app/models/form_line_item.rb +1 -1
  13. data/app/models/shop_category.rb +22 -7
  14. data/app/models/shop_customer.rb +1 -1
  15. data/app/models/shop_line_item.rb +26 -26
  16. data/app/models/shop_order.rb +0 -2
  17. data/app/models/shop_product.rb +15 -18
  18. data/app/views/.DS_Store +0 -0
  19. data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
  20. data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
  21. data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
  22. data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
  23. data/app/views/admin/shop/products/index/_product.html.haml +1 -1
  24. data/config/locales/en.yml +8 -7
  25. data/config/routes.rb +4 -16
  26. data/db/migrate/20101011063133_setup_shop.rb +94 -0
  27. data/db/seeds/forms.rb +113 -154
  28. data/db/seeds/layouts.rb +67 -103
  29. data/db/seeds/pages.rb +101 -0
  30. data/db/seeds/products.rb +29 -0
  31. data/db/seeds/snippets.rb +36 -21
  32. data/lib/shop/controllers/application_controller.rb +5 -3
  33. data/lib/shop/models/form_extension.rb +1 -2
  34. data/lib/shop/models/page.rb +0 -1
  35. data/lib/shop/models/user.rb +0 -1
  36. data/lib/shop/tags/card.rb +8 -2
  37. data/lib/shop/tags/cart.rb +5 -1
  38. data/lib/shop/tags/helpers.rb +35 -60
  39. data/lib/shop/tags/item.rb +2 -16
  40. data/lib/shop/tags/product.rb +7 -0
  41. data/lib/tasks/shop_extension_tasks.rake +9 -4
  42. data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
  43. data/radiant-shop-extension.gemspec +25 -201
  44. data/shop_extension.rb +18 -19
  45. data/spec/datasets/forms.rb +25 -28
  46. data/spec/datasets/shop_categories.rb +2 -2
  47. data/spec/datasets/shop_config.rb +24 -0
  48. data/spec/datasets/shop_customers.rb +1 -0
  49. data/spec/datasets/shop_line_items.rb +21 -3
  50. data/spec/datasets/shop_products.rb +4 -1
  51. data/spec/datasets/tags.rb +19 -0
  52. data/spec/lib/shop/models/page_spec.rb +1 -1
  53. data/spec/lib/shop/tags/card_spec.rb +30 -4
  54. data/spec/lib/shop/tags/cart_spec.rb +29 -12
  55. data/spec/lib/shop/tags/helpers_spec.rb +45 -66
  56. data/spec/lib/shop/tags/item_spec.rb +6 -10
  57. data/spec/lib/shop/tags/product_spec.rb +27 -2
  58. data/spec/models/form_address_spec.rb +9 -8
  59. data/spec/models/form_checkout_spec.rb +28 -22
  60. data/spec/models/shop_category_spec.rb +2 -10
  61. data/spec/models/shop_line_item_spec.rb +71 -34
  62. data/spec/models/shop_order_spec.rb +5 -5
  63. data/spec/models/shop_product_attachment_spec.rb +1 -0
  64. data/spec/models/shop_product_spec.rb +4 -47
  65. data/spec/spec.opts +3 -5
  66. metadata +60 -248
  67. data/Gemfile +0 -26
  68. data/Gemfile.lock +0 -75
  69. data/MIT-LICENSE +0 -20
  70. data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
  71. data/app/controllers/admin/shop/discounts_controller.rb +0 -64
  72. data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
  73. data/app/controllers/admin/shop/packages_controller.rb +0 -63
  74. data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
  75. data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
  76. data/app/controllers/admin/shop/variants_controller.rb +0 -48
  77. data/app/models/form_discount.rb +0 -39
  78. data/app/models/shop_discount.rb +0 -37
  79. data/app/models/shop_discountable.rb +0 -64
  80. data/app/models/shop_group.rb +0 -15
  81. data/app/models/shop_grouping.rb +0 -6
  82. data/app/models/shop_package.rb +0 -74
  83. data/app/models/shop_packing.rb +0 -22
  84. data/app/models/shop_product_variant.rb +0 -34
  85. data/app/models/shop_variant.rb +0 -23
  86. data/app/views/admin/pages/_shop_category.html.haml +0 -4
  87. data/app/views/admin/pages/_shop_product.html.haml +0 -4
  88. data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
  89. data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
  90. data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
  91. data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
  92. data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
  93. data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
  94. data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
  95. data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
  96. data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
  97. data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
  98. data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
  99. data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
  100. data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
  101. data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
  102. data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
  103. data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
  104. data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
  105. data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
  106. data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
  107. data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
  108. data/app/views/admin/shop/discounts/edit.html.haml +0 -11
  109. data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
  110. data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
  111. data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
  112. data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
  113. data/app/views/admin/shop/discounts/index.html.haml +0 -13
  114. data/app/views/admin/shop/discounts/new.html.haml +0 -11
  115. data/app/views/admin/shop/discounts/remove.html.haml +0 -12
  116. data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
  117. data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
  118. data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
  119. data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
  120. data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
  121. data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
  122. data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
  123. data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
  124. data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
  125. data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
  126. data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
  127. data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
  128. data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
  129. data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
  130. data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
  131. data/app/views/admin/shop/packages/edit.html.haml +0 -11
  132. data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
  133. data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
  134. data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
  135. data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
  136. data/app/views/admin/shop/packages/index.html.haml +0 -13
  137. data/app/views/admin/shop/packages/new.html.haml +0 -11
  138. data/app/views/admin/shop/packages/remove.html.haml +0 -12
  139. data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
  140. data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
  141. data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
  142. data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
  143. data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
  144. data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
  145. data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
  146. data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
  147. data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
  148. data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
  149. data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
  150. data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
  151. data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
  152. data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
  153. data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
  154. data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
  155. data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
  156. data/app/views/admin/shop/variants/edit.html.haml +0 -11
  157. data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
  158. data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
  159. data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
  160. data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
  161. data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
  162. data/app/views/admin/shop/variants/index.html.haml +0 -13
  163. data/app/views/admin/shop/variants/new.html.haml +0 -11
  164. data/app/views/admin/shop/variants/remove.html.haml +0 -12
  165. data/app/views/shop/categories/show.html.haml +0 -1
  166. data/app/views/shop/orders/show.html.haml +0 -1
  167. data/app/views/shop/products/index.html.haml +0 -1
  168. data/app/views/shop/products/show.html.haml +0 -1
  169. data/cucumber.yml +0 -1
  170. data/db/migrate/20100311053701_initial.rb +0 -153
  171. data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
  172. data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
  173. data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
  174. data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
  175. data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
  176. data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
  177. data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
  178. data/db/migrate/20100929081200_create_variants.rb +0 -20
  179. data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
  180. data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
  181. data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
  182. data/db/migrate/20100930235221_create_packages.rb +0 -31
  183. data/db/migrate/20101005231713_create_page_ids.rb +0 -11
  184. data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
  185. data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
  186. data/db/migrate/20101010071143_create_discounts.rb +0 -29
  187. data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
  188. data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
  189. data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
  190. data/features/support/env.rb +0 -16
  191. data/features/support/paths.rb +0 -14
  192. data/lib/shop/interface/packages.rb +0 -34
  193. data/lib/shop/interface/variants.rb +0 -34
  194. data/lib/shop/tags/package.rb +0 -95
  195. data/lib/shop/tags/product_variant.rb +0 -52
  196. data/lib/shop/tags/responses.rb +0 -34
  197. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  198. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  199. data/mockups/discounts/new-edit.bmml +0 -492
  200. data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
  201. data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
  202. data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
  203. data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
  204. data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
  205. data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
  206. data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
  207. data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
  208. data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
  209. data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
  210. data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
  211. data/spec/datasets/shop_discountables.rb +0 -22
  212. data/spec/datasets/shop_discounts.rb +0 -29
  213. data/spec/datasets/shop_groups.rb +0 -15
  214. data/spec/datasets/shop_packages.rb +0 -25
  215. data/spec/datasets/shop_product_variants.rb +0 -22
  216. data/spec/datasets/shop_variants.rb +0 -17
  217. data/spec/lib/shop/tags/package_spec.rb +0 -342
  218. data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
  219. data/spec/lib/shop/tags/responses_spec.rb +0 -129
  220. data/spec/models/form_discount_spec.rb +0 -63
  221. data/spec/models/shop_discount_spec.rb +0 -130
  222. data/spec/models/shop_discountable_spec.rb +0 -114
  223. data/spec/models/shop_group_spec.rb +0 -38
  224. data/spec/models/shop_package_spec.rb +0 -117
  225. data/spec/models/shop_packing_spec.rb +0 -67
  226. data/spec/models/shop_product_variant_spec.rb +0 -92
  227. data/spec/models/shop_variant_spec.rb +0 -32
@@ -0,0 +1,3 @@
1
+ - if @shop_category.new_record?
2
+ - f.fields_for :page do |pf|
3
+ = pf.hidden_field :status_id,:value => Status[Radiant::Config['defaults.page.status']].id
@@ -9,11 +9,4 @@
9
9
  = updated_stamp @shop_product
10
10
 
11
11
  - unless @shop_product.new_record?
12
- :javascript
13
- if(typeof(ROUTES) === 'undefined') ROUTES = new Array();
14
-
15
- ROUTES['admin_shop_product_images_path'] = "#{admin_shop_product_images_path(@shop_product)}";
16
- ROUTES['sort_admin_shop_product_images_path'] = "#{sort_admin_shop_product_images_path(@shop_product)}";
17
-
18
- ROUTES['admin_shop_product_image_path'] = "#{admin_shop_product_image_path(@shop_product, ':id')}";
19
- ROUTES['admin_shop_product_variant_path'] = "#{admin_shop_product_variant_path(@shop_product, ':id')}";
12
+ = routes_to_js(@routes)
@@ -0,0 +1,6 @@
1
+ - f.fields_for :page do |pf|
2
+ %tr
3
+ %th.label
4
+ = pf.label :layout_id, t('layout')
5
+ %td.field
6
+ = pf.collection_select :layout_id, Layout.all, :id, :name
@@ -0,0 +1,3 @@
1
+ - if @shop_product.new_record?
2
+ - f.fields_for :page do |pf|
3
+ = pf.hidden_field :status_id,:value => Status[Radiant::Config['defaults.page.status']].id
@@ -6,7 +6,7 @@
6
6
  - body.icon do
7
7
  - link_to [:edit_admin, product], :class => 'icon' do
8
8
  - unless product.attachments.empty?
9
- = image_tag product.attachments.first.image.url(:preview)
9
+ = image_tag product.attachments.first.image.url(:icon)
10
10
  - body.name do
11
11
  %span.name.attribute
12
12
  - link_to [:edit_admin, product] do
@@ -49,13 +49,14 @@ en:
49
49
  caption: "Caption"
50
50
  price: "Price"
51
51
  sku: "sku"
52
- variant_templates: "Variant Templates"
53
- product_groups: "Product Groups"
54
- variant: "Variant"
55
- new_variant: "New Variant"
56
- price_variation: "Price Variation"
57
- templates: "Templates"
58
- apply_template: "Apply Template"
52
+ all: "all"
53
+ new: "new"
54
+ shipped: "shipped"
55
+ paid: "paid"
56
+ order: "Order"
57
+ orders: "Orders"
58
+ export: Export
59
+ new_customer: "New Customer"
59
60
  text:
60
61
  remove_customer:
61
62
  warning: "Deleting a customer is irreversible and will also delete their orders and addresses, make sure you're sure."
data/config/routes.rb CHANGED
@@ -1,32 +1,20 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
 
3
3
  map.namespace :admin do |admin|
4
- admin.namespace :shop, :member => { :remove => :get } do |shop|
4
+ admin.namespace :shop, :member => { :remove => :get } do |shop|
5
+
5
6
  shop.resources :categories, :collection => { :sort => :put }, :member => { :products => :get } do |category|
6
7
  category.resources :products, :only => :new
7
8
  end
8
9
 
9
10
  shop.resources :products, :except => :new, :collection => { :sort => :put } do |product|
10
- product.resources :images, :controller => 'products/images', :only => [:index, :create, :destroy], :collection => { :sort => :put }
11
- product.resources :variants, :controller => 'products/variants', :only => [ :create, :destroy]
12
- product.resources :variant_templates, :controller => 'products/variant_templates', :only => [ :update ]
13
- product.resources :discounts, :controller => 'products/discounts', :only => [ :create, :destroy]
14
- product.resources :discount_templates,:controller => 'products/discount_templates', :only => [ :update ]
11
+ product.resources :images, :controller => 'products/images', :only => [:index, :create, :destroy], :collection => { :sort => :put }
15
12
  end
16
13
 
17
- shop.resources :packages, :member => { :remove => :get } do |packages|
18
- packages.resources :packings, :controller => 'packages/packings', :only => [:create, :update, :destroy], :collection => { :sort => :put }
19
- end
20
-
21
- shop.resources :discounts, :member => { :remove => :get } do |discounts|
22
- discounts.resources :discountables, :controller => 'discounts/discountables', :only => [:create,:destroy]
23
- end
24
-
25
- shop.resources :variants
26
-
27
14
  shop.resources :customers
28
15
 
29
16
  shop.resources :orders, :except => [ :destroy ], :collection => { :export => :get }
17
+
30
18
  end
31
19
 
32
20
  admin.resources :shops, :as => 'shop', :only => [ :index ]
@@ -0,0 +1,94 @@
1
+ class SetupShop < ActiveRecord::Migration
2
+ def self.up
3
+ create_table "shop_products", :force => true do |t|
4
+ t.decimal "price"
5
+ t.decimal "weight"
6
+ t.decimal "height"
7
+ t.decimal "width"
8
+ t.decimal "depth"
9
+ t.datetime "created_at"
10
+ t.datetime "updated_at"
11
+ t.integer "created_by_id"
12
+ t.integer "updated_by_id"
13
+ t.integer "page_id"
14
+ end
15
+
16
+ create_table "shop_categories", :force => true do |t|
17
+ t.integer "product_layout_id"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ t.integer "created_by_id"
21
+ t.integer "updated_by_id"
22
+ t.integer "page_id"
23
+ end
24
+
25
+ create_table "shop_product_attachments", :force => true do |t|
26
+ t.integer "position", :default => 1
27
+ t.integer "image_id"
28
+ t.integer "product_id"
29
+ t.integer "created_by_id"
30
+ t.integer "updated_by_id"
31
+ end
32
+ add_index "shop_product_attachments", ["image_id"], :name => "index_shop_product_attachments_on_image_id"
33
+ add_index "shop_product_attachments", ["position"], :name => "index_shop_product_attachments_on_position"
34
+ add_index "shop_product_attachments", ["product_id"], :name => "index_shop_product_attachments_on_product_id"
35
+
36
+ create_table "shop_orders", :force => true do |t|
37
+ t.text "notes"
38
+ t.string "status", :default => "new"
39
+ t.integer "billing_id"
40
+ t.integer "shipping_id"
41
+ t.datetime "created_at"
42
+ t.datetime "updated_at"
43
+ t.integer "customer_id"
44
+ t.integer "created_by_id"
45
+ t.integer "updated_by_id"
46
+ end
47
+ add_index "shop_orders", ["customer_id"], :name => "index_shop_orders_on_customer_id"
48
+ add_index "shop_orders", ["status"], :name => "index_shop_orders_on_status"
49
+
50
+ create_table "shop_line_items", :force => true do |t|
51
+ t.integer "quantity", :default => 1
52
+ t.integer "item_id"
53
+ t.string "item_type"
54
+ t.decimal "item_price"
55
+ t.datetime "created_at"
56
+ t.datetime "updated_at"
57
+ t.integer "order_id"
58
+ t.integer "created_by_id"
59
+ t.integer "updated_by_id"
60
+ end
61
+ add_index "shop_line_items", ["item_id"], :name => "index_shop_line_items_on_item_id"
62
+ add_index "shop_line_items", ["order_id"], :name => "index_shop_line_items_on_order_id"
63
+
64
+ create_table "shop_addresses", :force => true do |t|
65
+ t.string "email"
66
+ t.string "name"
67
+ t.string "unit"
68
+ t.string "street"
69
+ t.string "city"
70
+ t.string "state"
71
+ t.string "postcode"
72
+ t.string "country"
73
+ t.integer "created_by_id"
74
+ t.integer "updated_by_id"
75
+ t.datetime "created_at"
76
+ t.datetime "updated_at"
77
+ end
78
+
79
+ create_table "shop_payments", :force => true do |t|
80
+ t.float "amount"
81
+ t.datetime "created_at"
82
+ t.datetime "updated_at"
83
+ t.string "gateway"
84
+ t.string "card_type"
85
+ t.string "card_number"
86
+ t.integer "order_id"
87
+ t.integer "created_by_id"
88
+ t.integer "updated_by_id"
89
+ end
90
+
91
+ add_index "shop_payments", ["gateway"], :name => "index_shop_payments_on_gateway"
92
+ add_index "shop_payments", ["order_id"], :name => "index_shop_payments_on_order_id"
93
+ end
94
+ end
data/db/seeds/forms.rb CHANGED
@@ -1,11 +1,9 @@
1
- puts "Seed Shop Forms";
2
-
1
+ #---------------------------------------------------#
3
2
  # Add Cart Item
4
-
5
- Form.create({
6
- :title => 'CartAddProduct',
7
- :action => '/shop/cart', # Redirects to the cart listing
8
- :body => <<-BODY
3
+ #---------------------------------------------------#
4
+ add = Form.new
5
+ add.title = 'CartAddProduct'
6
+ add.body = <<-BODY
9
7
  <r:shop:product>
10
8
  <input type="hidden" name="line_item[item_id]" value="<r:id />" />
11
9
  <input type="hidden" name="line_item[item_type]" value="ShopProduct" />
@@ -14,177 +12,138 @@ Form.create({
14
12
  <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Buy Now" />
15
13
  </r:shop:product>
16
14
  BODY
17
- })
15
+ add.config = <<-CONFIG
16
+ add_product:
17
+ extension: line_item
18
+ process: add
19
+ CONFIG
18
20
 
19
- Form.create({
20
- :title => 'CartAddProductVariant',
21
- :action => '/shop/cart', # Redirects to the cart listing
22
- :body => <<-BODY
23
- <r:shop:product>
24
- <input type="hidden" name="line_item[item_id]" value="<r:id />" />
25
- <input type="hidden" name="line_item[item_type]" value="ShopProduct" />
26
-
27
- <input type="hidden" name="line_item[quantity]" value="1" />
28
- <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Buy Now" />
29
- </r:shop:product>
30
- BODY
31
- })
21
+ add.save
32
22
 
23
+ #---------------------------------------------------#
33
24
  # Update Cart Item
34
-
35
- Form.create({
36
- :title => 'CartUpdateItem',
37
- :action => '',
38
- :body => <<-BODY
25
+ #---------------------------------------------------#
26
+ update = Form.new
27
+ update.title = 'CartUpdateItem'
28
+ update.body = <<-BODY
39
29
  <r:shop:cart>
40
- <r:item>
41
- <input type="hidden" name="_method" value="put" />
42
- <input type="hidden" name="line_item[id]" value="<r:item:id />" />
43
-
44
- <input type="text" name="line_item[quantity]" value="<r:quantity />" />
45
- <input type="submit" name="add_to_cart" id="update_<r:id />" value="Update" />
46
- </r:item>
30
+ <r:item>
31
+ <input type="hidden" name="_method" value="put" />
32
+ <input type="hidden" name="line_item[id]" value="<r:item:id />" />
33
+
34
+ <input type="text" name="line_item[quantity]" value="<r:quantity />" />
35
+ <input type="submit" name="add_to_cart" id="update_<r:id />" value="Update" />
36
+ </r:item>
47
37
  </r:shop:cart>
48
38
  BODY
49
- })
50
-
51
- # Checkout Addresses
39
+ update.config = <<-CONFIG
40
+ add_product:
41
+ extension: line_item
42
+ process: modify
43
+ CONFIG
52
44
 
53
- addresses_body = <<-BODY
54
- <r:shop:cart>
55
- <div class="addresses">
56
- <div id="billing" class="address">
57
- <h4>Billing</h4>
58
- <ol class="address">
59
- <r:address type='billing'>
60
- <r:if_address><input type="hidden" name="billing[id]" value="<r:id />" /></r:if_address>
61
- <li>
62
- <r:label for='billing[name]'>Full Name</r:label>
63
- <input type="text" name="billing[name]" value="<r:name/>" />
64
- </li>
65
- <li>
66
- <r:label for='billing[email]'>Email</r:label>
67
- <input type="text" name="billing[email]" value="<r:email/>" />
68
- </li>
69
- <li>
70
- <r:label for='billing[street]'>Street</r:label>
71
- <input type="text" name="billing[street]" value="<r:street/>" />
72
- </li>
73
- <li>
74
- <r:label for='billing[city]'>Suburb and Postcode</r:label>
75
- <input type="text" name="billing[city]" value="<r:city/>" />
76
- <input type="text" name="billing[postcode]" value="<r:postcode/>" />
77
- </li>
78
- <li>
79
- <r:label for='billing[state]'>State and Country</r:label>
80
- <input type="text" name="billing[state]" value="<r:state/>" />
81
- <input type="text" name="billing[country]" value="<r:country/>" />
82
- </li>
83
- </r:address>
84
- </ol>
85
- </div>
86
-
87
- <div id="shipping" class="address">
88
- <h4>Shipping</h4>
45
+ update.save
46
+
47
+ #---------------------------------------------------#
48
+ # Cart Address
49
+ #---------------------------------------------------#
50
+ address = Form.new
51
+ address.title = 'CartAddress'
52
+ address.redirect_to = '/cart/payment'
53
+ address.body = <<-BODY
54
+ <r:shop:cart:items:if_items>
55
+ <div id="billing" class="address">
56
+ <r:address type='billing'>
57
+ <h4>Address</h4>
58
+
59
+ <r:if_address><input type="hidden" name="billing[id]" value="<r:id />" /></r:if_address>
60
+
89
61
  <ol class="address">
90
- <r:address type='shipping'>
91
- <r:if_address><input type="hidden" name="shipping[id]" value="<r:id />" /></r:if_address>
92
- <li>
93
- <r:label for='shipping[name]'>Full Name</r:label>
94
- <input type="text" name="shipping[name]" value="<r:name/>" />
95
- </li>
96
- <li>
97
- <r:label for='shipping[email]'>Email</r:label>
98
- <input type="text" name="shipping[email]" value="<r:email/>" />
99
- </li>
100
- <li>
101
- <r:label for='shipping[street]'>Street</r:label>
102
- <input type="text" name="shipping[street]" value="<r:street/>" />
103
- </li>
104
- <li>
105
- <r:label for='shipping[city]'>Suburb and Postcode</r:label>
106
- <input type="text" name="shipping[city]" value="<r:city/>" />
107
- <input type="text" name="shipping[postcode]" value="<r:postcode/>" />
108
- </li>
109
- <li>
110
- <r:label for='shipping[state]'>State and Country</r:label>
111
- <input type="text" name="shipping[state]" value="<r:state/>" />
112
- <input type="text" name="shipping[country]" value="<r:country/>" />
113
- </li>
114
- </r:address>
62
+ <li id="billing_name_input" class="input required">
63
+ <r:label for='billing[name]'>Full Name</r:label>
64
+ <input type="text" name="billing[name]" value="<r:name/>" />
65
+ </li>
66
+ <li id="billing_email_input" class="input required">
67
+ <r:label for='billing[email]'>Email</r:label>
68
+ <input type="text" name="billing[email]" value="<r:email/>" />
69
+ </li>
70
+ <li id="billing_street_input" class="input required">
71
+ <r:label for='billing[street]'>Street</r:label>
72
+ <input type="text" name="billing[street]" value="<r:street/>" />
73
+ </li>
74
+ <li id="billing_city_input" class="input required">
75
+ <r:label for='billing[city]'>Suburb and Postcode</r:label>
76
+ <input type="text" name="billing[city]" value="<r:city/>" />
77
+ <input type="text" name="billing[postcode]" value="<r:postcode/>" />
78
+ </li>
79
+ <li id="billing_state_input" class="input required">
80
+ <r:label for='billing[state]'>State and Country</r:label>
81
+ <input type="text" name="billing[state]" value="<r:state/>" />
82
+ <input type="text" name="billing[country]" value="<r:country/>" />
83
+ </li>
115
84
  </ol>
116
- </div>
85
+ </r:address>
117
86
  </div>
118
- </r:shop:cart>
87
+ </r:shop:cart:items:if_items>
119
88
 
120
- <r:submit value="Save Addresses" />
89
+ <r:submit value="On To Payment" />
121
90
  BODY
122
-
123
- addresses_config = <<-CONFIG
124
- checkout:
125
- address:
126
- billing: true
127
- shipping: true
91
+ address.config = <<-CONFIG
92
+ checkout_addresses:
93
+ extension: address
94
+ billing: true
128
95
  CONFIG
129
-
130
- Forms.create({
131
- :title => 'CheckoutAddresses',
132
- :redirect_to => '/shop',
133
- :body => addresses_body,
134
- :config => addresses_config
135
- })
136
-
137
- eway_body = <<-BODY
138
- <r:shop:cart>
96
+ address.save
97
+
98
+
99
+ #---------------------------------------------------#
100
+ # Cart Payment
101
+ #---------------------------------------------------#
102
+ payment = Form.new
103
+ payment.title = 'CartPayment'
104
+ payment.redirect_to = '/cart/thanks'
105
+ payment.body = <<-BODY
106
+ <r:response:if_results extension='bogus_checkout'>
107
+ <r:response:get name='results[bogus_checkout][message]' />
108
+ </r:response:if_results>
109
+
110
+ <r:shop:cart:items:if_items>
111
+ <input type="hidden" name="options[order_number]" value="<r:id />" />
139
112
  <ol class="card">
140
- <li>
113
+ <li id="card_type_select" class="select required">
141
114
  <r:label for='card[type]'>Type of Card</r:label>
142
- <r:select name='card[type]'>
143
- <r:option value='visa'>Visa</r:option>
144
- <r:option value='mastercard'>Master Card</r:option>
145
- <r:option value='diners'>Diners Club</r:option>
146
- <r:option vlaue='amex'>AMEX</r:option>
147
- </r:select>
115
+ <r:form:card:type />
116
+ <r:hidden name='card[type]' value='bogus' /> <!-- delete me -->
148
117
  </li>
149
- <li>
118
+ <li id="card_name_input" class="input required">
150
119
  <r:label for='card[name]'>Name on Card</r:label>
151
120
  <r:text name='card[name]' />
152
121
  </li>
153
- <li>
122
+ <li id="card_number_input" class="input required">
154
123
  <r:label for='card[number]'>Card Number</r:label>
155
124
  <r:text name='card[number]' />
125
+ <r:hidden name='card[number]' value='1' /> <!-- delete me -->
156
126
  </li>
157
- <li>
158
- <r:label for='card[verification]'>Verification Code</r:label>
127
+ <li id="card_verification_input" class="input required">
128
+ <r:label for='card[verification]'>Security Code</r:label>
159
129
  <r:text name='card[verification]' length='4' />
160
130
  </li>
161
- <li>
162
- <r:label for='card[month]'>Date on Card</r:label>
163
- <r:select:card:month />
164
- <r:select:card:year />
131
+ <li id="card_month_select" class="select required">
132
+ <r:label for='card[month]'>Expiry</r:label>
133
+ <r:form:card:month /><r:form:card:year />
134
+ </li>
135
+ <li id="card_submit" class="submit">
136
+ <r:submit value='Place Order' />
165
137
  </li>
166
138
  </ol>
167
- </r:shop:cart>
168
-
169
- <h3>Special Instructions</h3>
170
-
171
- <p><textarea name="order[message]"></textarea></p>
172
-
173
- <r:shop:cart:address type='billing'>
174
- <input type="hidden" name="options[address][address1]" value="<r:street />" />
175
- <input type="hidden" name="options[address][city]" value="<r:city />" />
176
- <input type="hidden" name="options[address][state]" value="<r:state />" />
177
- <input type="hidden" name="options[address][country]" value="<r:country />" />
178
- <input type="hidden" name="options[address][zip]" value="<r:postcode />" />
179
- <input type="hidden" name="options[email]" value="<r:email />" />
180
- <input type="hidden" name="options[description]" value="<r:config:setting key='site.url' /> order #<r:shop:cart:id />" />
181
- </r:shop:cart:address>
182
-
183
- <r:submit value="Place Order" />
184
-
185
- <r:snippet name='PaymentResponse' />
139
+
140
+ </r:shop:cart:items:if_items>
186
141
  BODY
187
-
188
- eway_config = <<-CONFIG
189
-
190
- CONFIG
142
+ payment.config = <<-CONFIG
143
+ bogus_checkout:
144
+ extension: checkout
145
+ test: true
146
+ gateway:
147
+ name: bogus
148
+ CONFIG
149
+ payment.save