apispree_core 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (890) hide show
  1. data/LICENSE +26 -0
  2. data/README.md +15 -0
  3. data/app/controllers/admin/adjustments_controller.rb +10 -0
  4. data/app/controllers/admin/base_controller.rb +63 -0
  5. data/app/controllers/admin/configurations_controller.rb +2 -0
  6. data/app/controllers/admin/general_settings_controller.rb +22 -0
  7. data/app/controllers/admin/images_controller.rb +49 -0
  8. data/app/controllers/admin/inventory_settings_controller.rb +13 -0
  9. data/app/controllers/admin/inventory_units_controller.rb +2 -0
  10. data/app/controllers/admin/line_items_controller.rb +60 -0
  11. data/app/controllers/admin/mail_methods_controller.rb +8 -0
  12. data/app/controllers/admin/mail_settings_controller.rb +14 -0
  13. data/app/controllers/admin/option_types_controller.rb +65 -0
  14. data/app/controllers/admin/orders_controller.rb +136 -0
  15. data/app/controllers/admin/overview_controller.rb +14 -0
  16. data/app/controllers/admin/payment_methods_controller.rb +43 -0
  17. data/app/controllers/admin/payments_controller.rb +107 -0
  18. data/app/controllers/admin/product_groups_controller.rb +46 -0
  19. data/app/controllers/admin/product_properties_controller.rb +10 -0
  20. data/app/controllers/admin/product_scopes_controller.rb +35 -0
  21. data/app/controllers/admin/products_controller.rb +113 -0
  22. data/app/controllers/admin/products_controller.rb~ +114 -0
  23. data/app/controllers/admin/properties_controller.rb +11 -0
  24. data/app/controllers/admin/prototypes_controller.rb +26 -0
  25. data/app/controllers/admin/reports_controller.rb +50 -0
  26. data/app/controllers/admin/resource_controller.rb +232 -0
  27. data/app/controllers/admin/return_authorizations_controller.rb +17 -0
  28. data/app/controllers/admin/shipments_controller.rb +117 -0
  29. data/app/controllers/admin/shipping_categories_controller.rb +2 -0
  30. data/app/controllers/admin/shipping_methods_controller.rb +14 -0
  31. data/app/controllers/admin/states_controller.rb +25 -0
  32. data/app/controllers/admin/tax_categories_controller.rb +2 -0
  33. data/app/controllers/admin/tax_rates_controller.rb +22 -0
  34. data/app/controllers/admin/tax_settings_controller.rb +13 -0
  35. data/app/controllers/admin/taxonomies_controller.rb +20 -0
  36. data/app/controllers/admin/taxons_controller.rb +161 -0
  37. data/app/controllers/admin/trackers_controller.rb +2 -0
  38. data/app/controllers/admin/users_controller.rb +65 -0
  39. data/app/controllers/admin/variants_controller.rb +51 -0
  40. data/app/controllers/admin/zones_controller.rb +23 -0
  41. data/app/controllers/checkout_controller.rb +97 -0
  42. data/app/controllers/content_controller.rb +21 -0
  43. data/app/controllers/locale_controller.rb +14 -0
  44. data/app/controllers/orders_controller.rb +64 -0
  45. data/app/controllers/products_controller.rb +39 -0
  46. data/app/controllers/spree/base_controller.rb +4 -0
  47. data/app/controllers/states_controller.rb +16 -0
  48. data/app/controllers/taxons_controller.rb +22 -0
  49. data/app/helpers/account_helper.rb +2 -0
  50. data/app/helpers/admin/base_helper.rb +194 -0
  51. data/app/helpers/admin/inventory_settings_helper.rb +5 -0
  52. data/app/helpers/admin/navigation_helper.rb +162 -0
  53. data/app/helpers/admin/orders_helper.rb +22 -0
  54. data/app/helpers/admin/overview_helper.rb +12 -0
  55. data/app/helpers/admin/payments_helper.rb +7 -0
  56. data/app/helpers/admin/product_groups_helper.rb +11 -0
  57. data/app/helpers/admin/product_properties_helper.rb +21 -0
  58. data/app/helpers/admin/products_helper.rb +11 -0
  59. data/app/helpers/admin/taxons_helper.rb +18 -0
  60. data/app/helpers/admin/users_helper.rb +8 -0
  61. data/app/helpers/admin/zones_helper.rb +11 -0
  62. data/app/helpers/checkout_helper.rb +31 -0
  63. data/app/helpers/hook_helper.rb +20 -0
  64. data/app/helpers/orders_helper.rb +3 -0
  65. data/app/helpers/products_helper.rb +30 -0
  66. data/app/helpers/search_helper.rb +10 -0
  67. data/app/helpers/spree/base_helper.rb +119 -0
  68. data/app/helpers/taxons_helper.rb +32 -0
  69. data/app/helpers/trackers_helper.rb +2 -0
  70. data/app/mailers/order_mailer.rb +19 -0
  71. data/app/mailers/shipment_mailer.rb +11 -0
  72. data/app/models/address.rb +115 -0
  73. data/app/models/adjustment.rb +47 -0
  74. data/app/models/app_configuration.rb +44 -0
  75. data/app/models/asset.rb +4 -0
  76. data/app/models/billing_integration.rb +23 -0
  77. data/app/models/calculator.rb +46 -0
  78. data/app/models/calculator/flat_percent_item_total.rb +19 -0
  79. data/app/models/calculator/flat_rate.rb +16 -0
  80. data/app/models/calculator/flexi_rate.rb +32 -0
  81. data/app/models/calculator/per_item.rb +16 -0
  82. data/app/models/calculator/price_bucket.rb +30 -0
  83. data/app/models/calculator/sales_tax.rb +48 -0
  84. data/app/models/calculator/vat.rb +63 -0
  85. data/app/models/configuration.rb +3 -0
  86. data/app/models/country.rb +16 -0
  87. data/app/models/creditcard.rb +267 -0
  88. data/app/models/gateway.rb +48 -0
  89. data/app/models/gateway/authorize_net.rb +19 -0
  90. data/app/models/gateway/authorize_net_cim.rb +132 -0
  91. data/app/models/gateway/beanstream.rb +187 -0
  92. data/app/models/gateway/bogus.rb +80 -0
  93. data/app/models/gateway/braintree.rb +88 -0
  94. data/app/models/gateway/eway.rb +11 -0
  95. data/app/models/gateway/linkpoint.rb +8 -0
  96. data/app/models/gateway/pay_pal.rb +11 -0
  97. data/app/models/gateway/sage_pay.rb +9 -0
  98. data/app/models/image.rb +31 -0
  99. data/app/models/inventory_unit.rb +119 -0
  100. data/app/models/line_item.rb +95 -0
  101. data/app/models/log_entry.rb +3 -0
  102. data/app/models/mail_method.rb +23 -0
  103. data/app/models/option_type.rb +9 -0
  104. data/app/models/option_value.rb +5 -0
  105. data/app/models/order.rb +484 -0
  106. data/app/models/payment.rb +119 -0
  107. data/app/models/payment_method.rb +56 -0
  108. data/app/models/payment_method/check.rb +27 -0
  109. data/app/models/preference.rb +51 -0
  110. data/app/models/product.rb +258 -0
  111. data/app/models/product_group.rb +216 -0
  112. data/app/models/product_option_type.rb +5 -0
  113. data/app/models/product_property.rb +15 -0
  114. data/app/models/product_scope.rb +78 -0
  115. data/app/models/property.rb +18 -0
  116. data/app/models/prototype.rb +5 -0
  117. data/app/models/return_authorization.rb +79 -0
  118. data/app/models/role.rb +3 -0
  119. data/app/models/shipment.rb +157 -0
  120. data/app/models/shipping_category.rb +3 -0
  121. data/app/models/shipping_method.rb +25 -0
  122. data/app/models/spree/alert.rb +13 -0
  123. data/app/models/state.rb +16 -0
  124. data/app/models/state_event.rb +16 -0
  125. data/app/models/tax_category.rb +15 -0
  126. data/app/models/tax_rate.rb +16 -0
  127. data/app/models/taxon.rb +52 -0
  128. data/app/models/taxonomy.rb +20 -0
  129. data/app/models/taxonomy.rb~ +22 -0
  130. data/app/models/tracker.rb +5 -0
  131. data/app/models/user.rb +21 -0
  132. data/app/models/variant.rb +104 -0
  133. data/app/models/zone.rb +84 -0
  134. data/app/models/zone_member.rb +10 -0
  135. data/app/stylesheets/_buttons.less +80 -0
  136. data/app/stylesheets/_cart.less +24 -0
  137. data/app/stylesheets/_checkout.less +76 -0
  138. data/app/stylesheets/_checkout_progress.less +62 -0
  139. data/app/stylesheets/_colors.less +16 -0
  140. data/app/stylesheets/_forms.less +50 -0
  141. data/app/stylesheets/_layout.less +77 -0
  142. data/app/stylesheets/_messages.less +32 -0
  143. data/app/stylesheets/_mixins.less +71 -0
  144. data/app/stylesheets/_navigation.less +130 -0
  145. data/app/stylesheets/_prices.less +18 -0
  146. data/app/stylesheets/_product_details.less +56 -0
  147. data/app/stylesheets/_product_lists.less +66 -0
  148. data/app/stylesheets/_registration.less +24 -0
  149. data/app/stylesheets/_reset.less +69 -0
  150. data/app/stylesheets/_typography.less +158 -0
  151. data/app/stylesheets/screen.less +13 -0
  152. data/app/views/admin/adjustments/_adjustments_table.html.erb +24 -0
  153. data/app/views/admin/adjustments/_form.html.erb +12 -0
  154. data/app/views/admin/adjustments/edit.html.erb +13 -0
  155. data/app/views/admin/adjustments/index.html.erb +4 -0
  156. data/app/views/admin/adjustments/new.html.erb +14 -0
  157. data/app/views/admin/configurations/index.html.erb +66 -0
  158. data/app/views/admin/extensions/index.html.erb +23 -0
  159. data/app/views/admin/general_settings/edit.html.erb +46 -0
  160. data/app/views/admin/general_settings/show.html.erb +36 -0
  161. data/app/views/admin/images/_form.html.erb +16 -0
  162. data/app/views/admin/images/edit.html.erb +19 -0
  163. data/app/views/admin/images/index.html.erb +69 -0
  164. data/app/views/admin/images/new.html.erb +22 -0
  165. data/app/views/admin/images/new.html.erb~ +22 -0
  166. data/app/views/admin/inventory_settings/edit.html.erb +27 -0
  167. data/app/views/admin/inventory_settings/show.html.erb +9 -0
  168. data/app/views/admin/inventory_units/adjust.html.erb +33 -0
  169. data/app/views/admin/mail_methods/_form.html.erb +96 -0
  170. data/app/views/admin/mail_methods/edit.html.erb +9 -0
  171. data/app/views/admin/mail_methods/index.html.erb +41 -0
  172. data/app/views/admin/mail_methods/new.html.erb +9 -0
  173. data/app/views/admin/option_types/_available.html.erb +27 -0
  174. data/app/views/admin/option_types/_form.html.erb +11 -0
  175. data/app/views/admin/option_types/_option_value_fields.html.erb +5 -0
  176. data/app/views/admin/option_types/_selected.html.erb +26 -0
  177. data/app/views/admin/option_types/available.js.erb +2 -0
  178. data/app/views/admin/option_types/edit.html.erb +32 -0
  179. data/app/views/admin/option_types/index.html.erb +33 -0
  180. data/app/views/admin/option_types/new.erb +11 -0
  181. data/app/views/admin/option_types/select.js.erb +3 -0
  182. data/app/views/admin/option_types/selected.html.erb +6 -0
  183. data/app/views/admin/orders/_add_product.html.erb +20 -0
  184. data/app/views/admin/orders/_form.html.erb +67 -0
  185. data/app/views/admin/orders/_line_item.html.erb +17 -0
  186. data/app/views/admin/orders/_user_form.html.erb +42 -0
  187. data/app/views/admin/orders/edit.html.erb +31 -0
  188. data/app/views/admin/orders/history.html.erb +29 -0
  189. data/app/views/admin/orders/index.html.erb +103 -0
  190. data/app/views/admin/orders/new.html.erb +20 -0
  191. data/app/views/admin/orders/show.html.erb +28 -0
  192. data/app/views/admin/orders/user.html.erb +24 -0
  193. data/app/views/admin/payment_methods/_form.html.erb +50 -0
  194. data/app/views/admin/payment_methods/edit.html.erb +10 -0
  195. data/app/views/admin/payment_methods/index.html.erb +49 -0
  196. data/app/views/admin/payment_methods/new.html.erb +11 -0
  197. data/app/views/admin/payments/_bill_address_form.html.erb +9 -0
  198. data/app/views/admin/payments/_form.html.erb +15 -0
  199. data/app/views/admin/payments/_list.html.erb +22 -0
  200. data/app/views/admin/payments/_transaction_list.html.erb +24 -0
  201. data/app/views/admin/payments/credit.html.erb +14 -0
  202. data/app/views/admin/payments/index.html.erb +22 -0
  203. data/app/views/admin/payments/new.html.erb +19 -0
  204. data/app/views/admin/payments/show.html.erb +10 -0
  205. data/app/views/admin/payments/source_forms/_check.html.erb +0 -0
  206. data/app/views/admin/payments/source_forms/_gateway.html.erb +43 -0
  207. data/app/views/admin/payments/source_views/_check.html.erb +0 -0
  208. data/app/views/admin/payments/source_views/_gateway.html.erb +34 -0
  209. data/app/views/admin/product_groups/_preview.html.erb +34 -0
  210. data/app/views/admin/product_groups/_product_scope.html.erb +24 -0
  211. data/app/views/admin/product_groups/edit.html.erb +56 -0
  212. data/app/views/admin/product_groups/index.html.erb +37 -0
  213. data/app/views/admin/product_groups/new.html.erb +12 -0
  214. data/app/views/admin/product_groups/show.html.erb +32 -0
  215. data/app/views/admin/product_groups/update.js.erb +8 -0
  216. data/app/views/admin/product_properties/_product_property_fields.html.erb +11 -0
  217. data/app/views/admin/product_properties/index.html.erb +55 -0
  218. data/app/views/admin/product_scopes/_form.html.erb +106 -0
  219. data/app/views/admin/product_scopes/create.js.erb +3 -0
  220. data/app/views/admin/product_scopes/destroy.js.erb +3 -0
  221. data/app/views/admin/product_scopes/new.html.erb +1 -0
  222. data/app/views/admin/products/_form.html.erb +112 -0
  223. data/app/views/admin/products/_option_types.html.erb +40 -0
  224. data/app/views/admin/products/_properties_form.erb +7 -0
  225. data/app/views/admin/products/edit.html.erb +10 -0
  226. data/app/views/admin/products/edit.html.erb~ +10 -0
  227. data/app/views/admin/products/index.html.erb +81 -0
  228. data/app/views/admin/products/index.html.erb~ +81 -0
  229. data/app/views/admin/products/new.erb +58 -0
  230. data/app/views/admin/products/new.erb~ +53 -0
  231. data/app/views/admin/products/show.html.erb +4 -0
  232. data/app/views/admin/products/show.html.erb~ +4 -0
  233. data/app/views/admin/properties/_form.html.erb +12 -0
  234. data/app/views/admin/properties/edit.html.erb +10 -0
  235. data/app/views/admin/properties/filtered.html.erb +1 -0
  236. data/app/views/admin/properties/index.html.erb +40 -0
  237. data/app/views/admin/properties/new.erb +11 -0
  238. data/app/views/admin/prototypes/_form.html.erb +44 -0
  239. data/app/views/admin/prototypes/available.html.erb +22 -0
  240. data/app/views/admin/prototypes/edit.html.erb +9 -0
  241. data/app/views/admin/prototypes/index.html.erb +37 -0
  242. data/app/views/admin/prototypes/new.erb +11 -0
  243. data/app/views/admin/prototypes/select.js.erb +4 -0
  244. data/app/views/admin/reports/index.html.erb +19 -0
  245. data/app/views/admin/reports/sales_total.html.erb +23 -0
  246. data/app/views/admin/return_authorizations/_form.html.erb +78 -0
  247. data/app/views/admin/return_authorizations/edit.html.erb +27 -0
  248. data/app/views/admin/return_authorizations/index.html.erb +45 -0
  249. data/app/views/admin/return_authorizations/new.html.erb +13 -0
  250. data/app/views/admin/shared/_additional_field.html.erb +5 -0
  251. data/app/views/admin/shared/_address.html.erb +5 -0
  252. data/app/views/admin/shared/_address_form.html.erb +79 -0
  253. data/app/views/admin/shared/_alert.html.erb +6 -0
  254. data/app/views/admin/shared/_calculator_fields.html.erb +19 -0
  255. data/app/views/admin/shared/_configuration_menu.html.erb +22 -0
  256. data/app/views/admin/shared/_destroy.js.erb +16 -0
  257. data/app/views/admin/shared/_edit_resource_links.html.erb +4 -0
  258. data/app/views/admin/shared/_group_from_products_form.html.erb +12 -0
  259. data/app/views/admin/shared/_new_adjustment_button.html.erb +8 -0
  260. data/app/views/admin/shared/_new_resource_links.html.erb +4 -0
  261. data/app/views/admin/shared/_order_details.html.erb +3 -0
  262. data/app/views/admin/shared/_order_sub_menu.html.erb +0 -0
  263. data/app/views/admin/shared/_order_tabs.html.erb +64 -0
  264. data/app/views/admin/shared/_product_sub_menu.html.erb +11 -0
  265. data/app/views/admin/shared/_product_tabs.html.erb +34 -0
  266. data/app/views/admin/shared/_report_criteria.html.erb +15 -0
  267. data/app/views/admin/shared/_show_resource_links.html.erb +5 -0
  268. data/app/views/admin/shared/_tabs.html.erb +6 -0
  269. data/app/views/admin/shared/_update_order_state.js +6 -0
  270. data/app/views/admin/shipments/_form.html.erb +77 -0
  271. data/app/views/admin/shipments/edit.html.erb +40 -0
  272. data/app/views/admin/shipments/index.html.erb +47 -0
  273. data/app/views/admin/shipments/new.html.erb +18 -0
  274. data/app/views/admin/shipping_categories/_form.html.erb +6 -0
  275. data/app/views/admin/shipping_categories/edit.html.erb +6 -0
  276. data/app/views/admin/shipping_categories/index.html.erb +29 -0
  277. data/app/views/admin/shipping_categories/new.html.erb +8 -0
  278. data/app/views/admin/shipping_methods/_form.html.erb +26 -0
  279. data/app/views/admin/shipping_methods/edit.html.erb +16 -0
  280. data/app/views/admin/shipping_methods/index.html.erb +49 -0
  281. data/app/views/admin/shipping_methods/new.html.erb +17 -0
  282. data/app/views/admin/states/_form.html.erb +9 -0
  283. data/app/views/admin/states/_state_list.html.erb +34 -0
  284. data/app/views/admin/states/edit.html.erb +10 -0
  285. data/app/views/admin/states/index.html.erb +16 -0
  286. data/app/views/admin/states/new.erb +8 -0
  287. data/app/views/admin/tax_categories/_form.html.erb +12 -0
  288. data/app/views/admin/tax_categories/edit.html.erb +10 -0
  289. data/app/views/admin/tax_categories/index.html.erb +44 -0
  290. data/app/views/admin/tax_categories/new.html.erb +10 -0
  291. data/app/views/admin/tax_categories/show.html.erb +1 -0
  292. data/app/views/admin/tax_rates/_form.html.erb +16 -0
  293. data/app/views/admin/tax_rates/edit.html.erb +6 -0
  294. data/app/views/admin/tax_rates/index.html.erb +34 -0
  295. data/app/views/admin/tax_rates/new.html.erb +8 -0
  296. data/app/views/admin/tax_settings/edit.html.erb +17 -0
  297. data/app/views/admin/tax_settings/show.html.erb +14 -0
  298. data/app/views/admin/taxonomies/_form.html.erb +10 -0
  299. data/app/views/admin/taxonomies/_form.html.erb~ +11 -0
  300. data/app/views/admin/taxonomies/_js_head.html.erb +9 -0
  301. data/app/views/admin/taxonomies/_list.html.erb +19 -0
  302. data/app/views/admin/taxonomies/_list.html.erb~ +20 -0
  303. data/app/views/admin/taxonomies/_taxon.html.erb +12 -0
  304. data/app/views/admin/taxonomies/edit.erb +49 -0
  305. data/app/views/admin/taxonomies/get_children.json.erb +9 -0
  306. data/app/views/admin/taxonomies/index.html.erb +16 -0
  307. data/app/views/admin/taxonomies/new.html.erb +12 -0
  308. data/app/views/admin/taxons/_form.html.erb +23 -0
  309. data/app/views/admin/taxons/_taxon_table.html.erb +23 -0
  310. data/app/views/admin/taxons/available.js.erb +33 -0
  311. data/app/views/admin/taxons/edit.html.erb +11 -0
  312. data/app/views/admin/taxons/remove.html.erb +1 -0
  313. data/app/views/admin/taxons/select.js.erb +2 -0
  314. data/app/views/admin/taxons/selected.html.erb +43 -0
  315. data/app/views/admin/trackers/_form.html.erb +26 -0
  316. data/app/views/admin/trackers/edit.html.erb +8 -0
  317. data/app/views/admin/trackers/index.html.erb +41 -0
  318. data/app/views/admin/trackers/new.html.erb +9 -0
  319. data/app/views/admin/users/_form.html.erb +35 -0
  320. data/app/views/admin/users/edit.html.erb +14 -0
  321. data/app/views/admin/users/index.html.erb +63 -0
  322. data/app/views/admin/users/new.html.erb +14 -0
  323. data/app/views/admin/users/show.html.erb +21 -0
  324. data/app/views/admin/variants/_form.html.erb +40 -0
  325. data/app/views/admin/variants/edit.html.erb +13 -0
  326. data/app/views/admin/variants/index.html.erb +66 -0
  327. data/app/views/admin/variants/new.erb +11 -0
  328. data/app/views/admin/zones/_country_member.html.erb +5 -0
  329. data/app/views/admin/zones/_form.html.erb +29 -0
  330. data/app/views/admin/zones/_member_type.html.erb +15 -0
  331. data/app/views/admin/zones/_state_member.html.erb +5 -0
  332. data/app/views/admin/zones/_zone_member.html.erb +5 -0
  333. data/app/views/admin/zones/edit.html.erb +10 -0
  334. data/app/views/admin/zones/index.html.erb +41 -0
  335. data/app/views/admin/zones/new.html.erb +10 -0
  336. data/app/views/checkout/_address.html.erb +163 -0
  337. data/app/views/checkout/_confirm.html.erb +11 -0
  338. data/app/views/checkout/_delivery.html.erb +25 -0
  339. data/app/views/checkout/_payment.html.erb +30 -0
  340. data/app/views/checkout/_summary.html.erb +21 -0
  341. data/app/views/checkout/edit.html.erb +20 -0
  342. data/app/views/checkout/payment/_check.html.erb +0 -0
  343. data/app/views/checkout/payment/_gateway.html.erb +31 -0
  344. data/app/views/checkout/registration.html.erb +20 -0
  345. data/app/views/content/cvv.html.erb +13 -0
  346. data/app/views/layouts/admin.html.erb +75 -0
  347. data/app/views/layouts/spree_application.html.erb +52 -0
  348. data/app/views/order_mailer/cancel_email.text.erb +16 -0
  349. data/app/views/order_mailer/confirm_email.text.erb +19 -0
  350. data/app/views/orders/_form.html.erb +19 -0
  351. data/app/views/orders/_line_item.html.erb +41 -0
  352. data/app/views/orders/edit.html.erb +41 -0
  353. data/app/views/orders/new.html.erb +9 -0
  354. data/app/views/orders/show.html.erb +14 -0
  355. data/app/views/products/_cart_form.html.erb +54 -0
  356. data/app/views/products/_cart_form.html.erb~ +54 -0
  357. data/app/views/products/_image.html.erb +5 -0
  358. data/app/views/products/_image.html.erb~ +5 -0
  359. data/app/views/products/_properties.html.erb +8 -0
  360. data/app/views/products/_taxons.html.erb +16 -0
  361. data/app/views/products/_thumbnails.html.erb +40 -0
  362. data/app/views/products/index.html.erb +37 -0
  363. data/app/views/products/show.html.erb +31 -0
  364. data/app/views/shared/_additional_field.html.erb +7 -0
  365. data/app/views/shared/_admin_head.html.erb +34 -0
  366. data/app/views/shared/_basic_layout.html.erb +44 -0
  367. data/app/views/shared/_edit_resource_links.html.erb +1 -0
  368. data/app/views/shared/_end_soon.html.erb +43 -0
  369. data/app/views/shared/_error_messages.html.erb +11 -0
  370. data/app/views/shared/_filters.html.erb +27 -0
  371. data/app/views/shared/_footer.html.erb +13 -0
  372. data/app/views/shared/_google_analytics.html.erb +40 -0
  373. data/app/views/shared/_head.html.erb +10 -0
  374. data/app/views/shared/_method_error_message.html.erb +4 -0
  375. data/app/views/shared/_nav_bar.html.erb +5 -0
  376. data/app/views/shared/_new_release.html.erb +42 -0
  377. data/app/views/shared/_new_resource_links.html.erb +1 -0
  378. data/app/views/shared/_order_details.html.erb +50 -0
  379. data/app/views/shared/_products.html.erb +42 -0
  380. data/app/views/shared/_search.html.erb +9 -0
  381. data/app/views/shared/_show_resource_links.html.erb +3 -0
  382. data/app/views/shared/_store_menu.html.erb +3 -0
  383. data/app/views/shared/_taxonomies.html.erb +19 -0
  384. data/app/views/shared/_test_hook.html.erb +1 -0
  385. data/app/views/shared/_upcoming_products.html.erb +42 -0
  386. data/app/views/shipment_mailer/shipped_email.text.erb +15 -0
  387. data/app/views/states/index.js.erb +1 -0
  388. data/app/views/taxons/_taxon.html.erb +4 -0
  389. data/app/views/taxons/show.html.erb +19 -0
  390. data/config/:cart +0 -0
  391. data/config/:checkout +0 -0
  392. data/config/:checkout_state +0 -0
  393. data/config/:collection +0 -0
  394. data/config/:empty_cart +0 -0
  395. data/config/:get, +0 -0
  396. data/config/:index +0 -0
  397. data/config/:nested_taxons +0 -0
  398. data/config/:pg_search +0 -0
  399. data/config/:put, +0 -0
  400. data/config/:simple_search +0 -0
  401. data/config/:taxons_pg_search +0 -0
  402. data/config/:taxons_search +0 -0
  403. data/config/:update_cart +0 -0
  404. data/config/:update_checkout +0 -0
  405. data/config/[:index, +0 -0
  406. data/config/address, +0 -0
  407. data/config/checkout#edit, +0 -0
  408. data/config/checkout#update, +0 -0
  409. data/config/content#cvv +0 -0
  410. data/config/content#show +0 -0
  411. data/config/cucumber.yml +10 -0
  412. data/config/initializers/form_builder.rb +19 -0
  413. data/config/initializers/load_unobtrusive_date_picker.rb +8 -0
  414. data/config/initializers/spree.rb +29 -0
  415. data/config/initializers/workarounds_for_ruby19.rb +72 -0
  416. data/config/locale#set +0 -0
  417. data/config/locales/en.yml +1015 -0
  418. data/config/orders#edit, +0 -0
  419. data/config/orders#empty, +0 -0
  420. data/config/orders#update, +0 -0
  421. data/config/products#index +0 -0
  422. data/config/products#index, +0 -0
  423. data/config/routes.rb +207 -0
  424. data/config/taxons#show, +0 -0
  425. data/db/default/countries.yml +1583 -0
  426. data/db/default/roles.yml +7 -0
  427. data/db/default/states.yml +256 -0
  428. data/db/default/zone_members.yml +169 -0
  429. data/db/default/zones.yml +13 -0
  430. data/db/migrate/20090823005402_spree_zero_nine_zero.rb +442 -0
  431. data/db/migrate/20090904192342_create_indexes_for_inventory_units.rb +12 -0
  432. data/db/migrate/20090923100315_add_count_on_hand_to_variants_and_products.rb +36 -0
  433. data/db/migrate/20091007134354_change_taxons_to_nested_set.rb +40 -0
  434. data/db/migrate/20091008091614_move_to_configurable_gateways.rb +55 -0
  435. data/db/migrate/20091012120519_product_groups_and_scopes.rb +25 -0
  436. data/db/migrate/20091015110842_add_open_id_authentication_tables.rb +20 -0
  437. data/db/migrate/20091015153048_add_openid_field_to_users.rb +19 -0
  438. data/db/migrate/20091016174634_change_preference_value_type.rb +10 -0
  439. data/db/migrate/20091017175558_create_billing_integrations.rb +16 -0
  440. data/db/migrate/20091021133257_charge_refactoring.rb +35 -0
  441. data/db/migrate/20091104151730_add_some_indexes.rb +21 -0
  442. data/db/migrate/20091126190904_checkout_state_machine.rb +13 -0
  443. data/db/migrate/20091209153045_state_for_shipments.rb +9 -0
  444. data/db/migrate/20091209202200_make_state_events_polymorphic.rb +12 -0
  445. data/db/migrate/20091211203813_ship_address_id_for_checkouts.rb +9 -0
  446. data/db/migrate/20091212161118_shipping_method_id_for_checkouts.rb +9 -0
  447. data/db/migrate/20091213222815_creditcard_last_four_digits.rb +19 -0
  448. data/db/migrate/20091214183826_populate_legacy_shipment_state.rb +19 -0
  449. data/db/migrate/20100105090147_add_cost_price.rb +9 -0
  450. data/db/migrate/20100105132138_shipment_id_for_inventory_units.rb +21 -0
  451. data/db/migrate/20100111205525_cim_fields_for_creditcards.rb +11 -0
  452. data/db/migrate/20100112151511_create_return_authorizations.rb +16 -0
  453. data/db/migrate/20100113090919_add_return_authorization_to_inventory_units.rb +9 -0
  454. data/db/migrate/20100113203104_create_trackers.rb +14 -0
  455. data/db/migrate/20100121160010_creditcard_id_for_creditcard_txns.rb +9 -0
  456. data/db/migrate/20100121183934_original_creditcard_txn_id_for_creditcard_txns.rb +9 -0
  457. data/db/migrate/20100125145351_add_test_mode_to_billing_integration.rb +11 -0
  458. data/db/migrate/20100126103714_create_products_product_groups.rb +12 -0
  459. data/db/migrate/20100209025806_create_payment_methods.rb +20 -0
  460. data/db/migrate/20100209144531_polymorphic_payments.rb +29 -0
  461. data/db/migrate/20100213103131_change_payments_payment_method_to_belongs_to.rb +11 -0
  462. data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +16 -0
  463. data/db/migrate/20100223170312_sti_for_transactions.rb +14 -0
  464. data/db/migrate/20100223183812_drop_billing_integrations.rb +16 -0
  465. data/db/migrate/20100224153127_deleted_at_for_payment_methods.rb +13 -0
  466. data/db/migrate/20100301163454_add_adjustments_index.rb +10 -0
  467. data/db/migrate/20100306153445_fix_by_popularity.rb +8 -0
  468. data/db/migrate/20100317120946_add_alt_text_to_images.rb +9 -0
  469. data/db/migrate/20100427121301_add_display_to_payment_methods.rb +9 -0
  470. data/db/migrate/20100504142133_add_addresses_checkouts_indexes.rb +16 -0
  471. data/db/migrate/20100506180619_add_icon_to_taxons.rb +18 -0
  472. data/db/migrate/20100506185838_add_description_to_taxons.rb +11 -0
  473. data/db/migrate/20100528155333_index_for_shipments_number.rb +9 -0
  474. data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +9 -0
  475. data/db/migrate/20100605152042_add_default_to_tax_categories.rb +9 -0
  476. data/db/migrate/20100624110730_add_display_to_shipping_methods.rb +9 -0
  477. data/db/migrate/20100624123336_rename_payment_method_display.rb +9 -0
  478. data/db/migrate/20100624175547_rename_preferences_field.rb +8 -0
  479. data/db/migrate/20100811163637_add_guest_flag.rb +13 -0
  480. data/db/migrate/20100811205836_drop_order_token.rb +11 -0
  481. data/db/migrate/20100812162326_payments_state_and_assigned_to_order_only.rb +11 -0
  482. data/db/migrate/20100813023502_create_address_keys_for_order.rb +15 -0
  483. data/db/migrate/20100813185745_payment_total_for_orders.rb +9 -0
  484. data/db/migrate/20100816212146_shipping_method_id_for_orders.rb +9 -0
  485. data/db/migrate/20100817152723_add_shipment_and_payment_state.rb +15 -0
  486. data/db/migrate/20100819170125_refactor_adjustments.rb +19 -0
  487. data/db/migrate/20100820135707_response_code_and_avs_response_for_payments.rb +11 -0
  488. data/db/migrate/20100901171814_change_guest_flag_to_anonymous.rb +13 -0
  489. data/db/migrate/20100903203949_email_for_orders.rb +9 -0
  490. data/db/migrate/20100923162011_create_mail_methods.rb +12 -0
  491. data/db/migrate/20100929151905_rename_frozen_to_locked.rb +8 -0
  492. data/db/migrate/20101008190536_move_special_instructions_to_orders.rb +11 -0
  493. data/db/migrate/20101026184700_create_log_entries.rb +15 -0
  494. data/db/migrate/20101026184714_migrate_transactions_to_payment_state.rb +94 -0
  495. data/db/migrate/20101026184746_delete_in_progress_orders.rb +18 -0
  496. data/db/migrate/20101026184808_migrate_checkout_to_orders.rb +27 -0
  497. data/db/migrate/20101026184833_migrate_adjustments.rb +9 -0
  498. data/db/migrate/20101026184855_remove_shipped_state.rb +14 -0
  499. data/db/migrate/20101026184916_prevent_nil_payment_total.rb +8 -0
  500. data/db/migrate/20101026184932_prevent_nil_email.rb +9 -0
  501. data/db/migrate/20101026184959_generate_anonymous_users.rb +14 -0
  502. data/db/migrate/20101026185022_update_order_state.rb +8 -0
  503. data/db/migrate/20101026192225_cleanup_legacy_tables.rb +11 -0
  504. data/db/migrate/20101028151745_remove_number_and_cvv_from_credicard.rb +9 -0
  505. data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +8 -0
  506. data/db/migrate/20101111133551_renamed_rma_cancelled_state.rb +10 -0
  507. data/db/migrate/20101117031806_fix_problematic_index_names.rb +13 -0
  508. data/db/migrate/20101223215658_add_position_to_variants.rb +9 -0
  509. data/db/migrate/20110110130847_add_next_state_to_state_events.rb +9 -0
  510. data/db/migrate/20110111122537_add_position_to_option_types.rb +9 -0
  511. data/db/migrate/20110314192118_remove_trailing_slashes_in_taxon_permalinks.rb +17 -0
  512. data/db/sample/users.rb +61 -0
  513. data/db/seeds.rb +3 -0
  514. data/lib/apispree_core.rb +94 -0
  515. data/lib/custom_fixtures.rb +7 -0
  516. data/lib/generators/spree_core/upgrade_generator.rb +23 -0
  517. data/lib/generators/templates/config/initializers/%file_name%.rb.tt +1 -0
  518. data/lib/generators/templates/config/locales/%current_locale%.yml.tt +2 -0
  519. data/lib/generators/templates/config/routes.rb +3 -0
  520. data/lib/middleware/seo_assist.rb +44 -0
  521. data/lib/product_filters.rb +179 -0
  522. data/lib/redirect_legacy_product_url.rb +13 -0
  523. data/lib/scopes.rb +69 -0
  524. data/lib/scopes/dynamic.rb +31 -0
  525. data/lib/scopes/product.rb +266 -0
  526. data/lib/scopes/variant.rb +18 -0
  527. data/lib/spree/calculated_adjustments.rb +69 -0
  528. data/lib/spree/config.rb +33 -0
  529. data/lib/spree/current_order.rb +30 -0
  530. data/lib/spree/file_utilz.rb +73 -0
  531. data/lib/spree/gateway_error.rb +3 -0
  532. data/lib/spree/mail_interceptor.rb +23 -0
  533. data/lib/spree/mail_settings.rb +33 -0
  534. data/lib/spree/preference_access.rb +27 -0
  535. data/lib/spree/search/base.rb +64 -0
  536. data/lib/spree_base.rb +116 -0
  537. data/lib/spree_core/action_callbacks.rb +26 -0
  538. data/lib/spree_core/authorize_net_cim_hack.rb +871 -0
  539. data/lib/spree_core/delegate_belongs_to.rb +89 -0
  540. data/lib/spree_core/enumerable_constants.rb +209 -0
  541. data/lib/spree_core/ext/active_record.rb +15 -0
  542. data/lib/spree_core/ext/array.rb +14 -0
  543. data/lib/spree_core/ext/hash.rb +75 -0
  544. data/lib/spree_core/ext/string.rb +10 -0
  545. data/lib/spree_core/preferences/model_hooks.rb +293 -0
  546. data/lib/spree_core/preferences/preference_definition.rb +53 -0
  547. data/lib/spree_core/railtie.rb +63 -0
  548. data/lib/spree_core/spree_custom_responder.rb +29 -0
  549. data/lib/spree_core/spree_respond_with.rb +57 -0
  550. data/lib/spree_core/ssl_requirement.rb +104 -0
  551. data/lib/spree_core/testing_support/factories.rb +13 -0
  552. data/lib/spree_core/testing_support/factories/address_factory.rb +20 -0
  553. data/lib/spree_core/testing_support/factories/adjustment_factory.rb +6 -0
  554. data/lib/spree_core/testing_support/factories/calculator_factory.rb +5 -0
  555. data/lib/spree_core/testing_support/factories/configuraion_factory.rb +4 -0
  556. data/lib/spree_core/testing_support/factories/country_factory.rb +7 -0
  557. data/lib/spree_core/testing_support/factories/creditcard_factory.rb +11 -0
  558. data/lib/spree_core/testing_support/factories/inventory_unit_factory.rb +7 -0
  559. data/lib/spree_core/testing_support/factories/line_item_factory.rb +8 -0
  560. data/lib/spree_core/testing_support/factories/mail_method_factory.rb +4 -0
  561. data/lib/spree_core/testing_support/factories/options_factory.rb +10 -0
  562. data/lib/spree_core/testing_support/factories/order_factory.rb +18 -0
  563. data/lib/spree_core/testing_support/factories/payment_factory.rb +26 -0
  564. data/lib/spree_core/testing_support/factories/payment_method_factory.rb +17 -0
  565. data/lib/spree_core/testing_support/factories/product_factory.rb +16 -0
  566. data/lib/spree_core/testing_support/factories/product_group_factory.rb +3 -0
  567. data/lib/spree_core/testing_support/factories/product_option_type_factory.rb +4 -0
  568. data/lib/spree_core/testing_support/factories/product_property_factory.rb +4 -0
  569. data/lib/spree_core/testing_support/factories/product_scope_factory.rb +6 -0
  570. data/lib/spree_core/testing_support/factories/property_factory.rb +4 -0
  571. data/lib/spree_core/testing_support/factories/prototype_factory.rb +4 -0
  572. data/lib/spree_core/testing_support/factories/return_authorization_factory.rb +8 -0
  573. data/lib/spree_core/testing_support/factories/role_factory.rb +9 -0
  574. data/lib/spree_core/testing_support/factories/shipment_factory.rb +9 -0
  575. data/lib/spree_core/testing_support/factories/shipping_category_factory.rb +5 -0
  576. data/lib/spree_core/testing_support/factories/shipping_method_factory.rb +11 -0
  577. data/lib/spree_core/testing_support/factories/state_factory.rb +11 -0
  578. data/lib/spree_core/testing_support/factories/tax_category_factory.rb +8 -0
  579. data/lib/spree_core/testing_support/factories/tax_rate_factory.rb +5 -0
  580. data/lib/spree_core/testing_support/factories/taxon_factory.rb +5 -0
  581. data/lib/spree_core/testing_support/factories/taxonomy_factory.rb +3 -0
  582. data/lib/spree_core/testing_support/factories/tracker_factory.rb +5 -0
  583. data/lib/spree_core/testing_support/factories/user_factory.rb +15 -0
  584. data/lib/spree_core/testing_support/factories/variant_factory.rb +14 -0
  585. data/lib/spree_core/testing_support/factories/zone_factory.rb +18 -0
  586. data/lib/spree_core/theme_support.rb +4 -0
  587. data/lib/spree_core/theme_support/hook.rb +51 -0
  588. data/lib/spree_core/theme_support/hook_listener.rb +68 -0
  589. data/lib/spree_core/theme_support/hook_modifier.rb +35 -0
  590. data/lib/spree_core/theme_support/more_patches.rb +118 -0
  591. data/lib/spree_core/version.rb +5 -0
  592. data/lib/store_helpers.rb +10 -0
  593. data/lib/tasks/common.rb +30 -0
  594. data/lib/tasks/core.rake +105 -0
  595. data/lib/tasks/install.rake +26 -0
  596. data/lib/tasks/rake_util.rb +19 -0
  597. data/lib/tasks/taxon.rake +14 -0
  598. data/lib/tasks/themes.rake +34 -0
  599. data/public/images/add-to-cart.png +0 -0
  600. data/public/images/admin/bg/active-tab.png +0 -0
  601. data/public/images/admin/bg/admin_tab_back.png +0 -0
  602. data/public/images/admin/bg/admin_tab_selected_back.png +0 -0
  603. data/public/images/admin/bg/content-back-blue.png +0 -0
  604. data/public/images/admin/bg/content-back-green.png +0 -0
  605. data/public/images/admin/bg/content-back.png +0 -0
  606. data/public/images/admin/bg/flash-error.png +0 -0
  607. data/public/images/admin/bg/flash-notice.png +0 -0
  608. data/public/images/admin/bg/green-stripes.gif +0 -0
  609. data/public/images/admin/bg/green-stripes.png +0 -0
  610. data/public/images/admin/bg/grid_header_back.png +0 -0
  611. data/public/images/admin/bg/grid_header_back_green.png +0 -0
  612. data/public/images/admin/bg/header-bg.png +0 -0
  613. data/public/images/admin/bg/header.png +0 -0
  614. data/public/images/admin/bg/header_bg.jpg +0 -0
  615. data/public/images/admin/bg/menu-current.png +0 -0
  616. data/public/images/admin/bg/red-stripes.gif +0 -0
  617. data/public/images/admin/bg/red-stripes.png +0 -0
  618. data/public/images/admin/bg/spree_50.png +0 -0
  619. data/public/images/admin/bg/subnav-divider.png +0 -0
  620. data/public/images/admin/bg/subnav.png +0 -0
  621. data/public/images/admin/bg/tab-back.png +0 -0
  622. data/public/images/admin/buttons/blue/left_01.png +0 -0
  623. data/public/images/admin/buttons/blue/right_01.png +0 -0
  624. data/public/images/admin/buttons/drag-handle-green.png +0 -0
  625. data/public/images/admin/buttons/green/left_01.png +0 -0
  626. data/public/images/admin/buttons/green/right_01.png +0 -0
  627. data/public/images/admin/buttons/left_01.png +0 -0
  628. data/public/images/admin/buttons/left_01_small.png +0 -0
  629. data/public/images/admin/buttons/orange/left_03.png +0 -0
  630. data/public/images/admin/buttons/orange/right_03.png +0 -0
  631. data/public/images/admin/buttons/right_01.png +0 -0
  632. data/public/images/admin/buttons/right_01_small.png +0 -0
  633. data/public/images/admin/icons/16x16/1.png +0 -0
  634. data/public/images/admin/icons/16x16/10.png +0 -0
  635. data/public/images/admin/icons/16x16/2.png +0 -0
  636. data/public/images/admin/icons/16x16/3.png +0 -0
  637. data/public/images/admin/icons/16x16/4.png +0 -0
  638. data/public/images/admin/icons/16x16/5.png +0 -0
  639. data/public/images/admin/icons/16x16/6.png +0 -0
  640. data/public/images/admin/icons/16x16/7.png +0 -0
  641. data/public/images/admin/icons/16x16/8.png +0 -0
  642. data/public/images/admin/icons/16x16/9.png +0 -0
  643. data/public/images/admin/icons/32x32/1.png +0 -0
  644. data/public/images/admin/icons/32x32/10.png +0 -0
  645. data/public/images/admin/icons/32x32/11.png +0 -0
  646. data/public/images/admin/icons/32x32/2.png +0 -0
  647. data/public/images/admin/icons/32x32/3.png +0 -0
  648. data/public/images/admin/icons/32x32/4.png +0 -0
  649. data/public/images/admin/icons/32x32/5.png +0 -0
  650. data/public/images/admin/icons/32x32/6.png +0 -0
  651. data/public/images/admin/icons/32x32/7.png +0 -0
  652. data/public/images/admin/icons/32x32/8.png +0 -0
  653. data/public/images/admin/icons/32x32/9.png +0 -0
  654. data/public/images/admin/icons/accept.png +0 -0
  655. data/public/images/admin/icons/add.gif +0 -0
  656. data/public/images/admin/icons/add.png +0 -0
  657. data/public/images/admin/icons/arrow-down.gif +0 -0
  658. data/public/images/admin/icons/cross.png +0 -0
  659. data/public/images/admin/icons/delete.gif +0 -0
  660. data/public/images/admin/icons/delete.png +0 -0
  661. data/public/images/admin/icons/drag.gif +0 -0
  662. data/public/images/admin/icons/edit.gif +0 -0
  663. data/public/images/admin/icons/edit.png +0 -0
  664. data/public/images/admin/icons/email.png +0 -0
  665. data/public/images/admin/icons/error.png +0 -0
  666. data/public/images/admin/icons/exclamation.png +0 -0
  667. data/public/images/admin/icons/feed.png +0 -0
  668. data/public/images/admin/icons/pdf.png +0 -0
  669. data/public/images/admin/icons/reorder.gif +0 -0
  670. data/public/images/admin/icons/search.gif +0 -0
  671. data/public/images/admin/icons/send-email.png +0 -0
  672. data/public/images/admin/icons/stop.png +0 -0
  673. data/public/images/admin/icons/tick.png +0 -0
  674. data/public/images/admin/icons/up.gif +0 -0
  675. data/public/images/admin/icons/xls.png +0 -0
  676. data/public/images/admin/tabs/off-left.png +0 -0
  677. data/public/images/admin/tabs/off-right.png +0 -0
  678. data/public/images/admin/tabs/on-left.png +0 -0
  679. data/public/images/admin/tabs/on-right.png +0 -0
  680. data/public/images/ajax_loader.gif +0 -0
  681. data/public/images/amex_cid.gif +0 -0
  682. data/public/images/bg-button-hover.png +0 -0
  683. data/public/images/bg-button-pressed.png +0 -0
  684. data/public/images/bg-button.gif +0 -0
  685. data/public/images/bg-button.png +0 -0
  686. data/public/images/blue/left_01.png +0 -0
  687. data/public/images/blue/right_01.png +0 -0
  688. data/public/images/body-back.png +0 -0
  689. data/public/images/bottom_shine.png +0 -0
  690. data/public/images/breadcrumb.gif +0 -0
  691. data/public/images/button-dark-hover.png +0 -0
  692. data/public/images/button-dark.png +0 -0
  693. data/public/images/buttons/bg-button-hover.png +0 -0
  694. data/public/images/buttons/bg-button-pressed.png +0 -0
  695. data/public/images/buttons/bg-button.gif +0 -0
  696. data/public/images/buttons/bg-button.png +0 -0
  697. data/public/images/buttons/blue/left_01.png +0 -0
  698. data/public/images/buttons/blue/right_01.png +0 -0
  699. data/public/images/buttons/button-dark-hover.png +0 -0
  700. data/public/images/buttons/button-dark.png +0 -0
  701. data/public/images/buttons/drag-handle-green.png +0 -0
  702. data/public/images/buttons/green/left_01.png +0 -0
  703. data/public/images/buttons/green/right_01.png +0 -0
  704. data/public/images/buttons/left_01.png +0 -0
  705. data/public/images/buttons/left_01_small.png +0 -0
  706. data/public/images/buttons/orange/left_03.png +0 -0
  707. data/public/images/buttons/orange/right_03.png +0 -0
  708. data/public/images/buttons/right_01.png +0 -0
  709. data/public/images/buttons/right_01_small.png +0 -0
  710. data/public/images/buttons/sxsw-ribbon-v1.png +0 -0
  711. data/public/images/buttons/top-shine.png +0 -0
  712. data/public/images/calendar_date_select/calendar.gif +0 -0
  713. data/public/images/cart-empty.png +0 -0
  714. data/public/images/cart-empty_x32.png +0 -0
  715. data/public/images/cart-full.png +0 -0
  716. data/public/images/cart-full_x32.png +0 -0
  717. data/public/images/checkout.png +0 -0
  718. data/public/images/creditcard.gif +0 -0
  719. data/public/images/datepicker/backstripes.gif +0 -0
  720. data/public/images/datepicker/bg_header.jpg +0 -0
  721. data/public/images/datepicker/bullet1.gif +0 -0
  722. data/public/images/datepicker/bullet2.gif +0 -0
  723. data/public/images/datepicker/cal.gif +0 -0
  724. data/public/images/datepicker/gradient-e5e5e5-ffffff.gif +0 -0
  725. data/public/images/discover_cid.gif +0 -0
  726. data/public/images/drag-handle-green.png +0 -0
  727. data/public/images/favicon.ico +0 -0
  728. data/public/images/green/left_01.png +0 -0
  729. data/public/images/green/right_01.png +0 -0
  730. data/public/images/grid.png +0 -0
  731. data/public/images/left_01.png +0 -0
  732. data/public/images/left_01_small.png +0 -0
  733. data/public/images/master_cid.jpg +0 -0
  734. data/public/images/menu-current.png +0 -0
  735. data/public/images/menu-hover.png +0 -0
  736. data/public/images/noimage/mini.jpg +0 -0
  737. data/public/images/noimage/product.jpg +0 -0
  738. data/public/images/noimage/small.jpg +0 -0
  739. data/public/images/openid-inputicon.gif +0 -0
  740. data/public/images/orange/left_03.png +0 -0
  741. data/public/images/orange/right_03.png +0 -0
  742. data/public/images/progress.gif +0 -0
  743. data/public/images/reorder.jpg +0 -0
  744. data/public/images/right_01.png +0 -0
  745. data/public/images/right_01_small.png +0 -0
  746. data/public/images/separator.png +0 -0
  747. data/public/images/shadow-top.png +0 -0
  748. data/public/images/shadow_top.png +0 -0
  749. data/public/images/spinner.gif +0 -0
  750. data/public/images/spree.jpg +0 -0
  751. data/public/images/spree/progress.gif +0 -0
  752. data/public/images/spree/spinner.gif +0 -0
  753. data/public/images/spree/spree.jpg +0 -0
  754. data/public/images/step-progress/completed-completed.gif +0 -0
  755. data/public/images/step-progress/completed-current.gif +0 -0
  756. data/public/images/step-progress/completed-first.gif +0 -0
  757. data/public/images/step-progress/current-first.gif +0 -0
  758. data/public/images/step-progress/current-incomplete.gif +0 -0
  759. data/public/images/step-progress/current-right.gif +0 -0
  760. data/public/images/step-progress/incomplete-incomplete.gif +0 -0
  761. data/public/images/step-progress/incomplete-right.gif +0 -0
  762. data/public/images/steps/1.png +0 -0
  763. data/public/images/steps/1_small.png +0 -0
  764. data/public/images/steps/2.png +0 -0
  765. data/public/images/steps/2_small.png +0 -0
  766. data/public/images/steps/3.png +0 -0
  767. data/public/images/steps/3_small.png +0 -0
  768. data/public/images/steps/4.png +0 -0
  769. data/public/images/steps/4_small.png +0 -0
  770. data/public/images/steps/5.png +0 -0
  771. data/public/images/steps/5_small.png +0 -0
  772. data/public/images/steps/6.png +0 -0
  773. data/public/images/steps/6_small.png +0 -0
  774. data/public/images/sxsw-ribbon-v1.png +0 -0
  775. data/public/images/tab_bottom.gif +0 -0
  776. data/public/images/tile-header.png +0 -0
  777. data/public/images/tile-slider.png +0 -0
  778. data/public/images/top-shine.png +0 -0
  779. data/public/images/tree-nav-icons/bullet.gif +0 -0
  780. data/public/images/tree-nav-icons/minus.gif +0 -0
  781. data/public/images/tree-nav-icons/plus.gif +0 -0
  782. data/public/images/tree-nav-icons/treeview-loading.gif +0 -0
  783. data/public/images/tree-nav-icons/treeview-sprite.gif +0 -0
  784. data/public/images/update.png +0 -0
  785. data/public/images/visa_cid.gif +0 -0
  786. data/public/images/wrapper-back-2.png +0 -0
  787. data/public/images/wrapper-back.png +0 -0
  788. data/public/images/yui-menubaritem_submenuindicator.png +0 -0
  789. data/public/images/yui-menubaritem_submenuindicator_disabled.png +0 -0
  790. data/public/images/yui-menuitem_checkbox.png +0 -0
  791. data/public/images/yui-menuitem_checkbox_disabled.png +0 -0
  792. data/public/images/yui-menuitem_submenuindicator.png +0 -0
  793. data/public/images/yui-menuitem_submenuindicator_disabled.png +0 -0
  794. data/public/images/yui-sprite.png +0 -0
  795. data/public/javascripts/additional-methods.js +236 -0
  796. data/public/javascripts/admin.js +232 -0
  797. data/public/javascripts/admin/address_states.js +25 -0
  798. data/public/javascripts/admin/checkouts/edit.js +130 -0
  799. data/public/javascripts/admin/orders/edit.js +23 -0
  800. data/public/javascripts/admin/orders/edit_form.js +16 -0
  801. data/public/javascripts/admin/payments/new.js +9 -0
  802. data/public/javascripts/admin/unobtrusive_handlers.js +43 -0
  803. data/public/javascripts/application.js +12 -0
  804. data/public/javascripts/calculator.js +15 -0
  805. data/public/javascripts/checkout.js +75 -0
  806. data/public/javascripts/datepicker.js +1445 -0
  807. data/public/javascripts/gateway.js +13 -0
  808. data/public/javascripts/jquery-1.4.2.min.js +154 -0
  809. data/public/javascripts/jquery-ui.js +188 -0
  810. data/public/javascripts/jquery.alerts/images/help.gif +0 -0
  811. data/public/javascripts/jquery.alerts/images/important.gif +0 -0
  812. data/public/javascripts/jquery.alerts/images/info.gif +0 -0
  813. data/public/javascripts/jquery.alerts/images/title.gif +0 -0
  814. data/public/javascripts/jquery.alerts/jquery.alerts.css +57 -0
  815. data/public/javascripts/jquery.alerts/jquery.alerts.js +235 -0
  816. data/public/javascripts/jquery.alerts/jquery.alerts.spree.css +30 -0
  817. data/public/javascripts/jquery.autocomplete.min.js +13 -0
  818. data/public/javascripts/jquery.cookie.js +96 -0
  819. data/public/javascripts/jquery.delayedobserver.js +35 -0
  820. data/public/javascripts/jquery.suggest.js +276 -0
  821. data/public/javascripts/jquery.template.js +255 -0
  822. data/public/javascripts/jquery.tokeninput.js +618 -0
  823. data/public/javascripts/jquery.validate.min.js +16 -0
  824. data/public/javascripts/jsTree/jquery.jstree.js +3510 -0
  825. data/public/javascripts/jsTree/themes/apple/bg.jpg +0 -0
  826. data/public/javascripts/jsTree/themes/apple/d.png +0 -0
  827. data/public/javascripts/jsTree/themes/apple/dot_for_ie.gif +0 -0
  828. data/public/javascripts/jsTree/themes/apple/style.css +60 -0
  829. data/public/javascripts/jsTree/themes/apple/throbber.gif +0 -0
  830. data/public/javascripts/lang/af.js +40 -0
  831. data/public/javascripts/lang/ar.js +50 -0
  832. data/public/javascripts/lang/de.js +40 -0
  833. data/public/javascripts/lang/du.js +40 -0
  834. data/public/javascripts/lang/en.js +42 -0
  835. data/public/javascripts/lang/es.js +41 -0
  836. data/public/javascripts/lang/fi.js +40 -0
  837. data/public/javascripts/lang/fr.js +44 -0
  838. data/public/javascripts/lang/gr.js +40 -0
  839. data/public/javascripts/lang/he.js +49 -0
  840. data/public/javascripts/lang/it.js +13 -0
  841. data/public/javascripts/lang/nl.js +40 -0
  842. data/public/javascripts/lang/no.js +40 -0
  843. data/public/javascripts/lang/pt.js +50 -0
  844. data/public/javascripts/lang/ro.js +40 -0
  845. data/public/javascripts/lang/ru.js +40 -0
  846. data/public/javascripts/lang/sp.js +40 -0
  847. data/public/javascripts/lang/sv.js +41 -0
  848. data/public/javascripts/lang/ua.js +40 -0
  849. data/public/javascripts/localization/messages_cn.js +24 -0
  850. data/public/javascripts/localization/messages_cs.js +23 -0
  851. data/public/javascripts/localization/messages_da.js +21 -0
  852. data/public/javascripts/localization/messages_de.js +21 -0
  853. data/public/javascripts/localization/messages_es.js +24 -0
  854. data/public/javascripts/localization/messages_fr.js +23 -0
  855. data/public/javascripts/localization/messages_hu.js +21 -0
  856. data/public/javascripts/localization/messages_it.js +26 -0
  857. data/public/javascripts/localization/messages_kk.js +23 -0
  858. data/public/javascripts/localization/messages_nl.js +23 -0
  859. data/public/javascripts/localization/messages_no.js +23 -0
  860. data/public/javascripts/localization/messages_pl.js +23 -0
  861. data/public/javascripts/localization/messages_ptbr.js +30 -0
  862. data/public/javascripts/localization/messages_ro.js +24 -0
  863. data/public/javascripts/localization/messages_ru.js +23 -0
  864. data/public/javascripts/localization/messages_se.js +23 -0
  865. data/public/javascripts/localization/messages_sk.js +21 -0
  866. data/public/javascripts/localization/messages_tr.js +24 -0
  867. data/public/javascripts/localization/messages_tw.js +24 -0
  868. data/public/javascripts/localization/messages_ua.js +24 -0
  869. data/public/javascripts/nested-attribute.js +26 -0
  870. data/public/javascripts/open_id.js +15 -0
  871. data/public/javascripts/product.js +49 -0
  872. data/public/javascripts/rails.js +127 -0
  873. data/public/javascripts/taxonomy.js +201 -0
  874. data/public/javascripts/zone.js +39 -0
  875. data/public/stylesheets/admin/admin-forms.css +154 -0
  876. data/public/stylesheets/admin/admin-reset.css +69 -0
  877. data/public/stylesheets/admin/admin-tables.css +39 -0
  878. data/public/stylesheets/admin/admin-typography.css +117 -0
  879. data/public/stylesheets/admin/admin.css +614 -0
  880. data/public/stylesheets/admin/autocomplete.css +73 -0
  881. data/public/stylesheets/admin/dashboard.css +143 -0
  882. data/public/stylesheets/admin/edit_checkouts.css +57 -0
  883. data/public/stylesheets/admin/grids.css +314 -0
  884. data/public/stylesheets/admin/reset-fonts-grids-2-6-0.css +7 -0
  885. data/public/stylesheets/admin/token-input.css +109 -0
  886. data/public/stylesheets/admin/yui-includes.css +14 -0
  887. data/public/stylesheets/datepicker.css +263 -0
  888. data/public/stylesheets/jquery.autocomplete.css +48 -0
  889. data/public/stylesheets/screen.css +916 -0
  890. metadata +1099 -0
@@ -0,0 +1,216 @@
1
+ # *ProductGroups* are used for creating and managing sets of products.
2
+ # Product group can be either anonymous(adhoc) or named.
3
+ #
4
+ # Anonymous Product groups are created by combining product scopes generated from url
5
+ # in 2 formats:
6
+ #
7
+ # /t/*taxons/s/name_of_scope/comma_separated_arguments/name_of_scope_that_doesn_take_any//order
8
+ # */s/name_of_scope/comma_separated_arguments/name_of_scope_that_doesn_take_any//order
9
+ #
10
+ # Named product groups can be created from anonymous ones, lub from another named scope
11
+ # (using ProductGroup.from_url method).
12
+ # Named product groups have pernament urls, that don't change even after changes
13
+ # to scopes are made, and come in two types.
14
+ #
15
+ # /t/*taxons/pg/named_product_group
16
+ # */pg/named_product_group
17
+ #
18
+ # first one is used for combining named scope with taxons, named product group can
19
+ # have #in_taxon or #taxons_name_eq scope defined, result should combine both
20
+ # and return products that exist in both taxons.
21
+ #
22
+ # ProductGroup#dynamic_products returns chain of named scopes generated from order and
23
+ # product scopes. So you can do counting, calculations etc, on resulted set of products,
24
+ # without retriving all records.
25
+ #
26
+ # ProductGroup operates on named scopes defined for product in Scopes::Product,
27
+ # or generated automatically by meta_search
28
+ #
29
+ class ProductGroup < ActiveRecord::Base
30
+ validates :name, :presence => true # TODO ensure that this field is defined as not_null
31
+ validates_associated :product_scopes
32
+
33
+ before_save :set_permalink
34
+ after_save :update_memberships
35
+
36
+ has_and_belongs_to_many :cached_products, :class_name => "Product"
37
+ # name
38
+ has_many :product_scopes
39
+ accepts_nested_attributes_for :product_scopes
40
+
41
+ # Testing utility: creates new *ProductGroup* from search permalink url.
42
+ # Follows conventions for accessing PGs from URLs, as decoded in routes
43
+ def self.from_url(url)
44
+ pg = nil;
45
+ case url
46
+ when /\/t\/(.+?)\/s\/(.+)/ then taxons = $1; attrs = $2;
47
+ when /\/t\/(.+?)\/pg\/(.+)/ then taxons = $1; pg_name = $2;
48
+ when /(.*?)\/s\/(.+)/ then attrs = $2;
49
+ when /(.*?)\/pg\/(.+)/ then pg_name = $2;
50
+ else return(nil)
51
+ end
52
+
53
+ if pg_name && opg = ProductGroup.find_by_permalink(pg_name)
54
+ pg = new.from_product_group(opg)
55
+ elsif attrs
56
+ attrs = url.split("/")
57
+ pg = new.from_route(attrs)
58
+ end
59
+ taxon = taxons && taxons.split("/").last
60
+ pg.add_scope("in_taxon", taxon) if taxon
61
+
62
+ pg
63
+ end
64
+
65
+ def from_product_group(opg)
66
+ self.product_scopes = opg.product_scopes.map{|ps|
67
+ ps = ps.clone;
68
+ ps.product_group_id = nil;
69
+ ps.product_group = self;
70
+ ps
71
+ }
72
+ self
73
+ end
74
+
75
+ def from_route(attrs)
76
+ self.order_scope = attrs.pop if attrs.length % 2 == 1
77
+ attrs.each_slice(2) do |scope|
78
+ next unless Product.respond_to?(scope.first)
79
+ add_scope(scope.first, scope.last.split(","))
80
+ end
81
+ self
82
+ end
83
+
84
+ def from_search(search_hash)
85
+ search_hash.each_pair do |scope_name, scope_attribute|
86
+ add_scope(scope_name, scope_attribute)
87
+ end
88
+
89
+ self
90
+ end
91
+
92
+ def add_scope(scope_name, arguments=[])
93
+ if scope_name.to_s !~ /eval|send|system|[^a-z0-9_!?]/
94
+ self.product_scopes << ProductScope.new({
95
+ :name => scope_name.to_s,
96
+ :arguments => [*arguments]
97
+ })
98
+ else
99
+ raise ArgumentError.new("'#{scope_name}` can't be used as scope")
100
+ end
101
+ self
102
+ end
103
+
104
+ def apply_on(scopish, use_order = true)
105
+ # There's bug in AR, it doesn't merge :order, instead it takes order
106
+ # from first nested_scope so we have to apply ordering FIRST.
107
+ # see #2253 on rails LH
108
+ base_product_scope = scopish
109
+ if use_order && !self.order_scope.blank? && Product.respond_to?(self.order_scope.intern)
110
+ base_product_scope = base_product_scope.send(self.order_scope)
111
+ end
112
+
113
+ return self.product_scopes.reject {|s| s.is_ordering? }.inject(base_product_scope) do |result, scope|
114
+ scope.apply_on(result)
115
+ end
116
+
117
+ end
118
+
119
+ # returns chain of named scopes generated from order scope and product scopes.
120
+ def dynamic_products(use_order = true)
121
+ apply_on(Product.group_by_products_id, use_order)
122
+ end
123
+
124
+ # Does the final ordering if requested
125
+ # TODO: move the order stuff out of the above - is superfluous now
126
+ def products(use_order = true)
127
+ cached_group = Product.in_cached_group(self)
128
+ if cached_group.limit(1).blank?
129
+ dynamic_products(use_order)
130
+ elsif !use_order
131
+ cached_group
132
+ else
133
+ product_scopes.select {|s|
134
+ s.is_ordering?
135
+ }.inject(cached_group) {|res,order|
136
+ order.apply_on(res)
137
+ }
138
+ end
139
+ end
140
+
141
+ def include?(product)
142
+ res = apply_on(Product.id_equals(product.id), false)
143
+ res.count > 0
144
+ end
145
+
146
+ def scopes_to_hash
147
+ result = {}
148
+ self.product_scopes.each do |scope|
149
+ result[scope.name] = scope.arguments
150
+ end
151
+ result
152
+ end
153
+
154
+ # generates ProductGroup url
155
+ def to_url
156
+ if (new_record? || name.blank?)
157
+ result = ""
158
+ result+= self.product_scopes.map{|ps|
159
+ [ps.name, ps.arguments.join(",")]
160
+ }.flatten.join('/')
161
+ result+= self.order_scope if self.order_scope
162
+
163
+ result
164
+ else
165
+ name.to_url
166
+ end
167
+ end
168
+
169
+ def set_permalink
170
+ self.permalink = self.name.to_url
171
+ end
172
+
173
+ def update_memberships
174
+ # wipe everything directly to avoid expensive in-rails sorting
175
+ ActiveRecord::Base.connection.execute "DELETE FROM product_groups_products WHERE product_group_id = #{self.id}"
176
+
177
+ # and generate the new group entirely in SQL
178
+ ActiveRecord::Base.connection.execute "INSERT INTO product_groups_products #{dynamic_products(false).scoped(:select => "products.id, #{self.id}").to_sql}"
179
+ end
180
+
181
+ def generate_preview(size = Spree::Config[:admin_pgroup_preview_size])
182
+ count = self.class.count_by_sql ["SELECT COUNT(*) FROM product_groups_products WHERE product_groups_products.product_group_id = ?", self]
183
+
184
+ return count, products.limit(size)
185
+ end
186
+
187
+ def to_s
188
+ "<ProductGroup" + (id && "[#{id}]").to_s + ":'#{to_url}'>"
189
+ end
190
+
191
+ def to_param
192
+ self.permalink
193
+ end
194
+
195
+ def order_scope
196
+ if scope = product_scopes.detect {|s| s.is_ordering?}
197
+ scope.name
198
+ end
199
+ end
200
+
201
+ def order_scope=(scope_name)
202
+ if scope = product_scopes.detect {|s| s.is_ordering?}
203
+ scope.update_attribute(:name, scope_name)
204
+ else
205
+ self.product_scopes.build(:name => scope_name, :arguments => [])
206
+ end
207
+ end
208
+
209
+ # Build a new product group with a scope to filter by specified products
210
+ def self.new_from_products(products, attrs = {})
211
+ pg = new(attrs)
212
+ pg.product_scopes.build(:name => 'with_ids', :arguments => [products.map(&:id).join(',')])
213
+ pg
214
+ end
215
+
216
+ end
@@ -0,0 +1,5 @@
1
+ class ProductOptionType < ActiveRecord::Base
2
+ belongs_to :product
3
+ belongs_to :option_type
4
+ acts_as_list :scope => :product
5
+ end
@@ -0,0 +1,15 @@
1
+ class ProductProperty < ActiveRecord::Base
2
+ belongs_to :product
3
+ belongs_to :property
4
+
5
+ validates :property, :presence => true
6
+
7
+ # virtual attributes for use with AJAX completion stuff
8
+ def property_name
9
+ property.name if property
10
+ end
11
+
12
+ def property_name=(name)
13
+ self.property = Property.find_by_name(name) unless name.blank?
14
+ end
15
+ end
@@ -0,0 +1,78 @@
1
+ # *ProductScope* is model for storing named scopes with their arguments,
2
+ # to be used with ProductGroups.
3
+ #
4
+ # Each product Scope can be applied to Product (or product scope) with #apply_on method
5
+ # which returns new combined named scope
6
+ #
7
+ class ProductScope < ActiveRecord::Base
8
+ # name
9
+ # arguments
10
+ belongs_to :product_group
11
+ serialize :arguments
12
+
13
+ validate :check_validity_of_scope
14
+
15
+ extend ::Scopes::Dynamic
16
+
17
+ # Get all products with this scope
18
+ def products
19
+ if Product.respond_to?(name)
20
+ Product.send(name, *arguments)
21
+ end
22
+ end
23
+
24
+ # Applies product scope on Product model or another named scope
25
+ def apply_on(another_scope)
26
+ array = *self.arguments
27
+ if Product.respond_to?(self.name.intern)
28
+ relation2 = if (array.blank? || array.size < 2)
29
+ Product.send(self.name.intern, array.try(:first))
30
+ else
31
+ Product.send(self.name.intern, *array)
32
+ end
33
+ else
34
+ relation2 = Product.metasearch({self.name.intern => array}).relation
35
+ end
36
+ unless another_scope.class == ActiveRecord::Relation
37
+ another_scope = another_scope.send(:relation)
38
+ end
39
+ another_scope.merge(relation2)
40
+ end
41
+
42
+ before_validation(:on => :create) {
43
+ # Add default empty arguments so scope validates and errors aren't caused when previewing it
44
+ if name && args = Scopes::Product.arguments_for_scope_name(name)
45
+ self.arguments ||= ['']*args.length
46
+ end
47
+ }
48
+
49
+ # checks validity of the named scope (if its safe and can be applied on Product)
50
+ def check_validity_of_scope
51
+ errors.add(:name, "is not a valid scope name") unless Product.respond_to?(self.name.intern)
52
+ apply_on(Product).limit(0) != nil
53
+ rescue Exception => e
54
+ unless Rails.env.production?
55
+
56
+ puts "name: #{self.name}"
57
+ puts "arguments: #{self.arguments.inspect}"
58
+ puts e.message
59
+ puts e.backtrace
60
+ end
61
+ errors.add(:arguments, "are incorrect")
62
+ end
63
+
64
+ # test ordering scope by looking for name pattern or missed arguments
65
+ def is_ordering?
66
+ name =~ /^(ascend_by|descend_by)/ || arguments.blank?
67
+ end
68
+
69
+ def to_sentence
70
+ result = I18n.t(:sentence, :scope => [:product_scopes, :scopes, self.name], :default => "")
71
+ result = I18n.t(:name, :scope => [:product_scopes, :scopes, self.name]) if result.blank?
72
+ result % [*self.arguments]
73
+ end
74
+
75
+ def to_s
76
+ to_sentence
77
+ end
78
+ end
@@ -0,0 +1,18 @@
1
+ class Property < ActiveRecord::Base
2
+ has_and_belongs_to_many :prototypes
3
+
4
+ has_many :product_properties, :dependent => :destroy
5
+ has_many :products, :through => :product_properties
6
+
7
+ validates :name, :presentation, :presence => true
8
+
9
+ scope :sorted, lambda { order(:name) }
10
+
11
+ def self.find_all_by_prototype(prototype)
12
+ id = prototype
13
+ if prototype.class == Prototype
14
+ id = prototype.id
15
+ end
16
+ joins('left join properties_prototypes on property_id = properties.id').where('prototype_id = ?', id)
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ class Prototype < ActiveRecord::Base
2
+ has_and_belongs_to_many :properties
3
+ has_and_belongs_to_many :option_types
4
+ validates :name, :presence => true
5
+ end
@@ -0,0 +1,79 @@
1
+ class ReturnAuthorization < ActiveRecord::Base
2
+ belongs_to :order
3
+ has_many :inventory_units
4
+ before_create :generate_number
5
+ before_save :force_positive_amount
6
+
7
+ validates :order, :presence => true
8
+ validates :amount, :numericality => true
9
+ validate :must_have_shipped_units
10
+
11
+ state_machine :initial => 'authorized' do
12
+ after_transition :to => 'received', :do => :process_return
13
+
14
+ event :receive do
15
+ transition :to => 'received', :from => 'authorized', :if => :allow_receive?
16
+ end
17
+ event :cancel do
18
+ transition :to => 'canceled', :from => 'authorized'
19
+ end
20
+ end
21
+
22
+ def add_variant(variant_id, quantity)
23
+ order_units = self.order.inventory_units.group_by(&:variant_id)
24
+ returned_units = self.inventory_units.group_by(&:variant_id)
25
+
26
+ count = 0
27
+
28
+ if returned_units[variant_id].nil? || returned_units[variant_id].size < quantity
29
+ count = returned_units[variant_id].nil? ? 0 : returned_units[variant_id].size
30
+
31
+ order_units[variant_id].each do |inventory_unit|
32
+ next unless inventory_unit.return_authorization.nil? && count < quantity
33
+
34
+ inventory_unit.return_authorization = self
35
+ inventory_unit.save!
36
+
37
+ count += 1
38
+ end
39
+ elsif returned_units[variant_id].size > quantity
40
+ (returned_units[variant_id].size - quantity).times do |i|
41
+ returned_units[variant_id][i].return_authorization_id = nil
42
+ returned_units[variant_id][i].save!
43
+ end
44
+ end
45
+
46
+ self.order.authorize_return! if self.inventory_units.reload.size > 0 && !self.order.awaiting_return?
47
+ end
48
+
49
+ private
50
+ def must_have_shipped_units
51
+ errors.add(:order, I18n.t("has_no_shipped_units")) if order.nil? || !order.inventory_units.any?(&:shipped?)
52
+ end
53
+
54
+ def generate_number
55
+ return if self.number
56
+
57
+ record = true
58
+ while record
59
+ random = "RMA#{Array.new(9){rand(9)}.join}"
60
+ record = ReturnAuthorization.find(:first, :conditions => ["number = ?", random])
61
+ end
62
+ self.number = random
63
+ end
64
+
65
+ def process_return
66
+ inventory_units.each &:return!
67
+
68
+ credit = Adjustment.create(:source => self, :order_id => self.order.id, :amount => self.amount.abs * -1, :label => I18n.t("rma_credit"))
69
+ self.order.update!
70
+ end
71
+
72
+ def allow_receive?
73
+ !inventory_units.empty?
74
+ end
75
+
76
+ def force_positive_amount
77
+ self.amount = self.amount.abs
78
+ end
79
+ end
@@ -0,0 +1,3 @@
1
+ class Role < ActiveRecord::Base
2
+ has_and_belongs_to_many :users
3
+ end
@@ -0,0 +1,157 @@
1
+ require 'ostruct'
2
+ class Shipment < ActiveRecord::Base
3
+ belongs_to :order
4
+ belongs_to :shipping_method
5
+ belongs_to :address
6
+ has_many :state_events, :as => :stateful
7
+ has_many :inventory_units
8
+ has_one :adjustment, :as => :source
9
+
10
+ before_create :generate_shipment_number
11
+ after_destroy :release_inventory_units
12
+ after_save :ensure_correct_adjustment, :update_order
13
+
14
+ attr_accessor :special_instructions
15
+ accepts_nested_attributes_for :address
16
+ accepts_nested_attributes_for :inventory_units
17
+
18
+ validates :inventory_units, :presence => true, :if => :require_inventory
19
+ validates :shipping_method, :presence => true
20
+
21
+ make_permalink :field => :number
22
+
23
+ scope :shipped, where(:state => 'shipped')
24
+ scope :ready, where(:state => 'ready')
25
+ scope :pending, where(:state => 'pending')
26
+
27
+ def to_param
28
+ self.number if self.number
29
+ generate_shipment_number unless self.number
30
+ self.number.parameterize.to_s.upcase
31
+ end
32
+
33
+ def shipped=(value)
34
+ return unless value == "1" && shipped_at.nil?
35
+ self.shipped_at = Time.now
36
+ end
37
+
38
+ # The adjustment amount associated with this shipment (if any.) Returns only the first adjustment to match
39
+ # the shipment but there should never really be more than one.
40
+ def cost
41
+ adjustment ? adjustment.amount : 0
42
+ end
43
+
44
+ # shipment state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
45
+ state_machine :initial => 'pending', :use_transactions => false do
46
+ event :ready do
47
+ transition :from => 'pending', :to => 'ready'
48
+ end
49
+ event :pend do
50
+ transition :from => 'ready', :to => 'pending'
51
+ end
52
+ event :ship do
53
+ transition :from => 'ready', :to => 'shipped'
54
+ end
55
+
56
+ after_transition :to => 'shipped', :do => :after_ship
57
+ end
58
+
59
+ def editable_by?(user)
60
+ !shipped?
61
+ end
62
+
63
+ def manifest
64
+ inventory_units.group_by(&:variant).map do |i|
65
+ OpenStruct.new(:variant => i.first, :quantity => i.last.length)
66
+ end
67
+ end
68
+
69
+
70
+ def line_items
71
+ if order.complete? and Spree::Config[:track_inventory_levels]
72
+ order.line_items.select {|li| inventory_units.map(&:variant_id).include?(li.variant_id)}
73
+ else
74
+ order.line_items
75
+ end
76
+ end
77
+
78
+ # Updates various aspects of the Shipment while bypassing any callbacks. Note that this method takes an explicit reference to the
79
+ # Order object. This is necessary because the association actually has a stale (and unsaved) copy of the Order and so it will not
80
+ # yield the correct results.
81
+ def update!(order)
82
+ old_state = self.state
83
+ new_state = determine_state(order)
84
+ update_attribute_without_callbacks "state", determine_state(order)
85
+ after_ship if new_state == 'shipped' and old_state != 'shipped'
86
+ end
87
+
88
+ private
89
+
90
+ def generate_shipment_number
91
+ return self.number unless self.number.blank?
92
+ record = true
93
+ while record
94
+ random = "H" + Array.new(11){rand(9)}.join
95
+ record = Shipment.find(:first, :conditions => ["number = ?", random])
96
+ end
97
+ self.number = random
98
+ end
99
+
100
+ def description_for_shipping_charge
101
+ "#{I18n.t(:shipping)} (#{shipping_method.name})"
102
+ end
103
+
104
+ # def transition_order
105
+ # update_attribute(:shipped_at, Time.now)
106
+ # # transition order to shipped if all shipments have been shipped
107
+ # order.ship! if order.shipments.all?(&:shipped?)
108
+ # end
109
+
110
+ def validate_shipping_method
111
+ unless shipping_method.nil?
112
+ errors.add :shipping_method, I18n.t("is_not_available_to_shipment_address") unless shipping_method.zone.include?(address)
113
+ end
114
+ end
115
+
116
+ def release_inventory_units
117
+ inventory_units.each {|unit| unit.update_attribute(:shipment_id, nil)}
118
+ end
119
+
120
+ # Determines the appropriate +state+ according to the following logic:
121
+ #
122
+ # pending unless +order.payment_state+ is +paid+
123
+ # shipped if already shipped (ie. does not change the state)
124
+ # ready all other cases
125
+ def determine_state(order)
126
+ return "pending" if self.inventory_units.any? {|unit| unit.backordered?}
127
+ return "shipped" if state == "shipped"
128
+ order.payment_state == "balance_due" ? "pending" : "ready"
129
+ end
130
+
131
+ # Determines whether or not inventory units should be associated with the shipment. This is always +false+ when
132
+ # +Spree::Config[:track_inventory_levels]+ is set to +false.+ Otherwise its +true+ whenever the order is completed
133
+ # (and not canceled.)
134
+ def require_inventory
135
+ return false unless Spree::Config[:track_inventory_levels]
136
+ order.completed? && !order.canceled?
137
+ end
138
+
139
+ def after_ship
140
+ inventory_units.each &:ship!
141
+ ShipmentMailer.shipped_email(self).deliver
142
+ end
143
+
144
+ def ensure_correct_adjustment
145
+ if adjustment
146
+ adjustment.originator = shipping_method
147
+ adjustment.save
148
+ else
149
+ shipping_method.create_adjustment(I18n.t(:shipping), order, self, true)
150
+ reload #ensure adjustment is present on later saves
151
+ end
152
+ end
153
+
154
+ def update_order
155
+ order.update!
156
+ end
157
+ end