spree_core 0.40.4 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. data/README.md +6 -1
  2. data/app/controllers/admin/base_controller.rb +0 -57
  3. data/app/controllers/admin/configurations_controller.rb +1 -1
  4. data/app/controllers/admin/general_settings_controller.rb +1 -1
  5. data/app/controllers/admin/images_controller.rb +18 -8
  6. data/app/controllers/admin/inventory_settings_controller.rb +1 -1
  7. data/app/controllers/admin/mail_settings_controller.rb +1 -1
  8. data/app/controllers/admin/option_types_controller.rb +11 -0
  9. data/app/controllers/admin/orders_controller.rb +16 -20
  10. data/app/controllers/admin/overview_controller.rb +1 -1
  11. data/app/controllers/admin/payment_methods_controller.rb +6 -6
  12. data/app/controllers/admin/product_groups_controller.rb +10 -11
  13. data/app/controllers/admin/product_properties_controller.rb +5 -5
  14. data/app/controllers/admin/product_scopes_controller.rb +12 -4
  15. data/app/controllers/admin/products_controller.rb +17 -12
  16. data/app/controllers/admin/properties_controller.rb +7 -7
  17. data/app/controllers/admin/prototypes_controller.rb +15 -15
  18. data/app/controllers/admin/reports_controller.rb +12 -11
  19. data/app/controllers/admin/shipments_controller.rb +0 -5
  20. data/app/controllers/admin/shipping_categories_controller.rb +6 -6
  21. data/app/controllers/admin/shipping_methods_controller.rb +1 -2
  22. data/app/controllers/admin/states_controller.rb +12 -12
  23. data/app/controllers/admin/tax_categories_controller.rb +2 -2
  24. data/app/controllers/admin/tax_rates_controller.rb +8 -8
  25. data/app/controllers/admin/tax_settings_controller.rb +1 -1
  26. data/app/controllers/admin/taxonomies_controller.rb +3 -3
  27. data/app/controllers/admin/taxons_controller.rb +1 -8
  28. data/app/controllers/admin/trackers_controller.rb +1 -1
  29. data/app/controllers/admin/users_controller.rb +6 -9
  30. data/app/controllers/admin/variants_controller.rb +13 -2
  31. data/app/controllers/admin/zones_controller.rb +9 -9
  32. data/app/controllers/checkout_controller.rb +5 -5
  33. data/app/controllers/products_controller.rb +1 -1
  34. data/app/controllers/taxons_controller.rb +3 -1
  35. data/app/helpers/admin/navigation_helper.rb +36 -19
  36. data/app/helpers/admin/payments_helper.rb +1 -1
  37. data/app/helpers/admin/product_groups_helper.rb +1 -1
  38. data/app/helpers/admin/product_properties_helper.rb +5 -5
  39. data/app/helpers/admin/products_helper.rb +2 -2
  40. data/app/helpers/admin/users_helper.rb +5 -2
  41. data/app/helpers/hook_helper.rb +3 -3
  42. data/app/helpers/products_helper.rb +0 -19
  43. data/app/helpers/spree/base_helper.rb +33 -2
  44. data/app/helpers/taxons_helper.rb +3 -3
  45. data/app/mailers/order_mailer.rb +2 -2
  46. data/app/mailers/shipment_mailer.rb +2 -2
  47. data/app/models/address.rb +42 -9
  48. data/app/models/adjustment.rb +8 -8
  49. data/app/models/app_configuration.rb +0 -6
  50. data/app/models/billing_integration.rb +1 -1
  51. data/app/models/calculator/sales_tax.rb +3 -3
  52. data/app/models/configuration.rb +1 -1
  53. data/app/models/country.rb +4 -5
  54. data/app/models/creditcard.rb +38 -31
  55. data/app/models/gateway.rb +14 -14
  56. data/app/models/gateway/beanstream.rb +4 -4
  57. data/app/models/gateway/bogus.rb +6 -6
  58. data/app/models/gateway/braintree.rb +88 -0
  59. data/app/models/gateway/eway.rb +3 -3
  60. data/app/models/image.rb +5 -4
  61. data/app/models/option_type.rb +1 -0
  62. data/app/models/order.rb +60 -21
  63. data/app/models/payment.rb +5 -32
  64. data/app/models/preference.rb +7 -7
  65. data/app/models/product.rb +22 -7
  66. data/app/models/product_group.rb +22 -26
  67. data/app/models/product_property.rb +5 -5
  68. data/app/models/product_scope.rb +26 -6
  69. data/app/models/property.rb +1 -1
  70. data/app/models/state.rb +2 -3
  71. data/app/models/tax_category.rb +1 -0
  72. data/app/models/tax_rate.rb +1 -2
  73. data/app/models/taxon.rb +12 -10
  74. data/app/models/taxonomy.rb +7 -4
  75. data/app/models/tracker.rb +1 -1
  76. data/app/models/user.rb +4 -0
  77. data/app/models/variant.rb +1 -1
  78. data/app/models/zone.rb +1 -1
  79. data/app/models/zone_member.rb +3 -3
  80. data/app/views/admin/{shared → adjustments}/_adjustments_table.html.erb +7 -4
  81. data/app/views/admin/adjustments/edit.html.erb +1 -1
  82. data/app/views/admin/adjustments/index.html.erb +2 -2
  83. data/app/views/admin/adjustments/new.html.erb +2 -1
  84. data/app/views/admin/general_settings/edit.html.erb +4 -12
  85. data/app/views/admin/general_settings/show.html.erb +0 -5
  86. data/app/views/admin/images/index.html.erb +8 -5
  87. data/app/views/admin/inventory_settings/show.html.erb +1 -1
  88. data/app/views/admin/mail_methods/index.html.erb +4 -4
  89. data/app/views/admin/option_types/_form.html.erb +4 -4
  90. data/app/views/admin/option_types/_option_value_fields.html.erb +2 -2
  91. data/app/views/admin/option_types/edit.html.erb +4 -2
  92. data/app/views/admin/option_types/index.html.erb +5 -5
  93. data/app/views/admin/orders/_line_item.html.erb +2 -1
  94. data/app/views/admin/orders/history.html.erb +6 -2
  95. data/app/views/admin/orders/index.html.erb +22 -19
  96. data/app/views/admin/orders/show.html.erb +1 -1
  97. data/app/views/admin/orders/user.html.erb +1 -1
  98. data/app/views/admin/payment_methods/index.html.erb +7 -5
  99. data/app/views/admin/payments/_list.html.erb +3 -3
  100. data/app/views/admin/payments/index.html.erb +1 -1
  101. data/app/views/admin/payments/show.html.erb +2 -2
  102. data/app/views/admin/product_groups/edit.html.erb +7 -7
  103. data/app/views/admin/product_groups/index.html.erb +5 -3
  104. data/app/views/admin/product_groups/update.js.erb +4 -3
  105. data/app/views/admin/product_properties/_product_property_fields.html.erb +3 -3
  106. data/app/views/admin/product_properties/index.html.erb +10 -5
  107. data/app/views/admin/product_scopes/destroy.js.erb +1 -0
  108. data/app/views/admin/products/index.html.erb +32 -33
  109. data/app/views/admin/properties/_form.html.erb +2 -2
  110. data/app/views/admin/properties/index.html.erb +4 -4
  111. data/app/views/admin/prototypes/index.html.erb +4 -4
  112. data/app/views/admin/shared/_address_form.html.erb +1 -1
  113. data/app/views/admin/shared/_calculator_fields.html.erb +1 -1
  114. data/app/views/admin/shared/_destroy.js.erb +15 -2
  115. data/app/views/admin/shared/_order_tabs.html.erb +1 -1
  116. data/app/views/admin/shared/_report_criteria.html.erb +1 -1
  117. data/app/views/admin/shipments/_form.html.erb +6 -2
  118. data/app/views/admin/shipments/edit.html.erb +1 -1
  119. data/app/views/admin/shipments/index.html.erb +4 -2
  120. data/app/views/admin/shipping_methods/_form.html.erb +2 -0
  121. data/app/views/admin/shipping_methods/index.html.erb +3 -2
  122. data/app/views/admin/states/_state_list.html.erb +11 -5
  123. data/app/views/admin/tax_categories/index.html.erb +9 -4
  124. data/app/views/admin/tax_settings/show.html.erb +2 -2
  125. data/app/views/admin/taxonomies/_list.html.erb +4 -2
  126. data/app/views/admin/taxonomies/index.html.erb +2 -2
  127. data/app/views/admin/taxons/_form.html.erb +1 -1
  128. data/app/views/admin/trackers/index.html.erb +5 -5
  129. data/app/views/admin/users/_form.html.erb +3 -4
  130. data/app/views/admin/users/index.html.erb +7 -6
  131. data/app/views/admin/users/show.html.erb +3 -3
  132. data/app/views/admin/variants/index.html.erb +21 -6
  133. data/app/views/admin/zones/_form.html.erb +9 -9
  134. data/app/views/admin/zones/_member_type.html.erb +5 -5
  135. data/app/views/admin/zones/index.html.erb +7 -5
  136. data/app/views/checkout/_address.html.erb +2 -2
  137. data/app/views/checkout/_payment.html.erb +3 -6
  138. data/app/views/layouts/admin.html.erb +3 -9
  139. data/app/views/layouts/spree_application.html.erb +2 -1
  140. data/app/views/orders/_line_item.html.erb +1 -1
  141. data/app/views/orders/edit.html.erb +17 -16
  142. data/app/views/orders/show.html.erb +1 -1
  143. data/app/views/shared/_admin_head.html.erb +1 -1
  144. data/app/views/shared/_error_messages.html.erb +2 -2
  145. data/app/views/shared/_filters.html.erb +4 -4
  146. data/app/views/shared/_head.html.erb +2 -2
  147. data/app/views/shared/_nav_bar.html.erb +2 -2
  148. data/app/views/shared/_products.html.erb +4 -2
  149. data/app/views/shared/_taxonomies.html.erb +15 -8
  150. data/app/views/shipment_mailer/shipped_email.text.erb +2 -2
  151. data/config/cucumber.yml +10 -0
  152. data/config/initializers/form_builder.rb +1 -5
  153. data/config/initializers/workarounds_for_ruby19.rb +5 -5
  154. data/config/locales/en.yml +33 -6
  155. data/config/routes.rb +18 -13
  156. data/db/migrate/20090923100315_add_count_on_hand_to_variants_and_products.rb +5 -5
  157. data/db/migrate/20091213222815_creditcard_last_four_digits.rb +5 -5
  158. data/db/migrate/20100105132138_shipment_id_for_inventory_units.rb +2 -2
  159. data/db/migrate/20100209025806_create_payment_methods.rb +3 -3
  160. data/db/migrate/20100209144531_polymorphic_payments.rb +1 -1
  161. data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +2 -2
  162. data/db/migrate/20100224153127_deleted_at_for_payment_methods.rb +1 -1
  163. data/db/migrate/20100506185838_add_description_to_taxons.rb +1 -1
  164. data/db/migrate/20100816212146_shipping_method_id_for_orders.rb +1 -1
  165. data/db/migrate/20101026184808_migrate_checkout_to_orders.rb +2 -2
  166. data/db/migrate/20101223215658_add_position_to_variants.rb +9 -0
  167. data/db/migrate/20110110130847_add_next_state_to_state_events.rb +9 -0
  168. data/db/migrate/20110111122537_add_position_to_option_types.rb +9 -0
  169. data/db/migrate/20110314192118_remove_trailing_slashes_in_taxon_permalinks.rb +17 -0
  170. data/lib/custom_fixtures.rb +1 -1
  171. data/lib/{seo_assist.rb → middleware/seo_assist.rb} +14 -8
  172. data/lib/product_filters.rb +49 -43
  173. data/lib/redirect_legacy_product_url.rb +5 -5
  174. data/lib/scopes.rb +2 -2
  175. data/lib/scopes/dynamic.rb +9 -16
  176. data/lib/scopes/product.rb +33 -16
  177. data/lib/scopes/variant.rb +4 -3
  178. data/lib/spree/calculated_adjustments.rb +5 -2
  179. data/lib/spree/config.rb +2 -0
  180. data/lib/spree/current_order.rb +4 -4
  181. data/lib/spree/mail_settings.rb +3 -2
  182. data/lib/spree/search/base.rb +9 -10
  183. data/lib/spree_base.rb +22 -23
  184. data/lib/spree_core.rb +10 -69
  185. data/lib/spree_core/authorize_net_cim_hack.rb +1 -1
  186. data/lib/spree_core/delegate_belongs_to.rb +18 -24
  187. data/lib/spree_core/enumerable_constants.rb +38 -38
  188. data/lib/spree_core/find_by_param.rb +8 -6
  189. data/lib/spree_core/preferences/preference_definition.rb +7 -7
  190. data/lib/spree_core/railtie.rb +58 -0
  191. data/lib/spree_core/ssl_requirement.rb +4 -3
  192. data/lib/spree_core/testing_support/factories.rb +13 -0
  193. data/lib/spree_core/testing_support/factories/address_factory.rb +20 -0
  194. data/lib/spree_core/testing_support/factories/adjustment_factory.rb +6 -0
  195. data/lib/spree_core/testing_support/factories/calculator_factory.rb +5 -0
  196. data/lib/spree_core/testing_support/factories/configuraion_factory.rb +4 -0
  197. data/lib/spree_core/testing_support/factories/country_factory.rb +7 -0
  198. data/lib/spree_core/testing_support/factories/creditcard_factory.rb +11 -0
  199. data/lib/spree_core/testing_support/factories/inventory_unit_factory.rb +7 -0
  200. data/lib/spree_core/testing_support/factories/line_item_factory.rb +8 -0
  201. data/lib/spree_core/testing_support/factories/mail_method_factory.rb +4 -0
  202. data/lib/spree_core/testing_support/factories/options_factory.rb +10 -0
  203. data/lib/spree_core/testing_support/factories/order_factory.rb +18 -0
  204. data/lib/spree_core/testing_support/factories/payment_factory.rb +26 -0
  205. data/lib/spree_core/testing_support/factories/payment_method_factory.rb +17 -0
  206. data/lib/spree_core/testing_support/factories/product_factory.rb +16 -0
  207. data/lib/spree_core/testing_support/factories/product_group_factory.rb +3 -0
  208. data/lib/spree_core/testing_support/factories/product_option_type_factory.rb +4 -0
  209. data/lib/spree_core/testing_support/factories/product_property_factory.rb +4 -0
  210. data/lib/spree_core/testing_support/factories/product_scope_factory.rb +6 -0
  211. data/lib/spree_core/testing_support/factories/property_factory.rb +4 -0
  212. data/lib/spree_core/testing_support/factories/prototype_factory.rb +4 -0
  213. data/lib/spree_core/testing_support/factories/return_authorization_factory.rb +8 -0
  214. data/lib/spree_core/testing_support/factories/role_factory.rb +9 -0
  215. data/lib/spree_core/testing_support/factories/shipment_factory.rb +9 -0
  216. data/lib/spree_core/testing_support/factories/shipping_category_factory.rb +5 -0
  217. data/lib/spree_core/testing_support/factories/shipping_method_factory.rb +7 -0
  218. data/lib/spree_core/testing_support/factories/state_factory.rb +11 -0
  219. data/lib/spree_core/testing_support/factories/tax_category_factory.rb +8 -0
  220. data/lib/spree_core/testing_support/factories/tax_rate_factory.rb +5 -0
  221. data/lib/spree_core/testing_support/factories/taxon_factory.rb +5 -0
  222. data/lib/spree_core/testing_support/factories/taxonomy_factory.rb +3 -0
  223. data/lib/spree_core/testing_support/factories/tracker_factory.rb +5 -0
  224. data/lib/spree_core/testing_support/factories/user_factory.rb +15 -0
  225. data/lib/spree_core/testing_support/factories/variant_factory.rb +14 -0
  226. data/lib/spree_core/testing_support/factories/zone_factory.rb +18 -0
  227. data/lib/spree_core/theme_support/hook.rb +1 -1
  228. data/lib/spree_core/theme_support/more_patches.rb +20 -20
  229. data/lib/spree_core/version.rb +5 -0
  230. data/lib/tasks/common.rb +30 -0
  231. data/lib/tasks/install.rake +1 -1
  232. data/lib/tasks/rake_util.rb +19 -0
  233. data/lib/tasks/taxon.rake +14 -0
  234. data/public/images/reorder.jpg +0 -0
  235. data/public/javascripts/admin.js +0 -6
  236. data/public/javascripts/admin/unobtrusive_handlers.js +28 -0
  237. data/public/javascripts/checkout.js +3 -3
  238. data/public/stylesheets/admin/admin-forms.css +1 -6
  239. data/public/stylesheets/admin/admin.css +0 -28
  240. data/public/stylesheets/screen.css +0 -280
  241. metadata +81 -43
  242. data/app/controllers/countries_controller.rb +0 -11
  243. data/app/models/spree/alert.rb +0 -13
  244. data/app/models/state_monitor.rb +0 -25
  245. data/app/views/admin/shared/_alert.html.erb +0 -6
  246. data/app/views/countries/index.js.erb +0 -1
  247. data/app/views/shared/_doc_and_xmlns.html.erb +0 -2
  248. data/app/views/users/edit.html.erb +0 -9
  249. data/app/views/users/show.html.erb +0 -46
  250. data/lib/spree_core/validation_group.rb +0 -143
  251. data/public/stylesheets/scaffold.css +0 -54
