spree_core 1.1.6 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/app/assets/images/{creditcards → credit_cards}/amex_cid.gif +0 -0
  2. data/app/assets/images/{creditcards/creditcard.gif → credit_cards/credit_card.gif} +0 -0
  3. data/app/assets/images/{creditcards → credit_cards}/discover_cid.gif +0 -0
  4. data/app/assets/images/{creditcards → credit_cards}/icons/american_express.png +0 -0
  5. data/app/assets/images/{creditcards → credit_cards}/icons/cirrus.png +0 -0
  6. data/app/assets/images/{creditcards → credit_cards}/icons/delta.png +0 -0
  7. data/app/assets/images/{creditcards → credit_cards}/icons/dinersclub.png +0 -0
  8. data/app/assets/images/{creditcards → credit_cards}/icons/directdebit.png +0 -0
  9. data/app/assets/images/{creditcards → credit_cards}/icons/discover.png +0 -0
  10. data/app/assets/images/{creditcards → credit_cards}/icons/egold.png +0 -0
  11. data/app/assets/images/{creditcards → credit_cards}/icons/maestro.png +0 -0
  12. data/app/assets/images/{creditcards → credit_cards}/icons/master.png +0 -0
  13. data/app/assets/images/{creditcards → credit_cards}/icons/paypal.png +0 -0
  14. data/app/assets/images/{creditcards → credit_cards}/icons/solo.png +0 -0
  15. data/app/assets/images/{creditcards → credit_cards}/icons/switch.png +0 -0
  16. data/app/assets/images/{creditcards → credit_cards}/icons/visa.png +0 -0
  17. data/app/assets/images/{creditcards → credit_cards}/icons/visaelectron.png +0 -0
  18. data/app/assets/images/{creditcards → credit_cards}/icons/westernunion.png +0 -0
  19. data/app/assets/images/{creditcards → credit_cards}/icons/wirecard.png +0 -0
  20. data/app/assets/images/{creditcards → credit_cards}/icons/worldpay.png +0 -0
  21. data/app/assets/images/{creditcards → credit_cards}/master_cid.jpg +0 -0
  22. data/app/assets/images/{creditcards → credit_cards}/visa_cid.gif +0 -0
  23. data/app/assets/javascripts/admin/admin.js.erb +12 -136
  24. data/app/assets/javascripts/admin/checkouts/edit.js +18 -35
  25. data/app/assets/javascripts/admin/gateway.js +2 -2
  26. data/app/assets/javascripts/admin/images/index.js.coffee +12 -0
  27. data/app/assets/javascripts/admin/images/new.js.coffee +4 -0
  28. data/app/assets/javascripts/admin/orders/edit.js +1 -1
  29. data/app/assets/javascripts/admin/orders/edit_form.js +0 -2
  30. data/app/assets/javascripts/admin/product_autocomplete.js.erb +116 -0
  31. data/app/assets/javascripts/store/cart.js.coffee +7 -0
  32. data/app/assets/javascripts/store/checkout.js.coffee +57 -0
  33. data/app/assets/javascripts/store/product.js.coffee +36 -0
  34. data/app/assets/stylesheets/admin/admin.css.erb +5 -0
  35. data/app/assets/stylesheets/admin/spree_core.css +1 -0
  36. data/app/assets/stylesheets/store/screen.css.scss +15 -1
  37. data/app/assets/stylesheets/store/variables.css.scss +29 -29
  38. data/app/controllers/spree/admin/banners_controller.rb +14 -0
  39. data/app/controllers/spree/admin/base_controller.rb +11 -0
  40. data/app/controllers/spree/admin/images_controller.rb +13 -5
  41. data/app/controllers/spree/admin/line_items_controller.rb +16 -25
  42. data/app/controllers/spree/admin/mail_methods_controller.rb +1 -8
  43. data/app/controllers/spree/admin/option_types_controller.rb +0 -25
  44. data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -3
  45. data/app/controllers/spree/admin/orders_controller.rb +23 -14
  46. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -7
  47. data/app/controllers/spree/admin/payments_controller.rb +5 -5
  48. data/app/controllers/spree/admin/products_controller.rb +15 -5
  49. data/app/controllers/spree/admin/prototypes_controller.rb +2 -2
  50. data/app/controllers/spree/admin/reports_controller.rb +1 -7
  51. data/app/controllers/spree/admin/resource_controller.rb +130 -130
  52. data/app/controllers/spree/admin/search_controller.rb +47 -0
  53. data/app/controllers/spree/admin/taxons_controller.rb +0 -43
  54. data/app/controllers/spree/base_controller.rb +2 -1
  55. data/app/controllers/spree/checkout_controller.rb +29 -10
  56. data/app/controllers/spree/orders_controller.rb +7 -11
  57. data/app/controllers/spree/products_controller.rb +5 -1
  58. data/app/helpers/spree/account_helper.rb +4 -0
  59. data/app/helpers/spree/admin/base_helper.rb +2 -44
  60. data/app/helpers/spree/admin/navigation_helper.rb +1 -3
  61. data/app/helpers/spree/admin/orders_helper.rb +3 -2
  62. data/app/helpers/spree/admin/products_helper.rb +21 -0
  63. data/app/helpers/spree/base_helper.rb +14 -11
  64. data/app/helpers/spree/checkout_helper.rb +5 -1
  65. data/app/helpers/spree/orders_helper.rb +5 -0
  66. data/app/helpers/spree/products_helper.rb +4 -0
  67. data/app/helpers/spree/trackers_helper.rb +4 -0
  68. data/app/models/spree/ability.rb +70 -0
  69. data/app/models/spree/address.rb +4 -12
  70. data/app/models/spree/adjustment.rb +30 -8
  71. data/app/models/spree/app_configuration.rb +1 -1
  72. data/app/models/spree/calculator/price_sack.rb +3 -5
  73. data/app/models/spree/country.rb +1 -4
  74. data/app/models/spree/{creditcard.rb → credit_card.rb} +4 -4
  75. data/app/models/spree/gateway.rb +2 -2
  76. data/app/models/spree/gateway/bogus.rb +10 -10
  77. data/app/models/spree/gateway/bogus_simple.rb +4 -4
  78. data/app/models/spree/image.rb +3 -12
  79. data/app/models/spree/inventory_unit.rb +4 -6
  80. data/app/models/spree/{user.rb → legacy_user.rb} +7 -6
  81. data/app/models/spree/line_item.rb +4 -5
  82. data/app/models/spree/option_type.rb +4 -6
  83. data/app/models/spree/option_value.rb +1 -1
  84. data/app/models/spree/order.rb +90 -132
  85. data/app/models/spree/order/checkout.rb +124 -0
  86. data/app/models/spree/payment.rb +6 -6
  87. data/app/models/spree/payment/processing.rb +34 -38
  88. data/app/models/spree/payment_method.rb +2 -2
  89. data/app/models/spree/preference.rb +2 -0
  90. data/app/models/spree/preferences/preferable_class_methods.rb +0 -2
  91. data/app/models/spree/preferences/store.rb +3 -21
  92. data/app/models/spree/product.rb +41 -43
  93. data/app/models/spree/product/scopes.rb +9 -25
  94. data/app/models/spree/product_option_type.rb +2 -2
  95. data/app/models/spree/product_property.rb +9 -4
  96. data/app/models/spree/property.rb +1 -1
  97. data/app/models/spree/prototype.rb +2 -2
  98. data/app/models/spree/return_authorization.rb +2 -2
  99. data/app/models/spree/role.rb +1 -1
  100. data/app/models/spree/shipment.rb +6 -5
  101. data/app/models/spree/shipping_method.rb +19 -13
  102. data/app/models/spree/state.rb +2 -5
  103. data/app/models/spree/state_change.rb +1 -1
  104. data/app/models/spree/tax_rate.rb +8 -1
  105. data/app/models/spree/taxon.rb +5 -1
  106. data/app/models/spree/taxonomy.rb +1 -1
  107. data/app/models/spree/tokenized_permission.rb +6 -0
  108. data/app/models/spree/tracker.rb +1 -1
  109. data/app/models/spree/variant.rb +13 -40
  110. data/app/models/spree/zone.rb +15 -14
  111. data/app/models/spree/zone_member.rb +1 -1
  112. data/app/views/spree/admin/image_settings/edit.html.erb +2 -2
  113. data/app/views/spree/admin/images/_form.html.erb +8 -4
  114. data/app/views/spree/admin/images/index.html.erb +1 -1
  115. data/app/views/spree/admin/line_items/create.js.erb +1 -1
  116. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  117. data/app/views/spree/admin/option_types/index.html.erb +1 -1
  118. data/app/views/spree/admin/orders/_add_product.html.erb +1 -1
  119. data/app/views/spree/admin/orders/customer_details/edit.html.erb +1 -1
  120. data/app/views/spree/admin/orders/index.html.erb +4 -4
  121. data/app/views/spree/admin/orders/show.html.erb +1 -1
  122. data/app/views/spree/admin/payments/_form.html.erb +1 -1
  123. data/app/views/spree/admin/payments/new.html.erb +0 -4
  124. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +1 -1
  125. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +2 -2
  126. data/app/views/spree/admin/products/_form.html.erb +21 -5
  127. data/app/views/spree/admin/products/index.html.erb +2 -2
  128. data/app/views/spree/admin/properties/_form.html.erb +1 -1
  129. data/app/views/spree/admin/properties/index.html.erb +1 -1
  130. data/app/views/spree/admin/return_authorizations/_form.html.erb +33 -17
  131. data/app/views/spree/admin/return_authorizations/edit.html.erb +2 -2
  132. data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
  133. data/app/views/spree/admin/shared/_head.html.erb +12 -2
  134. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -4
  135. data/app/views/spree/admin/shared/_product_tabs.html.erb +0 -6
  136. data/app/views/spree/admin/shared/_show_resource_links.html.erb +3 -3
  137. data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
  138. data/app/views/spree/admin/shipments/edit.html.erb +2 -2
  139. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  140. data/app/views/spree/admin/states/_state_list.html.erb +1 -1
  141. data/app/views/spree/admin/tax_rates/index.html.erb +1 -1
  142. data/app/views/spree/admin/taxonomies/_form.html.erb +1 -1
  143. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  144. data/app/views/spree/admin/taxons/_taxon_table.html.erb +2 -2
  145. data/app/views/spree/admin/variants/_form.html.erb +13 -13
  146. data/app/views/spree/admin/variants/index.html.erb +1 -7
  147. data/app/views/spree/checkout/_address.html.erb +10 -4
  148. data/app/views/spree/checkout/edit.html.erb +0 -1
  149. data/app/views/spree/checkout/payment/_gateway.html.erb +5 -5
  150. data/app/views/spree/checkout/registration.html.erb +2 -2
  151. data/app/views/spree/content/cvv.html.erb +6 -6
  152. data/app/views/spree/layouts/spree_application.html.erb +4 -48
  153. data/app/views/spree/order_mailer/cancel_email.text.erb +5 -5
  154. data/app/views/spree/order_mailer/confirm_email.text.erb +6 -7
  155. data/app/views/spree/orders/_adjustments.html.erb +14 -0
  156. data/app/views/spree/orders/_form.html.erb +1 -0
  157. data/app/views/spree/orders/show.html.erb +3 -3
  158. data/app/views/spree/products/_thumbnails.html.erb +1 -1
  159. data/app/views/spree/products/index.html.erb +1 -1
  160. data/app/views/spree/shared/_footer.html.erb +6 -0
  161. data/app/views/spree/shared/_google_analytics.html.erb +15 -16
  162. data/app/views/spree/shared/_head.html.erb +3 -9
  163. data/app/views/spree/shared/_header.html.erb +5 -0
  164. data/app/views/spree/shared/_main_nav_bar.html.erb +6 -0
  165. data/app/views/spree/shared/_nav_bar.html.erb +7 -3
  166. data/app/views/spree/shared/_order_details.html.erb +14 -11
  167. data/app/views/spree/shared/_sidebar.html.erb +3 -0
  168. data/app/views/spree/shared/unauthorized.html.erb +0 -0
  169. data/app/views/spree/shipment_mailer/shipped_email.text.erb +7 -7
  170. data/app/views/spree/taxons/show.html.erb +1 -1
  171. data/config/initializers/check_for_orphaned_preferences.rb +1 -1
  172. data/config/initializers/spree.rb +0 -12
  173. data/config/initializers/user_class_extensions.rb +25 -0
  174. data/config/initializers/workarounds_for_ruby19.rb +72 -0
  175. data/config/locales/en.yml +11 -24
  176. data/config/routes.rb +7 -37
  177. data/db/migrate/20090823005402_spree_zero_nine_zero.rb +14 -12
  178. data/db/migrate/20091015153048_add_openid_field_to_users.rb +9 -7
  179. data/db/migrate/20100209144531_polymorphic_payments.rb +5 -5
  180. data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +4 -4
  181. data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +3 -1
  182. data/db/migrate/20100811163637_add_guest_flag.rb +3 -1
  183. data/db/migrate/20100901171814_change_guest_flag_to_anonymous.rb +3 -1
  184. data/db/migrate/20101026184959_generate_anonymous_users.rb +3 -3
  185. data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +3 -1
  186. data/db/migrate/20111007143030_namespace_top_level_models.rb +18 -1
  187. data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +6 -4
  188. data/db/migrate/20120509055454_create_tokenized_permissions_table.rb +16 -0
  189. data/db/migrate/20120530012000_rename_creditcards_to_credit_cards.rb +11 -0
  190. data/db/migrate/20120604203654_remove_credit_total_from_orders.rb +5 -0
  191. data/lib/generators/spree/custom_user/custom_user_generator.rb +53 -0
  192. data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +28 -0
  193. data/lib/generators/spree/custom_user/templates/initializer.rb.tt +1 -0
  194. data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -0
  195. data/lib/generators/spree/dummy/dummy_generator.rb +3 -0
  196. data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +1 -0
  197. data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
  198. data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
  199. data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
  200. data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
  201. data/lib/generators/spree/install/templates/config/initializers/spree.rb +2 -0
  202. data/lib/spree/core.rb +15 -2
  203. data/lib/spree/core/controller_helpers.rb +123 -62
  204. data/lib/spree/core/current_order.rb +5 -0
  205. data/lib/spree/core/engine.rb +1 -1
  206. data/lib/spree/core/mail_settings.rb +1 -2
  207. data/lib/spree/core/permalinks.rb +1 -5
  208. data/lib/spree/core/preference_rescue.rb +8 -4
  209. data/lib/spree/core/relation_serialization.rb +9 -0
  210. data/lib/spree/core/respond_with.rb +1 -1
  211. data/lib/spree/core/s3_support.rb +25 -0
  212. data/lib/spree/core/search/base.rb +2 -5
  213. data/lib/spree/core/ssl_requirement.rb +2 -2
  214. data/lib/spree/core/store_helpers.rb +1 -2
  215. data/lib/spree/core/testing_support/controller_requests.rb +1 -0
  216. data/lib/spree/core/testing_support/env.rb +2 -0
  217. data/lib/spree/core/testing_support/factories/{creditcard_factory.rb → credit_card_factory.rb} +3 -3
  218. data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
  219. data/lib/spree/core/testing_support/factories/product_factory.rb +4 -4
  220. data/lib/spree/core/testing_support/factories/user_factory.rb +3 -3
  221. data/lib/spree/core/testing_support/factories/zone_factory.rb +2 -3
  222. data/lib/spree/core/token_resource.rb +27 -0
  223. data/lib/spree/core/version.rb +1 -1
  224. data/lib/spree/product_filters.rb +12 -13
  225. data/lib/tasks/core.rake +1 -1
  226. metadata +146 -154
  227. data/app/assets/images/noimage/large.png +0 -0
  228. data/app/assets/javascripts/admin/images/index.js +0 -10
  229. data/app/assets/javascripts/admin/images/new.js +0 -5
  230. data/app/assets/javascripts/admin/products.js +0 -2
  231. data/app/assets/javascripts/store/cart.js +0 -11
  232. data/app/assets/javascripts/store/checkout.js +0 -78
  233. data/app/assets/javascripts/store/product.js +0 -49
  234. data/app/controllers/spree/admin/users_controller.rb +0 -68
  235. data/app/views/spree/admin/option_types/_available.html.erb +0 -28
  236. data/app/views/spree/admin/option_types/_selected.html.erb +0 -26
  237. data/app/views/spree/admin/option_types/available.js.erb +0 -2
  238. data/app/views/spree/admin/option_types/select.js.erb +0 -3
  239. data/app/views/spree/admin/option_types/selected.html.erb +0 -6
  240. data/app/views/spree/admin/orders/history.html.erb +0 -29
  241. data/app/views/spree/admin/products/_option_types.html.erb +0 -40
  242. data/app/views/spree/admin/shared/_additional_field.html.erb +0 -5
  243. data/app/views/spree/admin/shared/_routes.html.erb +0 -8
  244. data/app/views/spree/admin/shared/_translations.html.erb +0 -17
  245. data/app/views/spree/admin/taxons/available.js.erb +0 -26
  246. data/app/views/spree/admin/taxons/remove.html.erb +0 -1
  247. data/app/views/spree/admin/taxons/select.js.erb +0 -2
  248. data/app/views/spree/admin/taxons/selected.html.erb +0 -42
  249. data/app/views/spree/admin/users/_form.html.erb +0 -19
  250. data/app/views/spree/admin/users/edit.html.erb +0 -14
  251. data/app/views/spree/admin/users/index.html.erb +0 -48
  252. data/app/views/spree/admin/users/new.html.erb +0 -14
  253. data/app/views/spree/admin/users/show.html.erb +0 -21
  254. data/app/views/spree/shared/_store_menu.html.erb +0 -2
  255. data/config/initializers/rails_5868.rb +0 -8
  256. data/db/migrate/20120605211305_make_users_email_index_unique.rb +0 -10
  257. data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +0 -11
  258. data/db/sample/users.rb +0 -61
  259. data/lib/generators/spree/sandbox/sandbox_generator.rb +0 -36
  260. data/lib/generators/spree/sandbox/templates/rails/routes.rb +0 -7
  261. data/lib/spree/core/ext/array.rb +0 -14
  262. data/lib/spree/core/ext/hash.rb +0 -75
  263. data/lib/spree/core/ext/string.rb +0 -10
  264. data/lib/tasks/install.rake +0 -18
