spree_core 0.30.0.beta1 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (513) hide show
  1. data/README.md +3 -12
  2. data/app/controllers/admin/adjustments_controller.rb +1 -17
  3. data/app/controllers/admin/base_controller.rb +12 -6
  4. data/app/controllers/admin/line_items_controller.rb +6 -29
  5. data/app/controllers/admin/mail_methods_controller.rb +13 -0
  6. data/app/controllers/admin/orders_controller.rb +32 -10
  7. data/app/controllers/admin/payments_controller.rb +15 -31
  8. data/app/controllers/admin/products_controller.rb +40 -41
  9. data/app/controllers/admin/reports_controller.rb +15 -14
  10. data/app/controllers/admin/return_authorizations_controller.rb +3 -16
  11. data/app/controllers/admin/shipments_controller.rb +8 -18
  12. data/app/controllers/admin/taxons_controller.rb +3 -3
  13. data/app/controllers/admin/users_controller.rb +5 -4
  14. data/app/controllers/checkout_controller.rb +26 -8
  15. data/app/controllers/orders_controller.rb +22 -10
  16. data/app/controllers/password_resets_controller.rb +0 -1
  17. data/app/controllers/products_controller.rb +2 -3
  18. data/app/controllers/spree/base_controller.rb +8 -0
  19. data/app/controllers/taxons_controller.rb +4 -4
  20. data/app/helpers/admin/navigation_helper.rb +4 -3
  21. data/app/helpers/checkout_helper.rb +1 -6
  22. data/app/helpers/spree/base_helper.rb +2 -0
  23. data/app/mailers/order_mailer.rb +19 -0
  24. data/app/mailers/shipment_mailer.rb +11 -0
  25. data/app/models/address.rb +3 -9
  26. data/app/models/adjustment.rb +3 -2
  27. data/app/models/app_configuration.rb +3 -16
  28. data/app/models/creditcard.rb +51 -45
  29. data/app/models/inventory_unit.rb +77 -80
  30. data/app/models/line_item.rb +33 -4
  31. data/app/models/log_entry.rb +3 -0
  32. data/app/models/mail_method.rb +23 -0
  33. data/app/models/order.rb +79 -177
  34. data/app/models/payment.rb +21 -18
  35. data/app/models/payment_method.rb +3 -3
  36. data/app/models/return_authorization.rb +11 -7
  37. data/app/models/shipment.rb +64 -40
  38. data/app/models/user.rb +1 -1
  39. data/app/models/variant.rb +6 -6
  40. data/app/views/admin/adjustments/index.html.erb +2 -32
  41. data/app/views/admin/configurations/index.html.erb +3 -3
  42. data/app/views/admin/mail_methods/_form.html.erb +96 -0
  43. data/app/views/admin/mail_methods/edit.html.erb +9 -0
  44. data/app/views/admin/mail_methods/index.html.erb +41 -0
  45. data/app/views/admin/mail_methods/new.html.erb +9 -0
  46. data/app/views/admin/orders/_form.html.erb +3 -4
  47. data/app/views/admin/{checkouts/_form.html.erb → orders/_user_form.html.erb} +10 -10
  48. data/app/views/admin/orders/edit.html.erb +1 -0
  49. data/app/views/admin/orders/index.html.erb +10 -6
  50. data/app/views/admin/orders/new.html.erb +1 -0
  51. data/app/views/admin/orders/show.html.erb +3 -2
  52. data/app/views/admin/{checkouts/edit.html.erb → orders/user.html.erb} +8 -5
  53. data/app/views/admin/payments/_list.html.erb +5 -7
  54. data/app/views/admin/payments/index.html.erb +3 -8
  55. data/app/views/admin/payments/new.html.erb +1 -1
  56. data/app/views/admin/payments/source_views/_gateway.html.erb +0 -1
  57. data/app/views/admin/reports/sales_total.html.erb +2 -6
  58. data/app/views/admin/return_authorizations/_form.html.erb +24 -12
  59. data/app/views/admin/return_authorizations/edit.html.erb +1 -1
  60. data/app/views/admin/return_authorizations/index.html.erb +6 -4
  61. data/app/views/admin/shared/_address_form.html.erb +20 -17
  62. data/app/views/admin/shared/_adjustments_table.html.erb +21 -0
  63. data/app/views/admin/shared/_configuration_menu.html.erb +1 -1
  64. data/app/views/admin/shared/_destroy.js.erb +3 -0
  65. data/app/views/admin/shared/_new_adjustment_button.html.erb +8 -0
  66. data/app/views/admin/shared/_order_tabs.html.erb +26 -22
  67. data/app/views/admin/shared/_report_criteria.html.erb +2 -2
  68. data/app/views/admin/shared/_update_order_state.js +6 -0
  69. data/app/views/admin/shipments/_form.html.erb +5 -11
  70. data/app/views/admin/shipments/edit.html.erb +4 -4
  71. data/app/views/admin/taxons/_form.html.erb +2 -2
  72. data/app/views/admin/taxons/_taxon_table.html.erb +3 -8
  73. data/app/views/admin/taxons/available.js.erb +4 -7
  74. data/app/views/admin/taxons/select.js.erb +2 -0
  75. data/app/views/admin/variants/index.html.erb +1 -1
  76. data/app/views/checkout/_address.html.erb +2 -0
  77. data/app/views/checkout/_delivery.html.erb +3 -3
  78. data/app/views/checkout/_payment.html.erb +23 -18
  79. data/app/views/checkout/_summary.html.erb +0 -10
  80. data/app/views/checkout/payment/_gateway.html.erb +1 -1
  81. data/app/views/checkout/registration.html.erb +20 -0
  82. data/app/views/layouts/admin.html.erb +2 -2
  83. data/app/views/order_mailer/{cancel.html.erb → cancel_email.text.erb} +4 -4
  84. data/app/views/order_mailer/{confirm.html.erb → confirm_email.text.erb} +3 -3
  85. data/app/views/orders/_line_item.html.erb +1 -3
  86. data/app/views/orders/edit.html.erb +1 -1
  87. data/app/views/shared/_basic_layout.html.erb +44 -0
  88. data/app/views/shared/_google_analytics.html.erb +23 -22
  89. data/app/views/shared/_head.html.erb +1 -1
  90. data/app/views/shared/_products.html.erb +1 -1
  91. data/app/views/shipment_mailer/shipped_email.text.erb +15 -0
  92. data/app/views/taxons/_taxon.html.erb +2 -2
  93. data/config/initializers/spree.rb +6 -2
  94. data/config/locales/{en_spree.yml → en.yml} +47 -17
  95. data/config/routes.rb +15 -8
  96. data/{lib/generators/templates/db → db}/default/countries.yml +0 -0
  97. data/{lib/generators/templates/db → db}/default/roles.yml +0 -0
  98. data/{lib/generators/templates/db → db}/default/states.yml +0 -0
  99. data/{lib/generators/templates/db → db}/default/zone_members.yml +0 -0
  100. data/{lib/generators/templates/db → db}/default/zones.yml +0 -0
  101. data/{lib/generators/templates/db → db}/migrate/20090823005402_spree_zero_nine_zero.rb +0 -0
  102. data/{lib/generators/templates/db → db}/migrate/20090904192342_create_indexes_for_inventory_units.rb +0 -0
  103. data/{lib/generators/templates/db → db}/migrate/20090923100315_add_count_on_hand_to_variants_and_products.rb +0 -0
  104. data/{lib/generators/templates/db → db}/migrate/20091007134354_change_taxons_to_nested_set.rb +0 -0
  105. data/{lib/generators/templates/db → db}/migrate/20091008091614_move_to_configurable_gateways.rb +0 -0
  106. data/{lib/generators/templates/db → db}/migrate/20091012120519_product_groups_and_scopes.rb +0 -0
  107. data/{lib/generators/templates/db → db}/migrate/20091015110842_add_open_id_authentication_tables.rb +0 -0
  108. data/{lib/generators/templates/db → db}/migrate/20091015153048_add_openid_field_to_users.rb +0 -0
  109. data/{lib/generators/templates/db → db}/migrate/20091016174634_change_preference_value_type.rb +0 -0
  110. data/{lib/generators/templates/db → db}/migrate/20091017175558_create_billing_integrations.rb +0 -0
  111. data/{lib/generators/templates/db → db}/migrate/20091021133257_charge_refactoring.rb +7 -4
  112. data/{lib/generators/templates/db → db}/migrate/20091104151730_add_some_indexes.rb +0 -0
  113. data/{lib/generators/templates/db → db}/migrate/20091126190904_checkout_state_machine.rb +0 -0
  114. data/{lib/generators/templates/db → db}/migrate/20091209153045_state_for_shipments.rb +0 -0
  115. data/{lib/generators/templates/db → db}/migrate/20091209202200_make_state_events_polymorphic.rb +0 -0
  116. data/{lib/generators/templates/db → db}/migrate/20091211203813_ship_address_id_for_checkouts.rb +0 -0
  117. data/{lib/generators/templates/db → db}/migrate/20091212161118_shipping_method_id_for_checkouts.rb +0 -0
  118. data/{lib/generators/templates/db → db}/migrate/20091213222815_creditcard_last_four_digits.rb +0 -0
  119. data/{lib/generators/templates/db → db}/migrate/20091214183826_populate_legacy_shipment_state.rb +0 -0
  120. data/{lib/generators/templates/db → db}/migrate/20100105090147_add_cost_price.rb +0 -0
  121. data/{lib/generators/templates/db → db}/migrate/20100105132138_shipment_id_for_inventory_units.rb +0 -0
  122. data/{lib/generators/templates/db → db}/migrate/20100111205525_cim_fields_for_creditcards.rb +0 -0
  123. data/{lib/generators/templates/db → db}/migrate/20100112151511_create_return_authorizations.rb +0 -0
  124. data/{lib/generators/templates/db → db}/migrate/20100113090919_add_return_authorization_to_inventory_units.rb +0 -0
  125. data/{lib/generators/templates/db → db}/migrate/20100113203104_create_trackers.rb +0 -0
  126. data/{lib/generators/templates/db → db}/migrate/20100121160010_creditcard_id_for_creditcard_txns.rb +0 -0
  127. data/{lib/generators/templates/db → db}/migrate/20100121183934_original_creditcard_txn_id_for_creditcard_txns.rb +0 -0
  128. data/{lib/generators/templates/db → db}/migrate/20100125145351_add_test_mode_to_billing_integration.rb +0 -0
  129. data/{lib/generators/templates/db → db}/migrate/20100126103714_create_products_product_groups.rb +0 -0
  130. data/{lib/generators/templates/db → db}/migrate/20100209025806_create_payment_methods.rb +0 -0
  131. data/{lib/generators/templates/db → db}/migrate/20100209144531_polymorphic_payments.rb +0 -0
  132. data/{lib/generators/templates/db → db}/migrate/20100213103131_change_payments_payment_method_to_belongs_to.rb +0 -0
  133. data/{lib/generators/templates/db → db}/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +0 -0
  134. data/{lib/generators/templates/db → db}/migrate/20100223170312_sti_for_transactions.rb +0 -0
  135. data/{lib/generators/templates/db → db}/migrate/20100223183812_drop_billing_integrations.rb +0 -0
  136. data/{lib/generators/templates/db → db}/migrate/20100224153127_deleted_at_for_payment_methods.rb +0 -0
  137. data/{lib/generators/templates/db → db}/migrate/20100301163454_add_adjustments_index.rb +0 -0
  138. data/{lib/generators/templates/db → db}/migrate/20100306153445_fix_by_popularity.rb +0 -0
  139. data/{lib/generators/templates/db → db}/migrate/20100317120946_add_alt_text_to_images.rb +0 -0
  140. data/{lib/generators/templates/db → db}/migrate/20100427121301_add_display_to_payment_methods.rb +0 -0
  141. data/{lib/generators/templates/db → db}/migrate/20100504142133_add_addresses_checkouts_indexes.rb +0 -0
  142. data/{lib/generators/templates/db → db}/migrate/20100506180619_add_icon_to_taxons.rb +0 -0
  143. data/{lib/generators/templates/db → db}/migrate/20100506185838_add_description_to_taxons.rb +0 -0
  144. data/{lib/generators/templates/db → db}/migrate/20100528155333_index_for_shipments_number.rb +0 -0
  145. data/{lib/generators/templates/db → db}/migrate/20100528185820_add_index_on_users_persistence_token.rb +0 -0
  146. data/{lib/generators/templates/db → db}/migrate/20100605152042_add_default_to_tax_categories.rb +0 -0
  147. data/{lib/generators/templates/db → db}/migrate/20100624110730_add_display_to_shipping_methods.rb +0 -0
  148. data/{lib/generators/templates/db → db}/migrate/20100624123336_rename_payment_method_display.rb +0 -0
  149. data/{lib/generators/templates/db → db}/migrate/20100624175547_rename_preferences_field.rb +0 -0
  150. data/{lib/generators/templates/db → db}/migrate/20100811163637_add_guest_flag.rb +0 -0
  151. data/{lib/generators/templates/db → db}/migrate/20100811205836_drop_order_token.rb +0 -0
  152. data/{lib/generators/templates/db → db}/migrate/20100812162326_payments_state_and_assigned_to_order_only.rb +0 -0
  153. data/{lib/generators/templates/db → db}/migrate/20100813023502_create_address_keys_for_order.rb +0 -0
  154. data/{lib/generators/templates/db → db}/migrate/20100813185745_payment_total_for_orders.rb +0 -0
  155. data/{lib/generators/templates/db → db}/migrate/20100816212146_shipping_method_id_for_orders.rb +0 -0
  156. data/{lib/generators/templates/db → db}/migrate/20100817152723_add_shipment_and_payment_state.rb +0 -0
  157. data/{lib/generators/templates/db → db}/migrate/20100819170125_refactor_adjustments.rb +0 -0
  158. data/{lib/generators/templates/db → db}/migrate/20100820135707_response_code_and_avs_response_for_payments.rb +0 -0
  159. data/{lib/generators/templates/db → db}/migrate/20100901171814_change_guest_flag_to_anonymous.rb +0 -0
  160. data/db/migrate/20100903203949_email_for_orders.rb +9 -0
  161. data/db/migrate/20100908170204_remove_unique_index_on_users_email.rb +9 -0
  162. data/db/migrate/20100923162011_create_mail_methods.rb +12 -0
  163. data/db/migrate/20100929151905_rename_frozen_to_locked.rb +8 -0
  164. data/db/migrate/20101008190536_move_special_instructions_to_orders.rb +11 -0
  165. data/db/migrate/20101026184700_create_log_entries.rb +15 -0
  166. data/db/migrate/20101026184714_migrate_transactions_to_payment_state.rb +94 -0
  167. data/db/migrate/20101026184746_delete_in_progress_orders.rb +18 -0
  168. data/db/migrate/20101026184808_migrate_checkout_to_orders.rb +27 -0
  169. data/db/migrate/20101026184833_migrate_adjustments.rb +9 -0
  170. data/db/migrate/20101026184855_remove_shipped_state.rb +14 -0
  171. data/db/migrate/20101026184916_prevent_nil_payment_total.rb +8 -0
  172. data/db/migrate/20101026184932_prevent_nil_email.rb +9 -0
  173. data/db/migrate/20101026184959_generate_anonymous_users.rb +14 -0
  174. data/db/migrate/20101026185022_update_order_state.rb +8 -0
  175. data/db/migrate/20101026192225_cleanup_legacy_tables.rb +11 -0
  176. data/db/migrate/20101028151745_remove_number_and_cvv_from_credicard.rb +9 -0
  177. data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +8 -0
  178. data/{lib/generators/templates/db → db}/sample/users.rb +0 -0
  179. data/db/seeds.rb +3 -0
  180. data/lib/generators/spree_core/upgrade_generator.rb +23 -0
  181. data/lib/scopes/product.rb +0 -5
  182. data/lib/spree/config.rb +4 -4
  183. data/lib/spree/current_order.rb +11 -3
  184. data/lib/spree/i18n_utils.rb +47 -0
  185. data/lib/spree/mail_interceptor.rb +23 -0
  186. data/lib/spree/mail_settings.rb +34 -0
  187. data/lib/spree/search/base.rb +50 -6
  188. data/lib/spree_core.rb +9 -8
  189. data/lib/{active_merchant/billing/authorize_net_cim.rb → spree_core/authorize_net_cim_hack.rb} +0 -0
  190. data/lib/spree_core/ext/active_record.rb +2 -0
  191. data/lib/spree_core/ssl_requirement.rb +9 -15
  192. data/lib/tasks/core.rake +1 -8
  193. data/lib/tasks/install.rake +27 -0
  194. data/{lib/generators/templates/public → public}/images/add-to-cart.png +0 -0
  195. data/{lib/generators/templates/public → public}/images/admin/bg/active-tab.png +0 -0
  196. data/{lib/generators/templates/public → public}/images/admin/bg/admin_tab_back.png +0 -0
  197. data/{lib/generators/templates/public → public}/images/admin/bg/admin_tab_selected_back.png +0 -0
  198. data/{lib/generators/templates/public → public}/images/admin/bg/content-back-blue.png +0 -0
  199. data/{lib/generators/templates/public → public}/images/admin/bg/content-back-green.png +0 -0
  200. data/{lib/generators/templates/public → public}/images/admin/bg/content-back.png +0 -0
  201. data/{lib/generators/templates/public → public}/images/admin/bg/flash-error.png +0 -0
  202. data/{lib/generators/templates/public → public}/images/admin/bg/flash-notice.png +0 -0
  203. data/{lib/generators/templates/public → public}/images/admin/bg/green-stripes.gif +0 -0
  204. data/{lib/generators/templates/public → public}/images/admin/bg/green-stripes.png +0 -0
  205. data/{lib/generators/templates/public → public}/images/admin/bg/grid_header_back.png +0 -0
  206. data/{lib/generators/templates/public → public}/images/admin/bg/grid_header_back_green.png +0 -0
  207. data/{lib/generators/templates/public → public}/images/admin/bg/header-bg.png +0 -0
  208. data/{lib/generators/templates/public → public}/images/admin/bg/header.png +0 -0
  209. data/{lib/generators/templates/public → public}/images/admin/bg/header_bg.jpg +0 -0
  210. data/{lib/generators/templates/public → public}/images/admin/bg/menu-current.png +0 -0
  211. data/{lib/generators/templates/public → public}/images/admin/bg/red-stripes.gif +0 -0
  212. data/{lib/generators/templates/public → public}/images/admin/bg/red-stripes.png +0 -0
  213. data/{lib/generators/templates/public → public}/images/admin/bg/spree_50.png +0 -0
  214. data/{lib/generators/templates/public → public}/images/admin/bg/subnav-divider.png +0 -0
  215. data/{lib/generators/templates/public → public}/images/admin/bg/subnav.png +0 -0
  216. data/{lib/generators/templates/public → public}/images/admin/bg/tab-back.png +0 -0
  217. data/{lib/generators/templates/public → public}/images/admin/buttons/blue/left_01.png +0 -0
  218. data/{lib/generators/templates/public → public}/images/admin/buttons/blue/right_01.png +0 -0
  219. data/{lib/generators/templates/public → public}/images/admin/buttons/drag-handle-green.png +0 -0
  220. data/{lib/generators/templates/public → public}/images/admin/buttons/green/left_01.png +0 -0
  221. data/{lib/generators/templates/public → public}/images/admin/buttons/green/right_01.png +0 -0
  222. data/{lib/generators/templates/public → public}/images/admin/buttons/left_01.png +0 -0
  223. data/{lib/generators/templates/public → public}/images/admin/buttons/left_01_small.png +0 -0
  224. data/{lib/generators/templates/public → public}/images/admin/buttons/orange/left_03.png +0 -0
  225. data/{lib/generators/templates/public → public}/images/admin/buttons/orange/right_03.png +0 -0
  226. data/{lib/generators/templates/public → public}/images/admin/buttons/right_01.png +0 -0
  227. data/{lib/generators/templates/public → public}/images/admin/buttons/right_01_small.png +0 -0
  228. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/1.png +0 -0
  229. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/10.png +0 -0
  230. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/2.png +0 -0
  231. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/3.png +0 -0
  232. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/4.png +0 -0
  233. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/5.png +0 -0
  234. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/6.png +0 -0
  235. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/7.png +0 -0
  236. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/8.png +0 -0
  237. data/{lib/generators/templates/public → public}/images/admin/icons/16x16/9.png +0 -0
  238. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/1.png +0 -0
  239. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/10.png +0 -0
  240. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/11.png +0 -0
  241. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/2.png +0 -0
  242. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/3.png +0 -0
  243. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/4.png +0 -0
  244. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/5.png +0 -0
  245. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/6.png +0 -0
  246. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/7.png +0 -0
  247. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/8.png +0 -0
  248. data/{lib/generators/templates/public → public}/images/admin/icons/32x32/9.png +0 -0
  249. data/{lib/generators/templates/public → public}/images/admin/icons/accept.png +0 -0
  250. data/{lib/generators/templates/public → public}/images/admin/icons/add.gif +0 -0
  251. data/{lib/generators/templates/public → public}/images/admin/icons/add.png +0 -0
  252. data/{lib/generators/templates/public → public}/images/admin/icons/arrow-down.gif +0 -0
  253. data/{lib/generators/templates/public → public}/images/admin/icons/cross.png +0 -0
  254. data/{lib/generators/templates/public → public}/images/admin/icons/delete.gif +0 -0
  255. data/{lib/generators/templates/public → public}/images/admin/icons/delete.png +0 -0
  256. data/{lib/generators/templates/public → public}/images/admin/icons/drag.gif +0 -0
  257. data/{lib/generators/templates/public → public}/images/admin/icons/edit.gif +0 -0
  258. data/{lib/generators/templates/public → public}/images/admin/icons/edit.png +0 -0
  259. data/{lib/generators/templates/public → public}/images/admin/icons/email.png +0 -0
  260. data/{lib/generators/templates/public → public}/images/admin/icons/error.png +0 -0
  261. data/{lib/generators/templates/public → public}/images/admin/icons/exclamation.png +0 -0
  262. data/{lib/generators/templates/public → public}/images/admin/icons/feed.png +0 -0
  263. data/{lib/generators/templates/public → public}/images/admin/icons/pdf.png +0 -0
  264. data/{lib/generators/templates/public → public}/images/admin/icons/reorder.gif +0 -0
  265. data/{lib/generators/templates/public → public}/images/admin/icons/search.gif +0 -0
  266. data/{lib/generators/templates/public → public}/images/admin/icons/send-email.png +0 -0
  267. data/{lib/generators/templates/public → public}/images/admin/icons/stop.png +0 -0
  268. data/{lib/generators/templates/public → public}/images/admin/icons/tick.png +0 -0
  269. data/{lib/generators/templates/public → public}/images/admin/icons/up.gif +0 -0
  270. data/{lib/generators/templates/public → public}/images/admin/icons/xls.png +0 -0
  271. data/{lib/generators/templates/public → public}/images/admin/tabs/off-left.png +0 -0
  272. data/{lib/generators/templates/public → public}/images/admin/tabs/off-right.png +0 -0
  273. data/{lib/generators/templates/public → public}/images/admin/tabs/on-left.png +0 -0
  274. data/{lib/generators/templates/public → public}/images/admin/tabs/on-right.png +0 -0
  275. data/{lib/generators/templates/public → public}/images/ajax_loader.gif +0 -0
  276. data/{lib/generators/templates/public → public}/images/amex_cid.gif +0 -0
  277. data/{lib/generators/templates/public → public}/images/bg-button-hover.png +0 -0
  278. data/{lib/generators/templates/public → public}/images/bg-button-pressed.png +0 -0
  279. data/{lib/generators/templates/public → public}/images/bg-button.gif +0 -0
  280. data/{lib/generators/templates/public → public}/images/bg-button.png +0 -0
  281. data/{lib/generators/templates/public → public}/images/blue/left_01.png +0 -0
  282. data/{lib/generators/templates/public → public}/images/blue/right_01.png +0 -0
  283. data/{lib/generators/templates/public → public}/images/body-back.png +0 -0
  284. data/{lib/generators/templates/public → public}/images/bottom_shine.png +0 -0
  285. data/{lib/generators/templates/public → public}/images/breadcrumb.gif +0 -0
  286. data/{lib/generators/templates/public → public}/images/button-dark-hover.png +0 -0
  287. data/{lib/generators/templates/public → public}/images/button-dark.png +0 -0
  288. data/{lib/generators/templates/public → public}/images/buttons/bg-button-hover.png +0 -0
  289. data/{lib/generators/templates/public → public}/images/buttons/bg-button-pressed.png +0 -0
  290. data/{lib/generators/templates/public → public}/images/buttons/bg-button.gif +0 -0
  291. data/{lib/generators/templates/public → public}/images/buttons/bg-button.png +0 -0
  292. data/{lib/generators/templates/public → public}/images/buttons/blue/left_01.png +0 -0
  293. data/{lib/generators/templates/public → public}/images/buttons/blue/right_01.png +0 -0
  294. data/{lib/generators/templates/public → public}/images/buttons/button-dark-hover.png +0 -0
  295. data/{lib/generators/templates/public → public}/images/buttons/button-dark.png +0 -0
  296. data/{lib/generators/templates/public → public}/images/buttons/drag-handle-green.png +0 -0
  297. data/{lib/generators/templates/public → public}/images/buttons/green/left_01.png +0 -0
  298. data/{lib/generators/templates/public → public}/images/buttons/green/right_01.png +0 -0
  299. data/{lib/generators/templates/public → public}/images/buttons/left_01.png +0 -0
  300. data/{lib/generators/templates/public → public}/images/buttons/left_01_small.png +0 -0
  301. data/{lib/generators/templates/public → public}/images/buttons/orange/left_03.png +0 -0
  302. data/{lib/generators/templates/public → public}/images/buttons/orange/right_03.png +0 -0
  303. data/{lib/generators/templates/public → public}/images/buttons/right_01.png +0 -0
  304. data/{lib/generators/templates/public → public}/images/buttons/right_01_small.png +0 -0
  305. data/{lib/generators/templates/public → public}/images/buttons/sxsw-ribbon-v1.png +0 -0
  306. data/{lib/generators/templates/public → public}/images/buttons/top-shine.png +0 -0
  307. data/{lib/generators/templates/public → public}/images/calendar_date_select/calendar.gif +0 -0
  308. data/{lib/generators/templates/public → public}/images/cart-empty.png +0 -0
  309. data/{lib/generators/templates/public → public}/images/cart-empty_x32.png +0 -0
  310. data/{lib/generators/templates/public → public}/images/cart-full.png +0 -0
  311. data/{lib/generators/templates/public → public}/images/cart-full_x32.png +0 -0
  312. data/{lib/generators/templates/public → public}/images/checkout.png +0 -0
  313. data/{lib/generators/templates/public → public}/images/creditcard.gif +0 -0
  314. data/{lib/generators/templates/public → public}/images/datepicker/backstripes.gif +0 -0
  315. data/{lib/generators/templates/public → public}/images/datepicker/bg_header.jpg +0 -0
  316. data/{lib/generators/templates/public → public}/images/datepicker/bullet1.gif +0 -0
  317. data/{lib/generators/templates/public → public}/images/datepicker/bullet2.gif +0 -0
  318. data/{lib/generators/templates/public → public}/images/datepicker/cal.gif +0 -0
  319. data/{lib/generators/templates/public → public}/images/datepicker/gradient-e5e5e5-ffffff.gif +0 -0
  320. data/{lib/generators/templates/public → public}/images/discover_cid.gif +0 -0
  321. data/{lib/generators/templates/public → public}/images/drag-handle-green.png +0 -0
  322. data/{lib/generators/templates/public → public}/images/favicon.ico +0 -0
  323. data/{lib/generators/templates/public → public}/images/green/left_01.png +0 -0
  324. data/{lib/generators/templates/public → public}/images/green/right_01.png +0 -0
  325. data/{lib/generators/templates/public → public}/images/grid.png +0 -0
  326. data/{lib/generators/templates/public → public}/images/left_01.png +0 -0
  327. data/{lib/generators/templates/public → public}/images/left_01_small.png +0 -0
  328. data/{lib/generators/templates/public → public}/images/master_cid.jpg +0 -0
  329. data/{lib/generators/templates/public → public}/images/menu-current.png +0 -0
  330. data/{lib/generators/templates/public → public}/images/menu-hover.png +0 -0
  331. data/{lib/generators/templates/public → public}/images/noimage/mini.jpg +0 -0
  332. data/{lib/generators/templates/public → public}/images/noimage/product.jpg +0 -0
  333. data/{lib/generators/templates/public → public}/images/noimage/small.jpg +0 -0
  334. data/{lib/generators/templates/public → public}/images/openid-inputicon.gif +0 -0
  335. data/{lib/generators/templates/public → public}/images/orange/left_03.png +0 -0
  336. data/{lib/generators/templates/public → public}/images/orange/right_03.png +0 -0
  337. data/{lib/generators/templates/public → public}/images/progress.gif +0 -0
  338. data/{lib/generators/templates/public → public}/images/right_01.png +0 -0
  339. data/{lib/generators/templates/public → public}/images/right_01_small.png +0 -0
  340. data/{lib/generators/templates/public → public}/images/separator.png +0 -0
  341. data/{lib/generators/templates/public → public}/images/shadow-top.png +0 -0
  342. data/{lib/generators/templates/public → public}/images/shadow_top.png +0 -0
  343. data/{lib/generators/templates/public → public}/images/spinner.gif +0 -0
  344. data/{lib/generators/templates/public → public}/images/spree.jpg +0 -0
  345. data/{lib/generators/templates/public → public}/images/spree/progress.gif +0 -0
  346. data/{lib/generators/templates/public → public}/images/spree/spinner.gif +0 -0
  347. data/{lib/generators/templates/public → public}/images/spree/spree.jpg +0 -0
  348. data/{lib/generators/templates/public → public}/images/step-progress/completed-completed.gif +0 -0
  349. data/{lib/generators/templates/public → public}/images/step-progress/completed-current.gif +0 -0
  350. data/{lib/generators/templates/public → public}/images/step-progress/completed-first.gif +0 -0
  351. data/{lib/generators/templates/public → public}/images/step-progress/current-first.gif +0 -0
  352. data/{lib/generators/templates/public → public}/images/step-progress/current-incomplete.gif +0 -0
  353. data/{lib/generators/templates/public → public}/images/step-progress/current-right.gif +0 -0
  354. data/{lib/generators/templates/public → public}/images/step-progress/incomplete-incomplete.gif +0 -0
  355. data/{lib/generators/templates/public → public}/images/step-progress/incomplete-right.gif +0 -0
  356. data/{lib/generators/templates/public → public}/images/steps/1.png +0 -0
  357. data/{lib/generators/templates/public → public}/images/steps/1_small.png +0 -0
  358. data/{lib/generators/templates/public → public}/images/steps/2.png +0 -0
  359. data/{lib/generators/templates/public → public}/images/steps/2_small.png +0 -0
  360. data/{lib/generators/templates/public → public}/images/steps/3.png +0 -0
  361. data/{lib/generators/templates/public → public}/images/steps/3_small.png +0 -0
  362. data/{lib/generators/templates/public → public}/images/steps/4.png +0 -0
  363. data/{lib/generators/templates/public → public}/images/steps/4_small.png +0 -0
  364. data/{lib/generators/templates/public → public}/images/steps/5.png +0 -0
  365. data/{lib/generators/templates/public → public}/images/steps/5_small.png +0 -0
  366. data/{lib/generators/templates/public → public}/images/steps/6.png +0 -0
  367. data/{lib/generators/templates/public → public}/images/steps/6_small.png +0 -0
  368. data/{lib/generators/templates/public → public}/images/sxsw-ribbon-v1.png +0 -0
  369. data/{lib/generators/templates/public → public}/images/tab_bottom.gif +0 -0
  370. data/{lib/generators/templates/public → public}/images/tile-header.png +0 -0
  371. data/{lib/generators/templates/public → public}/images/tile-slider.png +0 -0
  372. data/{lib/generators/templates/public → public}/images/top-shine.png +0 -0
  373. data/{lib/generators/templates/public → public}/images/tree-nav-icons/bullet.gif +0 -0
  374. data/{lib/generators/templates/public → public}/images/tree-nav-icons/minus.gif +0 -0
  375. data/{lib/generators/templates/public → public}/images/tree-nav-icons/plus.gif +0 -0
  376. data/{lib/generators/templates/public → public}/images/tree-nav-icons/treeview-loading.gif +0 -0
  377. data/{lib/generators/templates/public → public}/images/tree-nav-icons/treeview-sprite.gif +0 -0
  378. data/{lib/generators/templates/public → public}/images/update.png +0 -0
  379. data/{lib/generators/templates/public → public}/images/visa_cid.gif +0 -0
  380. data/{lib/generators/templates/public → public}/images/wrapper-back-2.png +0 -0
  381. data/{lib/generators/templates/public → public}/images/wrapper-back.png +0 -0
  382. data/{lib/generators/templates/public → public}/images/yui-menubaritem_submenuindicator.png +0 -0
  383. data/{lib/generators/templates/public → public}/images/yui-menubaritem_submenuindicator_disabled.png +0 -0
  384. data/{lib/generators/templates/public → public}/images/yui-menuitem_checkbox.png +0 -0
  385. data/{lib/generators/templates/public → public}/images/yui-menuitem_checkbox_disabled.png +0 -0
  386. data/{lib/generators/templates/public → public}/images/yui-menuitem_submenuindicator.png +0 -0
  387. data/{lib/generators/templates/public → public}/images/yui-menuitem_submenuindicator_disabled.png +0 -0
  388. data/{lib/generators/templates/public → public}/images/yui-sprite.png +0 -0
  389. data/{lib/generators/templates/public → public}/javascripts/additional-methods.js +0 -0
  390. data/{lib/generators/templates/public → public}/javascripts/admin.js +11 -11
  391. data/{lib/generators/templates/public → public}/javascripts/admin/address_states.js +0 -0
  392. data/{lib/generators/templates/public → public}/javascripts/admin/checkouts/edit.js +1 -1
  393. data/{lib/generators/templates/public → public}/javascripts/admin/orders/edit.js +0 -0
  394. data/{lib/generators/templates/public → public}/javascripts/admin/orders/edit_form.js +0 -0
  395. data/{lib/generators/templates/public → public}/javascripts/admin/payments/new.js +0 -0
  396. data/{lib/generators/templates/public → public}/javascripts/admin/unobtrusive_handlers.js +0 -0
  397. data/{lib/generators/templates/public → public}/javascripts/application.js +3 -3
  398. data/{lib/generators/templates/public → public}/javascripts/calculator.js +0 -0
  399. data/{lib/generators/templates/public → public}/javascripts/checkout.js +26 -15
  400. data/{lib/generators/templates/public → public}/javascripts/datepicker.js +0 -0
  401. data/{lib/generators/templates/public → public}/javascripts/gateway.js +0 -0
  402. data/{lib/generators/templates/public → public}/javascripts/jquery-1.4.2.min.js +0 -0
  403. data/{lib/generators/templates/public → public}/javascripts/jquery-ui.js +0 -0
  404. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/images/help.gif +0 -0
  405. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/images/important.gif +0 -0
  406. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/images/info.gif +0 -0
  407. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/images/title.gif +0 -0
  408. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/jquery.alerts.css +0 -0
  409. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/jquery.alerts.js +0 -0
  410. data/{lib/generators/templates/public → public}/javascripts/jquery.alerts/jquery.alerts.spree.css +0 -0
  411. data/{lib/generators/templates/public → public}/javascripts/jquery.autocomplete.min.js +0 -0
  412. data/{lib/generators/templates/public → public}/javascripts/jquery.js +0 -0
  413. data/{lib/generators/templates/public → public}/javascripts/jquery.suggest.js +0 -0
  414. data/{lib/generators/templates/public → public}/javascripts/jquery.template.js +0 -0
  415. data/{lib/generators/templates/public → public}/javascripts/jquery.tokeninput.js +0 -0
  416. data/{lib/generators/templates/public → public}/javascripts/jquery.validate.min.js +0 -0
  417. data/{lib/generators/templates/public → public}/javascripts/jrails.autocomplete.js +0 -0
  418. data/{lib/generators/templates/public → public}/javascripts/jrails.js +0 -0
  419. data/{lib/generators/templates/public → public}/javascripts/jsTree/jquery.tree.js +0 -0
  420. data/{lib/generators/templates/public → public}/javascripts/jsTree/plugins/jquery.tree.contextmenu.js +0 -0
  421. data/{lib/generators/templates/public → public}/javascripts/jsTree/themes/apple/bg.jpg +0 -0
  422. data/{lib/generators/templates/public → public}/javascripts/jsTree/themes/apple/dot_for_ie.gif +0 -0
  423. data/{lib/generators/templates/public → public}/javascripts/jsTree/themes/apple/icons.png +0 -0
  424. data/{lib/generators/templates/public → public}/javascripts/jsTree/themes/apple/style.css +0 -0
  425. data/{lib/generators/templates/public → public}/javascripts/jsTree/themes/apple/throbber.gif +0 -0
  426. data/{lib/generators/templates/public → public}/javascripts/lang/af.js +0 -0
  427. data/{lib/generators/templates/public → public}/javascripts/lang/ar.js +0 -0
  428. data/{lib/generators/templates/public → public}/javascripts/lang/de.js +0 -0
  429. data/{lib/generators/templates/public → public}/javascripts/lang/du.js +0 -0
  430. data/{lib/generators/templates/public → public}/javascripts/lang/en.js +0 -0
  431. data/{lib/generators/templates/public → public}/javascripts/lang/es.js +0 -0
  432. data/{lib/generators/templates/public → public}/javascripts/lang/fi.js +0 -0
  433. data/{lib/generators/templates/public → public}/javascripts/lang/fr.js +0 -0
  434. data/{lib/generators/templates/public → public}/javascripts/lang/gr.js +0 -0
  435. data/{lib/generators/templates/public → public}/javascripts/lang/he.js +0 -0
  436. data/{lib/generators/templates/public → public}/javascripts/lang/it.js +0 -0
  437. data/{lib/generators/templates/public → public}/javascripts/lang/nl.js +0 -0
  438. data/{lib/generators/templates/public → public}/javascripts/lang/no.js +0 -0
  439. data/{lib/generators/templates/public → public}/javascripts/lang/pt.js +0 -0
  440. data/{lib/generators/templates/public → public}/javascripts/lang/ro.js +0 -0
  441. data/{lib/generators/templates/public → public}/javascripts/lang/ru.js +0 -0
  442. data/{lib/generators/templates/public → public}/javascripts/lang/sp.js +0 -0
  443. data/{lib/generators/templates/public → public}/javascripts/lang/sv.js +0 -0
  444. data/{lib/generators/templates/public → public}/javascripts/lang/ua.js +0 -0
  445. data/{lib/generators/templates/public → public}/javascripts/localization/messages_cn.js +0 -0
  446. data/{lib/generators/templates/public → public}/javascripts/localization/messages_cs.js +0 -0
  447. data/{lib/generators/templates/public → public}/javascripts/localization/messages_da.js +0 -0
  448. data/{lib/generators/templates/public → public}/javascripts/localization/messages_de.js +0 -0
  449. data/{lib/generators/templates/public → public}/javascripts/localization/messages_es.js +0 -0
  450. data/{lib/generators/templates/public → public}/javascripts/localization/messages_fr.js +0 -0
  451. data/{lib/generators/templates/public → public}/javascripts/localization/messages_hu.js +0 -0
  452. data/{lib/generators/templates/public → public}/javascripts/localization/messages_it.js +0 -0
  453. data/{lib/generators/templates/public → public}/javascripts/localization/messages_kk.js +0 -0
  454. data/{lib/generators/templates/public → public}/javascripts/localization/messages_nl.js +0 -0
  455. data/{lib/generators/templates/public → public}/javascripts/localization/messages_no.js +0 -0
  456. data/{lib/generators/templates/public → public}/javascripts/localization/messages_pl.js +0 -0
  457. data/{lib/generators/templates/public → public}/javascripts/localization/messages_ptbr.js +0 -0
  458. data/{lib/generators/templates/public → public}/javascripts/localization/messages_ro.js +0 -0
  459. data/{lib/generators/templates/public → public}/javascripts/localization/messages_ru.js +0 -0
  460. data/{lib/generators/templates/public → public}/javascripts/localization/messages_se.js +0 -0
  461. data/{lib/generators/templates/public → public}/javascripts/localization/messages_sk.js +0 -0
  462. data/{lib/generators/templates/public → public}/javascripts/localization/messages_tr.js +0 -0
  463. data/{lib/generators/templates/public → public}/javascripts/localization/messages_tw.js +0 -0
  464. data/{lib/generators/templates/public → public}/javascripts/localization/messages_ua.js +0 -0
  465. data/{lib/generators/templates/public → public}/javascripts/nested-attribute.js +0 -0
  466. data/{lib/generators/templates/public → public}/javascripts/open_id.js +0 -0
  467. data/{lib/generators/templates/public → public}/javascripts/product.js +0 -0
  468. data/{lib/generators/templates/public → public}/javascripts/rails.js +0 -0
  469. data/{lib/generators/templates/public → public}/javascripts/taxonomy.js +0 -0
  470. data/{lib/generators/templates/public → public}/javascripts/zone.js +0 -0
  471. data/{lib/generators/templates/public → public}/stylesheets/admin/admin-forms.css +0 -0
  472. data/{lib/generators/templates/public → public}/stylesheets/admin/admin-reset.css +0 -0
  473. data/{lib/generators/templates/public → public}/stylesheets/admin/admin-tables.css +0 -0
  474. data/{lib/generators/templates/public → public}/stylesheets/admin/admin-typography.css +0 -0
  475. data/{lib/generators/templates/public → public}/stylesheets/admin/admin.css +21 -18
  476. data/{lib/generators/templates/public → public}/stylesheets/admin/autocomplete.css +0 -1
  477. data/{lib/generators/templates/public → public}/stylesheets/admin/dashboard.css +0 -0
  478. data/{lib/generators/templates/public → public}/stylesheets/admin/edit_checkouts.css +0 -0
  479. data/{lib/generators/templates/public → public}/stylesheets/admin/grids.css +0 -0
  480. data/{lib/generators/templates/public → public}/stylesheets/admin/reset-fonts-grids-2-6-0.css +0 -0
  481. data/{lib/generators/templates/public → public}/stylesheets/admin/token-input.css +0 -0
  482. data/{lib/generators/templates/public → public}/stylesheets/admin/yui-includes.css +0 -0
  483. data/{lib/generators/templates/public → public}/stylesheets/datepicker.css +0 -0
  484. data/{lib/generators/templates/public → public}/stylesheets/jquery.autocomplete.css +0 -0
  485. data/{lib/generators/templates/public → public}/stylesheets/scaffold.css +0 -0
  486. data/{lib/generators/templates/public → public}/stylesheets/screen.css +0 -0
  487. metadata +475 -402
  488. data/app/controllers/admin/checkouts_controller.rb +0 -58
  489. data/app/models/checkout.rb +0 -141
  490. data/app/models/order_mailer.rb +0 -24
  491. data/app/views/admin/checkouts/show.html.erb +0 -131
  492. data/app/views/admin/mail_settings/edit.html.erb +0 -114
  493. data/app/views/admin/mail_settings/show.html.erb +0 -59
  494. data/app/views/admin/taxons/select.html.erb +0 -1
  495. data/app/views/checkout/_complete.html.erb +0 -1
  496. data/app/views/password_resets/edit.html.erb +0 -12
  497. data/app/views/password_resets/new.html.erb +0 -12
  498. data/config/initializers/touch.rb +0 -14
  499. data/lib/generators/spree_core/extension_generator.rb +0 -57
  500. data/lib/generators/spree_core/install_generator.rb +0 -59
  501. data/lib/generators/templates/LICENSE +0 -23
  502. data/lib/generators/templates/README.md +0 -13
  503. data/lib/generators/templates/Rakefile +0 -1
  504. data/lib/generators/templates/application_controller.rb +0 -4
  505. data/lib/generators/templates/extension.gemspec.tt +0 -21
  506. data/lib/generators/templates/extension/engine.rb.tt +0 -14
  507. data/lib/generators/templates/extension/extension.rb.tt +0 -1
  508. data/lib/generators/templates/lib/tasks/%file_name%.rake.tt +0 -1
  509. data/lib/generators/templates/public/javascripts/jquery-1.3.2.min.js +0 -19
  510. data/lib/generators/templates/public/javascripts/jquery-and-plugins.js +0 -36
  511. data/lib/generators/templates/spree_site.rb +0 -8
  512. data/lib/spree/search.rb +0 -47
  513. data/lib/spree_core/preferences/mail_settings.rb +0 -57