data/README.md CHANGED
@@ -7,4 +7,9 @@ Create the test site
7
7
 
8
8
  Run the tests
9
9
 
10
- rake spec
10
+ rake spec
11
+
12
+ Run the coverage. After the rake task open coverage/index.html
13
+
14
+ rake rcov
15
+
@@ -1,44 +1,11 @@
1
1
  class Admin::BaseController < Spree::BaseController
2
2
  ssl_required
3
3
 
4
- before_filter :check_alerts if Rails.env.production?
5
-
6
4
  helper :search
7
5
  helper 'admin/navigation'
8
6
  layout 'admin'
9
7
 
10
- before_filter :parse_date_params
11
-
12
8
  protected
13
- def check_alerts
14
- return unless current_user and should_check_alerts?
15
-
16
- unless session.has_key? :alerts
17
- begin
18
- session[:alerts] = Spree::Alert.current(request.host)
19
- filter_dismissed_alerts
20
- Spree::Config.set :last_check_for_spree_alerts => DateTime.now.to_s
21
- rescue
22
- session[:alerts] = nil
23
- end
24
- end
25
- end
26
-
27
- def should_check_alerts?
28
- return false if not Spree::Config[:check_for_spree_alerts]
29
-
30
- last_check = Spree::Config[:last_check_for_spree_alerts]
31
- return true if last_check.blank?
32
-
33
- DateTime.parse(last_check) < 12.hours.ago
34
- end
35
-
36
- def filter_dismissed_alerts
37
- return unless session[:alerts]
38
- dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
39
- session[:alerts].reject! { |a| dismissed.include? a.id.to_s }
40
- end
41
-
42
9
  def render_js_for_destroy