@@ -41,9 +41,9 @@ module Spree
41
41
 
42
42
  private
43
43
 
44
- def load_order
45
- @order = Order.find_by_number(params[:order_id], :include => :adjustments)
46
- end
44
+ def load_order
45
+ @order = Order.find_by_number!(params[:order_id], :include => :adjustments)
46
+ end
47
47
 
48
48
  end
49
49
  end
@@ -4,7 +4,7 @@ module Spree
4
4
  require 'spree/core/gateway_error'
5
5
  before_filter :initialize_txn_partials
6
6
  before_filter :initialize_order_events
7
- before_filter :load_order, :only => [:show, :edit, :update, :fire, :resend, :history, :user]
7
+ before_filter :load_order, :only => [:show, :edit, :update, :fire, :resend]
8
8
 
9
9
  respond_to :html
10
10
 
@@ -14,6 +14,12 @@ module Spree
14
14
  @show_only_completed = params[:q][:completed_at_not_null].present?
15
15
  params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc'
16
16
 
17
+ # As date params are deleted if @show_only_completed, store
18
+ # the original date so we can restore them into the params
19
+ # after the search
20
+ created_at_gt = params[:q][:created_at_gt]
21
+ created_at_lt = params[:q][:created_at_lt]
22
+
17
23
  if !params[:q][:created_at_gt].blank?