@@ -0,0 +1,3 @@
1
+ class LogEntry < ActiveRecord::Base
2
+ belongs_to :source, :polymorphic => true
3
+ end
@@ -0,0 +1,23 @@
1
+ class MailMethod < ActiveRecord::Base
2
+
3
+ MAIL_AUTH = ['none', 'plain', 'login', 'cram_md5']
4
+ SECURE_CONNECTION_TYPES = ['None','SSL','TLS']
5
+
6
+ preference :enable_mail_delivery, :boolean, :default => false
7
+ preference :mail_host, :string, :default => 'localhost'
8
+ preference :mail_domain, :string, :default => 'localhost'
9
+ preference :mail_port, :integer, :default => 25
10
+ preference :mail_auth_type, :string, :default => MailMethod::MAIL_AUTH[0]
11
+ preference :smtp_username, :string
12
+ preference :smtp_password, :string
13
+ preference :secure_connection_type, :string, :default => MailMethod::SECURE_CONNECTION_TYPES[0]
14
+ preference :mails_from, :string, :default => "no-reply@example.com"
15
+ preference :mail_bcc, :string, :default => "spree@example.com"
16
+ preference :intercept_email, :string, :default => nil
17
+
18
+ validates :environment, :presence => true
19
+
20
+ def self.current
21
+ MailMethod.where(:environment => Rails.env).first
22
+ end
23
+ end
data/app/models/order.rb CHANGED
@@ -1,24 +1,20 @@
1
1
  class Order < ActiveRecord::Base