43
10
  render :partial => "/admin/shared/destroy"
44
11
  flash.notice = nil
@@ -57,28 +24,4 @@ class Admin::BaseController < Spree::BaseController
57
24
  # return access_denied unless object.editable_by?(current_user)
58
25
  # true
59
26
  # end
60
-
61
- private
62
- def parse_date_params
63
- params.each do |k, v|
64
- parse_date_params_for(v) if v.is_a?(Hash)
65
- end
66
- end
67
-
68
- def parse_date_params_for(hash)
69
- dates = []
70
- hash.each do |k, v|
71
- parse_date_params_for(v) if v.is_a?(Hash)
72
- if k =~ /\(\di\)$/
73
- param_name = k[/^\w+/]
74
- dates << param_name
75
- end
76
- end
77
- if (dates.size > 0)
78
- dates.uniq.each do |date|
79
- hash[date] = [hash.delete("#{date}(1i)"), hash.delete("#{date}(2i)"), hash.delete("#{date}(3i)")].join('-')
80
- end
81
- end
82
- end
83
27
  end
84
-
@@ -1,6 +1,6 @@
1
1
  class Admin::ConfigurationsController < Admin::BaseController
2
2
  before_filter :initialize_extension_links, :only => :index
3
-
3
+
4
4
  class << self