18
24
  params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue ""
19
25
  end
@@ -29,6 +35,11 @@ module Spree
29
35
 
30
36
  @search = Order.ransack(params[:q])
31
37
  @orders = @search.result.includes([:user, :shipments, :payments]).page(params[:page]).per(Spree::Config[:orders_per_page])
38
+
39
+ # Restore dates
40
+ params[:q][:created_at_gt] = created_at_gt
41
+ params[:q][:created_at_lt] = created_at_lt
42
+
32
43
  respond_with(@orders)
33
44
  end
34
45
 
@@ -71,7 +82,6 @@ module Spree
71
82
  end
72
83
  end
73
84
 
74
-
75
85
  def fire
76
86
  # TODO - possible security check here but right now any admin can before any transition (and the state machine
77
87
  # itself will make sure transitions are not applied in the wrong state)
@@ -96,20 +106,19 @@ module Spree
96
106
 
97
107
  private
98
108
 
99
- def load_order
100
- @order ||= Order.find_by_number(params[:id], :include => :adjustments) if params[:id]
101
- @order
102
- end
109
+ def load_order
110
+ @order = Order.find_by_number!(params[:id], :include => :adjustments) if params[:id]
111
+ end
103
112
 
104
- # Allows extensions to add new forms of payment to provide their own display of transactions
105
- def initialize_txn_partials
106
- @txn_partials = []
107
- end
113
+ # Allows extensions to add new forms of payment to provide their own display of transactions
114
+ def initialize_txn_partials
115
+ @txn_partials = []
116
+ end
108
117
 