2
- # module Totaling
3
- # def total
4
- # map(&:amount).sum
5
- # end
6
- # end
7
2
 
8
- attr_accessible :line_items, :bill_address, :ship_address
9
- #attr_protected :charge_total, :item_total, :total, :user, :user_id, :number, :token
3
+ attr_accessible :line_items, :bill_address_attributes, :ship_address_attributes, :payments_attributes, :ship_address, :line_items_attributes,
4
+ :shipping_method_id, :email, :use_billing, :special_instructions
10
5
 
11
6
  belongs_to :user
12
-
13
7
  belongs_to :bill_address, :foreign_key => "bill_address_id", :class_name => "Address"
14
8
  belongs_to :ship_address, :foreign_key => "ship_address_id", :class_name => "Address"
15
9
  belongs_to :shipping_method
10
+
16
11
  has_many :state_events, :as => :stateful
17
12
  has_many :line_items, :dependent => :destroy
18
13
  has_many :inventory_units
19
- has_many :payments, :dependent => :destroy#, :extend => Totaling
14
+ has_many :payments, :dependent => :destroy
20
15
  has_many :shipments, :dependent => :destroy
21
16
  has_many :return_authorizations, :dependent => :destroy
17
+ has_many :adjustments, :dependent => :destroy
22
18
 