5
5
  def add_link(text, path, description)
6
6
  unless @@extension_links.any?{|link| link[:link_text] == text}
@@ -2,7 +2,7 @@ class Admin::GeneralSettingsController < Admin::BaseController
2
2
 
3
3
  def update
4
4
  Spree::Config.set(params[:preferences])
5
-
5
+
6
6
  respond_to do |format|
7
7
  format.html {
8
8
  redirect_to admin_general_settings_path
@@ -1,7 +1,7 @@
1
1
  class Admin::ImagesController < Admin::BaseController
2
2
  resource_controller
3
3
  before_filter :load_data
4
-
4
+
5
5
  new_action.response do |wants|
6
6
  wants.html {render :action => :new, :layout => false}
7
7
  end
@@ -13,22 +13,32 @@ class Admin::ImagesController < Admin::BaseController
13
13
  update.response do |wants|
14
14
  wants.html {redirect_to admin_product_images_url(@product)}
15
15
  end
16
-
16
+
17
17
  create.before :set_viewable
18
18
  update.before :set_viewable
19
19
  destroy.before :destroy_before
20
-
21
- destroy.response do |wants|
20
+
21
+ destroy.response do |wants|
22
22
  wants.html do
23
23
  render :text => ""
24
24
  end
25
25
  end
26
-
26
+
27
+ def update_positions
28
+ params[:positions].each do |id, index|
29
+ Image.update_all(['position=?', index], ['id=?', id])
30
+ end
31
+
32
+ respond_to do |format|
33
+ format.js { render :text => 'Ok' }
34
+ end
35
+ end
36
+
27
37
  private
28
38
 
29
39
  def load_data
30
40
  @product = Product.find_by_permalink(params[:product_id])
31
- @variants = @product.variants.collect do |variant|
41
+ @variants = @product.variants.collect do |variant|
32
42
  [variant.options_text, variant.id ]
33
43
  end
34
44
  @variants.insert(0, [I18n.t("all"), "All"])
@@ -46,8 +56,8 @@ class Admin::ImagesController < Admin::BaseController
46
56
  object.viewable = @product
47
57
  end
48
58
  end
49
-
50
- def destroy_before
59
+
60
+ def destroy_before
51
61
  @viewable = object.viewable
52
62
  end
53
63
 
@@ -2,7 +2,7 @@ class Admin::InventorySettingsController < Admin::BaseController
2
2
 
3
3
  def update
4
4
  Spree::Config.set(params[:preferences])
5
-
5
+
6
6
  respond_to do |format|
7
7
  format.html {
8
8
  redirect_to admin_inventory_settings_path
@@ -3,7 +3,7 @@ class Admin::MailSettingsController < Admin::BaseController
3
3
  def update
4
4
  Spree::Config.set(params[:preferences])
5
5
  Spree::Preferences::MailSettings.init
6
-
6
+
7
7
  respond_to do |format|
8
8
  format.html {
9
9
  redirect_to admin_mail_settings_path
@@ -20,6 +20,17 @@ class Admin::OptionTypesController < Admin::BaseController
20
20
  redirect_to selected_admin_product_option_types_url(@product)
21
21
  end
22
22
 
23
+ def update_positions
24
+ params[:positions].each do |id, index|
25
+ OptionType.update_all(['position=?', index], ['id=?', id])
26
+ end
27
+
28
+ respond_to do |format|
29
+ format.html { redirect_to admin_product_variants_url(params[:product_id]) }
30
+ format.js { render :text => 'Ok' }
31
+ end
32
+ end
33
+
23
34
  new_action.response do |wants|
24
35
  wants.html {render :action => :new, :layout => !request.xhr?}
25
36
  end
@@ -68,30 +68,26 @@ class Admin::OrdersController < Admin::BaseController
68
68
 
69
69
  def collection
70
70
  params[:search] ||= {}
71
-
72
- if params[:search].present?
73
- if params[:search].delete(:completed_at_not_null) == "1"
74
- params[:search][:completed_at_not_null] = "1"
75
- end
76
- else
77
- params[:search][:completed_at_not_null] = "1"
71
+ @show_only_completed = params[:search][:completed_at_is_not_null].present?
72
+ params[:search][:meta_sort] ||= @show_only_completed ? 'completed_at.desc' : 'created_at.desc'
73
+
74
+ @search = Order.metasearch(params[:search])
75
+
76
+ if !params[:search][:created_at_greater_than].blank?
77
+ params[:search][:created_at_greater_than] = Time.zone.parse(params[:search][:created_at_greater_than]).beginning_of_day rescue ""
78
78
  end
79
-
80
- if !params[:search][:completed_at_greater_than].blank?
81
- params[:search][:completed_at_greater_than] = Time.zone.parse(params[:search][:completed_at_greater_than]).beginning_of_day rescue ""
79
+
80
+ if !params[:search][:created_at_less_than].blank?
81
+ params[:search][:created_at_less_than] = Time.zone.parse(params[:search][:created_at_less_than]).end_of_day rescue ""
82
82
  end
83
83
 
84
- if !params[:search][:completed_at_less_than].blank?
85
- params[:search][:completed_at_less_than] = Time.zone.parse(params[:search][:completed_at_less_than]).end_of_day rescue ""
84
+ if @show_only_completed
85
+ params[:search][:completed_at_greater_than] = params[:search].delete(:created_at_greater_than)
86
+ params[:search][:completed_at_less_than] = params[:search].delete(:created_at_less_than)
86
87
  end
87
-
88
- params[:search][:order] ||= "descend_by_completed_at"
89
- @search = Order.searchlogic(params[:search])
90
-
91
- # QUERY - get per_page from form ever??? maybe push into model
92
- # @search.per_page ||= Spree::Config[:orders_per_page]
93
-
94
- @collection = @search.do_search.paginate(:include => [:user, :shipments, :payments],
88
+
89
+ @collection = Order.metasearch(params[:search]).paginate(
90
+ :include => [:user, :shipments, :payments],
95
91
  :per_page => Spree::Config[:orders_per_page],
96
92
  :page => params[:page])
97
93
  end
@@ -8,7 +8,7 @@ class Admin::OverviewController < Admin::BaseController
8
8
  #@users = User.find_with_deleted(:all, :order => 'updated_at desc')
9
9
  # going to list today's orders, yesterday's orders, older orders
10
10
  # have a filter / search at the top
11
- # @orders, @
11
+ # @orders, @
12
12
  end
13
13
 
14
14
  end
@@ -7,19 +7,19 @@ class Admin::PaymentMethodsController < Admin::BaseController
7
7
  update.wants.html { redirect_to edit_object_url }
8
8
  create.wants.html { redirect_to edit_object_url }
9
9
 
10
- private
10
+ private
11
11
  def build_object
12
12
  if params[:payment_method] && params[:payment_method][:type]
13
- @object ||= params[:payment_method][:type].constantize.send parent? ? :build : :new, object_params
13
+ @object ||= params[:payment_method][:type].constantize.send parent? ? :build : :new, object_params
14
14
  else
15
- @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
15
+ @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
16
16
  end
17
17
  end
18
-
19
- def load_data
18
+
19
+ def load_data
20
20
  @providers = Gateway.providers
21
21
  end
22
-
22
+
23
23
  def update_before
24
24
  if params[:payment_method] && params[:payment_method][:type] && @object['type'].to_s != params[:payment_method][:type]
25
25
  @object.update_attribute(:type, params[:payment_method][:type])
@@ -1,10 +1,10 @@
1
1
  class Admin::ProductGroupsController < Admin::BaseController
2
2
  resource_controller
3
-
4
- create.response do |wants|
3
+
4
+ create.response do |wants|
5
5
  wants.html { redirect_to edit_object_path }
6
6
  end
7
- update.response do |wants|
7
+ update.response do |wants|
8
8
  wants.html { redirect_to edit_object_path }
9
9
  wants.js { render :action => 'update', :layout => false}
10
10
  end
@@ -15,14 +15,14 @@ class Admin::ProductGroupsController < Admin::BaseController
15
15
  render :partial => 'preview', :layout => false
16
16
  end
17
17
 
18
-
18
+
19
19
  private
20
20
 
21
21
  # Consolidate argument arrays for nested product_scope attributes
22
22
  # Necessary for product scopes with multiple arguments
23
23
  def object_params
24
24
  if params["product_group"] and params["product_group"]["product_scopes_attributes"].is_a?(Array)
25
- params["product_group"]["product_scopes_attributes"] = params["product_group"]["product_scopes_attributes"].group_by {|a| a["id"]}.map do |scope_id, attrs|
25
+ params["product_group"]["product_scopes_attributes"] = params["product_group"]["product_scopes_attributes"].group_by {|a| a["id"]}.map do |scope_id, attrs|
26
26
  a = { "id" => scope_id, "arguments" => attrs.map{|a| a["arguments"] }.flatten }
27
27
  if name = attrs.first["name"]
28
28
  a["name"] = name
@@ -34,12 +34,11 @@ class Admin::ProductGroupsController < Admin::BaseController
34
34
  end
35
35
 
36
36
  def collection
37
- @search = ProductGroup.searchlogic(params[:search])
38
-
39
- @collection = @search.do_search.paginate(
40
- :per_page => Spree::Config[:per_page],
41
- :page => params[:page]
42
- )
37
+ params[:search] ||= {}
38
+ params[:search][:meta_sort] ||= "name.desc"
39
+ @search = ProductGroup.metasearch(params[:search])
40
+ @collection = @search.paginate( :per_page => Spree::Config[:per_page],
41
+ :page => params[:page])
43
42
  end
44
43
 
45
44
  end
@@ -1,13 +1,13 @@
1
1
  class Admin::ProductPropertiesController < Admin::BaseController
2
2
  resource_controller
3
3
  before_filter :find_properties
4
-
5
- # note: we're using attribute_fu to manage the product_properties so the products controller will be
6
- # doing most of the work
4
+
5
+ # note: we're using attribute_fu to manage the product_properties so the products controller will be
6
+ # doing most of the work
7
7
  belongs_to :product
8
-
8
+
9
9
  private
10
-
10
+
11
11
  def find_properties
12
12
  @properties = Property.all.map(&:name).join(" ")
13
13
  end
@@ -2,18 +2,26 @@ class Admin::ProductScopesController < Admin::BaseController
2
2
  helper 'admin/product_groups'
3
3
 
4
4
  resource_controller
5
-
5
+
6
6
  belongs_to :product_group
7
-
7
+
8
8
  actions :create, :destroy
9
9
 
10
- create.response do |wants|
10
+ destroy.after :update_memberships
11
+
12
+ create.response do |wants|
11
13
  wants.html { redirect_to edit_admin_product_group_path(parent_object) }
12
14
  wants.js { render :action => 'create', :layout => false}
13
15
  end
14
- destroy.response do |wants|
16
+ destroy.response do |wants|
15
17
  wants.html { redirect_to edit_admin_product_group_path(parent_object) }
16
18
  wants.js { render :action => 'destroy', :layout => false}
17
19
  end
18
20
 
21
+ private
22
+
23
+ def update_memberships
24
+ object.product_group.update_memberships
25
+ end
26
+
19
27
  end
@@ -79,26 +79,31 @@ class Admin::ProductsController < Admin::BaseController
79
79
 
80
80
  def collection
81
81
  return @collection if @collection.present?
82
- scopes = ['group_by_products_id']
83
82
 
84
83
  unless request.xhr?
85
- # Note: the SL scopes are on/off switches, so we need to select "not_deleted" explicitly if the switch is off
86
- # QUERY - better as named scope or as SL scope?
87
- if params[:search].nil? || params[:search][:deleted_at_not_null].blank?
88
- scopes << 'not_deleted'
84
+ params[:search] ||= {}
85
+ # Note: the MetaSearch scopes are on/off switches, so we need to select "not_deleted" explicitly if the switch is off
86
+ if params[:search][:deleted_at_is_null].nil?
87
+ params[:search][:deleted_at_is_null] = "1"
89
88
  end
90
89
 
91
- @search = end_of_association_chain.searchlogic(params[:search] ? params[:search].except(:deleted_at_not_null) : nil)
92
- @search.order ||= "ascend_by_name"
90
+ params[:search][:meta_sort] ||= "name.asc"
91
+ @search = end_of_association_chain.metasearch(params[:search])
93
92
 
94
- @collection = @search.do_search.instance_eval(scopes.join(".")).paginate(:include => {:variants => [:images, :option_values]},
95
- :per_page => Spree::Config[:admin_products_per_page],
96
- :page => params[:page])
93
+ pagination_options = {:include => {:variants => [:images, :option_values]},
94
+ :per_page => Spree::Config[:admin_products_per_page],
95
+ :page => params[:page]}
96
+
97
+ @collection = @search.relation.group_by_products_id.paginate(pagination_options)
97
98
  else
98
99
  includes = [{:variants => [:images, {:option_values => :option_type}]}, :master, :images]
99
100
 
100
- @collection = end_of_association_chain.where(["name LIKE ?", "%#{params[:q]}%"]).includes(includes).limit(params[:limit] || 10)
101
- @collection.concat end_of_association_chain.where(["variants.sku LIKE ?", "%#{params[:q]}%"]).includes(:variants_including_master).limit(params[:limit] || 10)
101
+ @collection = end_of_association_chain.where(["name LIKE ?", "%#{params[:q]}%"])
102
+ @collection = @collection.includes(includes).limit(params[:limit] || 10)
103
+
104
+ tmp = end_of_association_chain.where(["variants.sku LIKE ?", "%#{params[:q]}%"])
105
+ tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
106
+ @collection.concat(tmp)
102
107
 
103
108
  @collection.uniq
104
109
  end
@@ -1,25 +1,25 @@
1
1
  class Admin::PropertiesController < Admin::BaseController
2
2
  resource_controller
3
-
3
+
4
4
  before_filter :load_object, :only => :filtered
5
5
  belongs_to :product
6
-
6
+
7
7
  def filtered
8
- @properties = Property.where('lower(name) LIKE ?', "%#{params[:q].downcase}%").order(:name)
8
+ @properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
9
9
  render :template => "admin/properties/filtered.html.erb", :layout => false
10
10
  end
11
-
11
+
12
12
  new_action.response do |wants|
13
13
  wants.html {render :action => :new, :layout => !request.xhr? }
14
14
  end
15
15
 
16
16
  # redirect to index (instead of r_c default of show view)
17
- update.response do |wants|
17
+ update.response do |wants|
18
18
  wants.html {redirect_to collection_url}
19
19
  end
20
-
20
+
21
21
  # redirect to index (instead of r_c default of show view)
22
- create.response do |wants|
22
+ create.response do |wants|
23
23
  wants.html {redirect_to collection_url}
24
24
  end
25
25