109
- # Used for extensions which need to provide their own custom event links on the order details view.
110
- def initialize_order_events
111
- @order_events = %w{cancel resume}
112
- end
118
+ # Used for extensions which need to provide their own custom event links on the order details view.
119
+ def initialize_order_events
120
+ @order_events = %w{cancel resume}
121
+ end
113
122
 
114
123
  end
115
124
  end
@@ -27,13 +27,7 @@ module Spree
27
27
  end
28
28
 
29
29
  payment_method_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
30
- attributes = params[:payment_method].merge(payment_method_params)
31
- attributes.each do |k,v|
32
- if k.include?("password") && attributes[k].blank?
33
- attributes.delete(k)
34
- end
35
- end
36
- if @payment_method.update_attributes(attributes)
30
+ if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
37
31
  invoke_callbacks(:update, :after)
38
32
  flash.notice = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method))
39
33
  respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
@@ -21,7 +21,7 @@ module Spree
21
21
  def create
22
22
  @payment = @order.payments.build(object_params)
23
23
  if @payment.payment_method.is_a?(Spree::Gateway) && @payment.payment_method.payment_profiles_supported? && params[:card].present? and params[:card] != 'new'
24
- @payment.source = Creditcard.find_by_id(params[:card])
24
+ @payment.source = CreditCard.find_by_id(params[:card])
25
25
  end