23
19
  accepts_nested_attributes_for :line_items
24
20
  accepts_nested_attributes_for :bill_address
@@ -26,19 +22,15 @@ class Order < ActiveRecord::Base
26
22
  accepts_nested_attributes_for :payments
27
23
  accepts_nested_attributes_for :shipments
28
24
 
29
- has_many :adjustments
30
-
31
25
  before_create :create_user
32
26
  before_create :generate_order_number
33
27
 
34
- delegate :email, :to => :user
28
+ validates_presence_of :email, :if => :require_email
29
+
35
30
  #delegate :ip_address, :to => :checkout
36
31
  def ip_address
37
32
  '192.168.1.100'
38
33
  end
39
- #delegate :special_instructions, :to => :checkout
40
-
41
- #validates :item_total, :total, :numericality => true
42
34
 
43
35
  scope :by_number, lambda {|number| where("orders.number = ?", number)}
44
36
  scope :between, lambda {|*dates| where("orders.created_at between :start and :stop").where(:start, dates.first.to_date).where(:stop, dates.last.to_date)}
@@ -49,16 +41,21 @@ class Order < ActiveRecord::Base
49
41
 
50
42
  make_permalink :field => :number
51
43
 
52
- # attr_accessible is a nightmare with attachment_fu, so use attr_protected instead.
53
- attr_protected :charge_total, :item_total, :total, :user, :user_id, :number, :token #,:state
54
-
55
44
  attr_accessor :out_of_stock_items
56
45
 
46
+ class_inheritable_accessor :update_hooks
47
+ self.update_hooks = Set.new
48
+
49
+ # Use this method in other gems that wish to register their own custom logic that should be called after Order#updat
50
+ def self.register_update_hook(hook)
51
+ self.update_hooks.add(hook)
52
+ end
53
+
57
54
  def to_param
58
55
  number.to_s.parameterize.upcase
59
56
  end
60
57
 
61
- def complete?
58
+ def completed?
62
59
  !! completed_at
63
60
  end
64
61
 
@@ -78,6 +75,7 @@ class Order < ActiveRecord::Base
78
75
  state_machine :initial => 'cart', :use_transactions => false do
79
76
 
80
77
  event :next do
78
+ transition :from => 'cart', :to => 'address'
81
79
  transition :from => 'address', :to => 'delivery'
82
80
  transition :from => 'delivery', :to => 'payment'
83
81
  transition :from => 'payment', :to => 'confirm'
@@ -98,15 +96,28 @@ class Order < ActiveRecord::Base
98
96
  transition :to => 'awaiting_return'
99
97
  end
100
98
 
101
- before_transition :to => 'complete', :do => :process_payments!
99
+ before_transition :to => 'complete' do |order|
100
+ begin
101
+ order.process_payments!
102
+ rescue Spree::GatewayError
103
+ if Spree::Config[:allow_checkout_on_gateway_error]
104
+ true
105
+ else
106
+ false
107
+ end
108
+ end
109
+ end
110
+
102
111
  after_transition :to => 'complete', :do => :finalize!