26
26
 
27
27
  begin
@@ -46,7 +46,7 @@ module Spree
46
46
 
47
47
  rescue Spree::Core::GatewayError => e
48
48
  flash[:error] = "#{e.message}"
49
- respond_with(@payment) { |format| format.html { redirect_to new_admin_payment_path(@order) } }
49
+ respond_with(@payment) { |format| format.html { redirect_to new_admin_order_payment_path(@order) } }
50
50
  end
51
51
  end
52
52
 
@@ -83,15 +83,15 @@ module Spree
83
83
  else
84
84
  @payment_method = @payment_methods.first
85
85
  end
86
- @previous_cards = @order.creditcards.with_payment_profile
86
+ @previous_cards = @order.credit_cards.with_payment_profile
87
87
  end
88
88
 
89
89
  def load_order
90
- @order ||= Order.find_by_number! params[:order_id]
90
+ @order = Order.find_by_number!(params[:order_id])
91
91
  end
92
92
 
93
93
  def load_payment
94
- @payment ||= Payment.find params[:id]
94
+ @payment = Payment.find(params[:id])
95
95
  end
96
96
 
97
97
  end
@@ -19,9 +19,13 @@ module Spree
19
19
  end
20
20
  end
21
21
 
22
+ # override the destory method to set deleted_at value
23
+ # instead of actually deleting the product.
22
24
  def destroy