103
112
  after_transition :to => 'delivery', :do => :create_tax_charge!
104
- after_transition :to => 'payment', :do => :create_shipment_and_shipping_charge!
113
+ after_transition :to => 'payment', :do => :create_shipment!
114
+ after_transition :to => 'canceled', :do => :after_cancel
105
115
 
106
116
  end
107
117
 
108
118
  # Indicates whether there are any backordered InventoryUnits associated with the Order.
109
119
  def backordered?
120
+ return false unless Spree::Config[:track_inventory_levels]
110
121
  inventory_units.backorder.present?
111
122
  end
112
123
 
@@ -116,11 +127,15 @@ class Order < ActiveRecord::Base
116
127
  # up in an infinite recursion as the associations try to save and then in turn try to call +update!+ again.)
117
128
  def update!
118
129
  update_totals
119
- update_shipment_state
120
130
  update_payment_state
131
+
132
+ # give each of the shipments a chance to update themselves
133
+ shipments.each { |shipment| shipment.update!(self) }#(&:update!)
134
+ update_shipment_state
121
135
  update_adjustments
122
136
  # update totals a second time in case updated adjustments have an effect on the total
123
137
  update_totals
138
+
124
139
  update_attributes_without_callbacks({
125
140
  :payment_state => payment_state,
126
141
  :shipment_state => shipment_state,
@@ -129,6 +144,8 @@ class Order < ActiveRecord::Base
129
144
  :payment_total => payment_total,
130
145
  :total => total
131
146
  })