23
- @product = Product.where(:permalink => params[:id]).first!
24
- @product.delete
25
+ @product = Product.find_by_permalink!(params[:id])
26
+ @product.update_column(:deleted_at, Time.now)
27
+
28
+ @product.variants_including_master.update_all(:deleted_at => Time.now)
25
29
 
26
30
  flash.notice = I18n.t('notice_messages.product_deleted')
27
31
 
@@ -67,6 +71,8 @@ module Spree
67
71
  end
68
72
 
69
73
  def load_data
74
+ @taxons = Taxon.order(:name)
75
+ @option_types = OptionType.order(:name)
70
76
  @tax_categories = TaxCategory.order(:name)
71
77
  @shipping_categories = ShippingCategory.order(:name)
72
78
  end
@@ -86,9 +92,13 @@ module Spree
86
92
  includes([:master, {:variants => [:images, :option_values]}]).
87
93
  page(params[:page]).
88
94
  per(Spree::Config[:admin_products_per_page])
89
- if params[:q][:s].include?("master_price")
90
- @collection = @collection.group("spree_variants.price")
91
- end
95
+
96
+ if params[:q][:s].include?("master_price")
97
+ # By applying the group in the main query we get an undefined method gsub for Arel::Nodes::Descending
98
+ # It seems to only work when the price is actually being sorted in the query
99
+ # To be investigated later.
100
+ @collection = @collection.group("spree_variants.price")
101
+ end
92
102
  else
93
103
  includes = [{:variants => [:images, {:option_values => :option_type}]}, {:master => :images}]
94
104
 
@@ -29,8 +29,8 @@ module Spree
29
29
  private
30
30
 
31
31
  def set_habtm_associations
32
- @prototype.property_ids = params[:option_type].blank? ? [] : params[:property][:id]
33
- @prototype.option_type_ids = params[:option_type].blank? ? [] : params[:option_type][:id]
32
+ @prototype.property_ids = params[:property][:id] if params[:property]
33
+ @prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
34
34
  end
35
35
  end
36
36
  end
@@ -1,11 +1,10 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class ReportsController < Spree::Admin::BaseController
4
- before_filter :load_data
5
4
  respond_to :html
6
5
 
7
6
  AVAILABLE_REPORTS = {
8
- :sales_total => {:name => I18n.t(:sales_total), :description => I18n.t(:sales_total_description)}
7
+ :sales_total => { :name => I18n.t(:sales_total), :description => I18n.t(:sales_total_description) }
9
8
  }
10
9
 
11
10
  def index
@@ -43,11 +42,6 @@ module Spree
43
42
  respond_with
44
43
  end
45
44
 
46
- private
47
- def load_data
48
-
49
- end
50
-
51
45
  end
52
46
  end
53
47
  end
@@ -2,7 +2,7 @@ require 'spree/core/action_callbacks'
2
2
 
3
3
  class Spree::Admin::ResourceController < Spree::Admin::BaseController
4
4
  helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
5
- prepend_before_filter :load_resource
5
+ before_filter :load_resource
6
6
  rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
7
7
 
8
8
  respond_to :html
@@ -12,14 +12,14 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
12
12
  invoke_callbacks(:new_action, :before)
13
13
  respond_with(@object) do |format|
14
14
  format.html { render :layout => !request.xhr? }
15
- format.js { render :layout => false }
15
+ format.js { render :layout => false }
16
16
  end
17
17
  end
18
18
 
19
19
  def edit
20
20
  respond_with(@object) do |format|
21
21
  format.html { render :layout => !request.xhr? }
22
- format.js { render :layout => false }
22
+ format.js { render :layout => false }
23
23
  end
24
24
  end
25
25
 
@@ -72,169 +72,169 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
72
72
 
73
73
  protected
74
74
 
75
- def resource_not_found
76
- flash[:error] = flash_message_for(model_class.new, :not_found)
77
- redirect_to collection_url
78
- end
75
+ def resource_not_found
76
+ flash[:error] = flash_message_for(model_class.new, :not_found)
77
+ redirect_to collection_url
78
+ end
79
79
 
80
- class << self
81
- attr_accessor :parent_data
82
- attr_accessor :callbacks
80
+ class << self
81
+ attr_accessor :parent_data
82
+ attr_accessor :callbacks
83
83
 
84
- def belongs_to(model_name, options = {})
85
- @parent_data ||= {}
86
- @parent_data[:model_name] = model_name
87
- @parent_data[:model_class] = model_name.to_s.classify.constantize
88
- @parent_data[:find_by] = options[:find_by] || :id
89
- end
84
+ def belongs_to(model_name, options = {})
85
+ @parent_data ||= {}
86
+ @parent_data[:model_name] = model_name
87
+ @parent_data[:model_class] = model_name.to_s.classify.constantize
88
+ @parent_data[:find_by] = options[:find_by] || :id
89
+ end
90
90
 
91
- def new_action
92
- @callbacks ||= {}
93
- @callbacks[:new_action] ||= Spree::ActionCallbacks.new
94
- end
91
+ def new_action
92
+ @callbacks ||= {}
93
+ @callbacks[:new_action] ||= Spree::ActionCallbacks.new
94
+ end
95
95
 
96
- def create
97
- @callbacks ||= {}
98
- @callbacks[:create] ||= Spree::ActionCallbacks.new
99
- end
96
+ def create
97
+ @callbacks ||= {}
98
+ @callbacks[:create] ||= Spree::ActionCallbacks.new
99
+ end
100
100
 
101
- def update
102
- @callbacks ||= {}
103
- @callbacks[:update] ||= Spree::ActionCallbacks.new
104
- end
101
+ def update
102
+ @callbacks ||= {}
103
+ @callbacks[:update] ||= Spree::ActionCallbacks.new
104
+ end
105
105
 
106
- def destroy
107
- @callbacks ||= {}
108
- @callbacks[:destroy] ||= Spree::ActionCallbacks.new
106
+ def destroy
107
+ @callbacks ||= {}
108
+ @callbacks[:destroy] ||= Spree::ActionCallbacks.new
109
+ end
109
110
  end
110
- end
111
111
 
112
- def model_class
113
- "Spree::#{controller_name.classify}".constantize
114
- end
112
+ def model_class
113
+ "Spree::#{controller_name.classify}".constantize
114
+ end
115
115
 
116
- def model_name
117
- parent_data[:model_name].gsub('spree/', '')
118
- end
116
+ def model_name
117
+ parent_data[:model_name].gsub('spree/', '')
118
+ end
119
119
 
120
- def object_name
121
- controller_name.singularize
122
- end
120
+ def object_name
121
+ controller_name.singularize
122
+ end
123
123
 
124
- def load_resource
125
- if member_action?
126
- @object ||= load_resource_instance
127
- instance_variable_set("@#{object_name}", @object)
128
- else
129
- @collection ||= collection
130
- instance_variable_set("@#{controller_name}", @collection)
124
+ def load_resource
125
+ if member_action?
126
+ @object ||= load_resource_instance
127
+ instance_variable_set("@#{object_name}", @object)
128
+ else
129
+ @collection ||= collection
130
+ instance_variable_set("@#{controller_name}", @collection)
131
+ end
131
132
  end
132
- end
133
133
 
134
- def load_resource_instance
135
- if new_actions.include?(params[:action].to_sym)
136
- build_resource
137
- elsif params[:id]
138
- find_resource
134
+ def load_resource_instance
135
+ if new_actions.include?(params[:action].to_sym)
136
+ build_resource
137
+ elsif params[:id]
138
+ find_resource
139
+ end
139
140
  end
140
- end
141
141
 
142
- def parent_data
143
- self.class.parent_data
144
- end
142
+ def parent_data
143
+ self.class.parent_data
144
+ end
145
145
 
146
- def parent
147
- if parent_data.present?
148
- @parent ||= parent_data[:model_class].where(parent_data[:find_by] => params["#{model_name}_id"]).first
149
- instance_variable_set("@#{model_name}", @parent)
150
- else
151
- nil
146
+ def parent
147
+ if parent_data.present?
148
+ @parent ||= parent_data[:model_class].where(parent_data[:find_by] => params["#{model_name}_id"]).first
149
+ instance_variable_set("@#{model_name}", @parent)
150
+ else
151
+ nil
152
+ end
152
153
  end
153
- end
154
154
 