147
+
148
+ update_hooks.each { |hook| self.send hook }
132
149
  end
133
150
 
134
151
  def restore_state
@@ -137,9 +154,10 @@ class Order < ActiveRecord::Base
137
154
  update_attribute("state", state_events.last.previous_state)
138
155
 
139
156
  if paid?
140
- InventoryUnit.sell_units(self) if inventory_units.empty?
141
- shipment.inventory_units = inventory_units
142
- shipment.ready!
157
+ raise "do something with inventory"
158
+ #InventoryUnit.assign_opening_inventory(self) if inventory_units.empty?
159
+ #shipment.inventory_units = inventory_units
160
+ #shipment.ready!
143
161
  end
144
162
 
145
163
  end
@@ -158,54 +176,9 @@ class Order < ActiveRecord::Base
158
176
 
159
177
 
160
178
 
161
- # def make_shipments_shipped
162
- # shipments.reject(&:shipped?).each do |shipment|
163
- # shipment.update_attributes(:state => 'shipped', :shipped_at => Time.now)
164
- # end
165
- # end
166
- #
167
- # def make_shipments_ready
168
- # shipments.each(&:ready)
169
- # end
170
- #
171
- # def make_shipments_pending
172
- # shipments.each(&:pend)
173
- # end
174
- #
175
- # def shipped_units
176
- # shipped_units = shipments.inject([]) { |units, shipment| units.concat(shipment.shipped? ? shipment.inventory_units : []) }
177
- # return nil if shipped_units.empty?
178
- #
179
- # shipped = {}
180
- # shipped_units.group_by(&:variant_id).each do |variant_id, ship_units|
181
- # shipped[Variant.find(variant_id)] = ship_units.size
182
- # end
183
- # shipped
184
- # end
185
-
186
- # def returnable_units
187
- # returned_units = return_authorizations.inject([]) { |units, return_auth| units << return_auth.inventory_units}
188
- # returned_units.flatten! unless returned_units.nil?
189
- #
190
- # returnable = shipped_units
191
- # return if returnable.nil?
192
- #
193
- # returned_units.group_by(&:variant_id).each do |variant_id, returned_units|
194
- # variant = returnable.detect { |ru| ru.first.id == variant_id }[0]
195
- #
196
- # count = returnable[variant] - returned_units.size
197
- # if count > 0
198
- # returnable[variant] = returnable[variant] - returned_units.size
199
- # else
200
- # returnable.delete variant
201
- # end
202
- # end
203
- #
204
- # returnable.empty? ? nil : returnable
205
- # end
206
-
207
179
  def allow_cancel?
208
- self.state != 'canceled'
180
+ return false unless completed? and state != 'canceled'
181
+ %w{ready backorder pending}.include? shipment_state
209
182
  end
210
183
 
211
184
  def allow_resume?
@@ -260,31 +233,12 @@ class Order < ActiveRecord::Base
260
233
  line_items.detect{|line_item| line_item.variant_id == variant.id}
261
234
  end
262
235
 
263
- # def mark_shipped
264
- # inventory_units.each do |inventory_unit|
265
- # inventory_unit.ship!
266
- # end
267
- # end
268
-
269
- # TODO: Re-implement these 4 methods
270
236
  def ship_total
271
- # shipping_charges.reload.map(&:amount).sum
272
- 0
237
+ adjustments.shipping.map(&:amount).sum
273
238
  end
274
239
 
275
240
  def tax_total
276
- # tax_charges.reload.map(&:amount).sum
277
- 0
278
- end
279
-
280
- def credit_total
281
- # credits.reload.map(&:amount).sum.abs
282
- 0
283
- end
284
-
285
- def charge_total
286
- # charges.reload.map(&:amount).sum
287
- 0
241
+ adjustments.tax.map(&:amount).sum
288
242
  end
289
243
 
290
244
  # Creates a new tax charge if applicable. Uses the highest possible matching rate and destroys any previous
@@ -298,26 +252,25 @@ class Order < ActiveRecord::Base
298
252
  rate.create_adjustment(I18n.t(:tax), self, self, true)
299
253
  end
300
254
 
301
- def create_shipment_and_shipping_charge!
255
+ # Creates a new shipment (adjustment is created by shipment model)
256
+ def create_shipment!
302
257
  shipping_method.reload
303
258
  if shipment.present?
304
259
  shipment.update_attributes(:shipping_method => shipping_method)
305
260
  else
306
- self.shipments << Shipment.create(:order => self, :shipping_method => shipping_method)
307
- end
308
- if shipping_charge = adjustments.shipping.first
309
- # shipping_charge.update_attributes(:originator_id => shipping_method.id)
310
- shipping_charge.originator = shipping_method
311
- shipping_charge.save
312
- else
313
- shipping_method.create_adjustment(I18n.t(:shipping), self, shipment, true)
261
+ self.shipments << Shipment.create(:order => self, :shipping_method => shipping_method, :address => self.ship_address)
314
262
  end
263
+
315
264
  end
316
265
 
317
266
  def outstanding_balance
318
267
  total - payment_total
319
268
  end
320
269
 
270
+ def outstanding_balance?
271
+ self.outstanding_balance != 0
272
+ end
273
+
321
274
  def destroy_inapplicable_adjustments
322
275
  destroyed = adjustments.reject(&:applicable?).map(&:destroy)
323
276
  adjustments.reload if destroyed.any?
@@ -328,46 +281,23 @@ class Order < ActiveRecord::Base
328
281
  "#{address.firstname} #{address.lastname}" if address
329
282
  end
330
283
 
331
- # def outstanding_balance?
332
- # outstanding_balance > 0
333
- # end
334
- #
335
- # def outstanding_credit
336
- # [0, payments.total - total].max
337
- # end
338
- #
339
- # def outstanding_credit?
340
- # outstanding_credit > 0
341
- # end
342
-
343
- # def creditcards
344
- # creditcard_ids = (payments.from_creditcard + checkout.payments.from_creditcard).map(&:source_id).uniq
345
- # Creditcard.scoped(:conditions => {:id => creditcard_ids})
346
- # end
347
-
348
- # Indicates whether order has a real user associated with it or just a placeholder anonymous user
349
- def anonymous?
350
- user && user.anonymous?
351
- end
352
-
353
- # Associates the order with a registered user (replacing the previously associated guest user)
354
- #
355
- # throws an Exception if there is already a registered user associated with the order
356
- def register!(user)
357
- raise "Already registred" if user and not user.anonymous?
358
- self.user = user and save!
284
+ def creditcards
285
+ creditcard_ids = payments.from_creditcard.map(&:source_id).uniq
286
+ Creditcard.scoped(:conditions => {:id => creditcard_ids})
359
287
  end
360
288
 
361
289
  def process_payments!
362
- payments.each(&:process!)
290
+ ret = payments.each(&:process!)
363
291
  end
364
292
 
365
293
  # Finalizes an in progress order after checkout is complete.
366
294
  # Called after transition to complete state when payments will have been processed
367
295
  def finalize!
368
- self.out_of_stock_items = InventoryUnit.sell_units(self)
369
- shipments.create(:inventory_units => inventory_units.reload)
370
296
  update_attribute(:completed_at, Time.now)
297
+ self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)
298
+ # lock any optional adjustments (coupon promotions, etc.)
299
+ adjustments.optional.each { |adjustment| adjustment.update_attribute("locked", true) }
300
+ OrderMailer.confirm_email(self).deliver
371
301
  end
372
302
 
373
303
 
@@ -418,49 +348,9 @@ class Order < ActiveRecord::Base
418
348
  end
419
349
 
420
350
 
421
-
422
-
423
351
  private
424
- # def complete_order
425
- # self.adjustments.each(&:update_amount)
426
- # update_attribute(:completed_at, Time.now)
427
- #
428
- # if email
429
- # OrderMailer.confirm(self).deliver
430
- # end
431
- #
432
- # begin
433
- # @out_of_stock_items = InventoryUnit.sell_units(self)
434
- # update_totals unless @out_of_stock_items.empty?
435
- # shipment.inventory_units = inventory_units
436
- # save!
437
- # rescue Exception => e
438
- # logger.error "Problem saving authorized order: #{e.message}"
439
- # logger.error self.to_yaml
440
- # end
441
- # end
442
- #
443
- # def cancel_order
444
- # make_shipments_pending
445
- # restock_inventory
446
- # OrderMailer.cancel(self).deliver
447
- # end
448
- #
449
- # def restock_inventory
450
- # inventory_units.each do |inventory_unit|
451
- # inventory_unit.restock! if inventory_unit.can_restock?
452
- # end
453
- #
454
- # inventory_units.reload
455
- # end
456
- #
457
- # def update_line_items
458
- # to_wipe = self.line_items.select {|li| 0 == li.quantity || li.quantity.nil? }
459
- # LineItem.destroy(to_wipe)
460
- # self.line_items -= to_wipe # important: remove defunct items, avoid a reload
461
- # end
462
-
463
352
  def create_user
353
+ self.email = user.email if self.user and user.email !~ /example.net/
464
354
  self.user ||= User.anonymous!
465
355
  end
466
356
 
@@ -471,6 +361,7 @@ class Order < ActiveRecord::Base
471
361
  # or there are InventoryUnits associated with the order that have a state of "sold" but are not associated with a Shipment.
472
362
  # ready when all Shipments are in the "ready" state
473
363
  # backorder when there is backordered inventory associated with an order
364
+ # pending when all Shipments are in the "pending" state
474
365
  #
475
366
  # The +shipment_state+ value helps with reporting, etc. since it provides a quick and easy way to locate Orders needing attention.
476
367
  def update_shipment_state
@@ -482,6 +373,8 @@ class Order < ActiveRecord::Base
482
373
  "shipped"
483
374
  when shipments.ready.count
484
375
  "ready"
376
+ when shipments.pending.count
377
+ "pending"
485
378
  else
486
379
  "partial"
487
380
  end
@@ -493,11 +386,13 @@ class Order < ActiveRecord::Base
493
386
  # paid when +payment_total+ is equal to +total+
494
387
  # balance_due when +payment_total+ is less than +total+
495
388
  # credit_owed when +payment_total+ is greater than +total+
389
+ # failed when most recent payment is in the failed state
496
390
  #
497
391
  # The +payment_state+ value helps with reporting, etc. since it provides a quick and easy way to locate Orders needing attention.
498
392
  def update_payment_state
499
393
  if payment_total < total
500
394
  self.payment_state = "balance_due"
395
+ self.payment_state = "failed" if payments.present? and payments.last.state == "failed"
501
396
  elsif payment_total > total
502
397
  self.payment_state = "credit_owed"
503
398
  else
@@ -529,8 +424,15 @@ class Order < ActiveRecord::Base
529
424
  self.adjustments.reload.each(&:update!)
530
425
  end
531
426
 
532
- # def create_shipment
533
- # self.shipments << Shipment.create(:order => self)
534
- # end
427
+ # Determine if email is required (we don't want validation errors before we hit the checkout)
428
+ def require_email
429
+ return true unless new_record? or state == 'cart'
430
+ end
431
+
432
+ def after_cancel
433
+ # TODO: make_shipments_pending
434
+ # TODO: restock_inventory
435
+ OrderMailer.cancel_email(self).deliver
436
+ end
535
437
 
536
438
  end