155
- def find_resource
156
- if parent_data.present?
157
- parent.send(controller_name).find(params[:id])
158
- else
159
- model_class.find(params[:id])
155
+ def find_resource
156
+ if parent_data.present?
157
+ parent.send(controller_name).find(params[:id])
158
+ else
159
+ model_class.find(params[:id])
160
+ end
160
161
  end
161
- end
162
162
 
163
- def build_resource
164
- if parent_data.present?
165
- parent.send(controller_name).build(params[object_name])
166
- else
167
- model_class.new(params[object_name])
163
+ def build_resource
164
+ if parent_data.present?
165
+ parent.send(controller_name).build(params[object_name])
166
+ else
167
+ model_class.new(params[object_name])
168
+ end
168
169
  end
169
- end
170
170
 
171
- def collection
172
- return parent.send(controller_name) if parent_data.present?
173
- if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
174
- model_class.accessible_by(current_ability)
175
- else
176
- model_class.scoped
171
+ def collection
172
+ return parent.send(controller_name) if parent_data.present?
173
+ if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
174
+ model_class.accessible_by(current_ability)
175
+ else
176
+ model_class.scoped
177
+ end
177
178
  end
178
- end
179
179
 
180
- def location_after_save
181
- collection_url
182
- end
180
+ def location_after_save
181
+ collection_url
182
+ end
183
183
 
184
- def invoke_callbacks(action, callback_type)
185
- callbacks = self.class.callbacks || {}
186
- return if callbacks[action].nil?
187
- case callback_type.to_sym
188
- when :before then callbacks[action].before_methods.each {|method| send method }
189
- when :after then callbacks[action].after_methods.each {|method| send method }
190
- when :fails then callbacks[action].fails_methods.each {|method| send method }
184
+ def invoke_callbacks(action, callback_type)
185
+ callbacks = self.class.callbacks || {}
186
+ return if callbacks[action].nil?
187
+ case callback_type.to_sym
188
+ when :before then callbacks[action].before_methods.each {|method| send method }
189
+ when :after then callbacks[action].after_methods.each {|method| send method }
190
+ when :fails then callbacks[action].fails_methods.each {|method| send method }
191
+ end
191
192
  end
192
- end
193
193
 
194
- # URL helpers
194
+ # URL helpers
195
195
 
196
- def new_object_url(options = {})
197
- if parent_data.present?
198
- spree.new_polymorphic_url([:admin, parent, model_class], options)
199
- else
200
- spree.new_polymorphic_url([:admin, model_class], options)
196
+ def new_object_url(options = {})
197
+ if parent_data.present?
198
+ spree.new_polymorphic_url([:admin, parent, model_class], options)
199
+ else
200
+ spree.new_polymorphic_url([:admin, model_class], options)
201
+ end
201
202
  end
202
- end
203
203
 
204
- def edit_object_url(object, options = {})
205
- if parent_data.present?
206
- spree.send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
207
- else
208
- spree.send "edit_admin_#{object_name}_url", object, options
204
+ def edit_object_url(object, options = {})
205
+ if parent_data.present?
206
+ spree.send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
207
+ else
208
+ spree.send "edit_admin_#{object_name}_url", object, options
209
+ end
209
210
  end
210
- end
211
211
 
212
- def object_url(object = nil, options = {})
213
- target = object ? object : @object
214
- if parent_data.present?
215
- spree.send "admin_#{model_name}_#{object_name}_url", parent, target, options
216
- else
217
- spree.send "admin_#{object_name}_url", target, options
212
+ def object_url(object = nil, options = {})
213
+ target = object ? object : @object
214
+ if parent_data.present?
215
+ spree.send "admin_#{model_name}_#{object_name}_url", parent, target, options
216
+ else
217
+ spree.send "admin_#{object_name}_url", target, options
218
+ end
218
219
  end
219
- end
220
220
 
221
- def collection_url(options = {})
222
- if parent_data.present?
223
- spree.polymorphic_url([:admin, parent, model_class], options)
224
- else
225
- spree.polymorphic_url([:admin, model_class], options)
221
+ def collection_url(options = {})
222
+ if parent_data.present?
223
+ spree.polymorphic_url([:admin, parent, model_class], options)
224
+ else
225
+ spree.polymorphic_url([:admin, model_class], options)
226
+ end
226
227
  end
227
- end
228
228
 
229
- def collection_actions
230
- [:index]
231
- end
229
+ def collection_actions
230
+ [:index]
231
+ end
232
232
 
233
- def member_action?
234
- !collection_actions.include? params[:action].to_sym
235
- end
233
+ def member_action?
234
+ !collection_actions.include? params[:action].to_sym
235
+ end
236
236
 
237
- def new_actions
238
- [:new, :create]
239
- end
237
+ def new_actions
238
+ [:new, :create]
239
+ end
240
240
  end