spree_core 1.0.7 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/app/assets/javascripts/admin/admin.js.erb +9 -18
  2. data/app/assets/javascripts/admin/calculator.js +7 -6
  3. data/app/assets/javascripts/admin/checkouts/edit.js +2 -2
  4. data/app/assets/javascripts/admin/image_settings.js +49 -0
  5. data/app/assets/javascripts/admin/orders/edit_form.js +14 -14
  6. data/app/assets/stylesheets/admin/admin.css.erb +36 -54
  7. data/app/assets/stylesheets/store/screen.css.scss +25 -12
  8. data/app/controllers/spree/admin/base_controller.rb +3 -3
  9. data/app/controllers/spree/admin/image_settings_controller.rb +71 -0
  10. data/app/controllers/spree/admin/images_controller.rb +22 -21
  11. data/app/controllers/spree/admin/mail_methods_controller.rb +1 -1
  12. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  13. data/app/controllers/spree/admin/orders_controller.rb +13 -13
  14. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -1
  15. data/app/controllers/spree/admin/payments_controller.rb +1 -1
  16. data/app/controllers/spree/admin/product_properties_controller.rb +3 -4
  17. data/app/controllers/spree/admin/products_controller.rb +49 -47
  18. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  19. data/app/controllers/spree/admin/prototypes_controller.rb +12 -6
  20. data/app/controllers/spree/admin/reports_controller.rb +15 -16
  21. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  22. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  23. data/app/controllers/spree/admin/shipments_controller.rb +0 -3
  24. data/app/controllers/spree/admin/states_controller.rb +9 -9
  25. data/app/controllers/spree/admin/users_controller.rb +18 -42
  26. data/app/controllers/spree/admin/variants_controller.rb +22 -21
  27. data/app/controllers/spree/admin/zones_controller.rb +11 -11
  28. data/app/controllers/spree/content_controller.rb +1 -1
  29. data/app/controllers/spree/locale_controller.rb +2 -2
  30. data/app/controllers/spree/orders_controller.rb +4 -6
  31. data/app/controllers/spree/products_controller.rb +1 -1
  32. data/app/controllers/spree/states_controller.rb +4 -7
  33. data/app/helpers/spree/admin/base_helper.rb +4 -0
  34. data/app/helpers/spree/admin/navigation_helper.rb +4 -16
  35. data/app/helpers/spree/base_helper.rb +22 -3
  36. data/app/models/spree/activator.rb +4 -1
  37. data/app/models/spree/address.rb +45 -45
  38. data/app/models/spree/adjustment.rb +4 -4
  39. data/app/models/spree/app_configuration.rb +12 -0
  40. data/app/models/spree/calculator/default_tax.rb +1 -3
  41. data/app/models/spree/calculator/flat_percent_item_total.rb +0 -2
  42. data/app/models/spree/calculator/flat_rate.rb +0 -3
  43. data/app/models/spree/calculator/flexi_rate.rb +1 -3
  44. data/app/models/spree/calculator/per_item.rb +1 -6
  45. data/app/models/spree/calculator/price_sack.rb +0 -2
  46. data/app/models/spree/country.rb +1 -1
  47. data/app/models/spree/creditcard.rb +9 -10
  48. data/app/models/spree/gateway.rb +0 -2
  49. data/app/models/spree/image.rb +18 -2
  50. data/app/models/spree/inventory_unit.rb +4 -2
  51. data/app/models/spree/mail_method.rb +1 -6
  52. data/app/models/spree/option_type.rb +3 -1
  53. data/app/models/spree/order.rb +68 -62
  54. data/app/models/spree/payment.rb +1 -1
  55. data/app/models/spree/payment_method.rb +0 -6
  56. data/app/models/spree/product/scopes.rb +44 -44
  57. data/app/models/spree/product.rb +44 -26
  58. data/app/models/spree/product_property.rb +0 -2
  59. data/app/models/spree/property.rb +0 -16
  60. data/app/models/spree/prototype.rb +0 -1
  61. data/app/models/spree/return_authorization.rb +0 -2
  62. data/app/models/spree/shipment.rb +2 -3
  63. data/app/models/spree/shipping_category.rb +0 -2
  64. data/app/models/spree/shipping_method.rb +1 -2
  65. data/app/models/spree/shipping_rate.rb +9 -0
  66. data/app/models/spree/state.rb +10 -2
  67. data/app/models/spree/{state_event.rb → state_change.rb} +1 -4
  68. data/app/models/spree/tax_rate.rb +3 -3
  69. data/app/models/spree/taxon.rb +1 -6
  70. data/app/models/spree/taxonomy.rb +3 -6
  71. data/app/models/spree/user.rb +1 -0
  72. data/app/models/spree/variant.rb +3 -4
  73. data/app/models/spree/zone.rb +0 -10
  74. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +1 -1
  75. data/app/views/spree/admin/configurations/index.html.erb +4 -0
  76. data/app/views/spree/admin/image_settings/edit.html.erb +91 -0
  77. data/app/views/spree/admin/image_settings/show.html.erb +11 -0
  78. data/app/views/spree/admin/images/index.html.erb +3 -3
  79. data/app/views/spree/admin/mail_methods/_form.html.erb +1 -1
  80. data/app/views/spree/admin/mail_methods/index.html.erb +1 -1
  81. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  82. data/app/views/spree/admin/option_types/index.html.erb +1 -1
  83. data/app/views/spree/admin/option_types/new.js.erb +1 -1
  84. data/app/views/spree/admin/orders/_form.html.erb +3 -5
  85. data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
  86. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  87. data/app/views/spree/admin/orders/history.html.erb +2 -2
  88. data/app/views/spree/admin/orders/index.html.erb +19 -19
  89. data/app/views/spree/admin/payment_methods/_form.html.erb +1 -1
  90. data/app/views/spree/admin/payment_methods/index.html.erb +1 -3
  91. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  92. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  93. data/app/views/spree/admin/products/_form.html.erb +30 -27
  94. data/app/views/spree/admin/products/index.html.erb +9 -9
  95. data/app/views/spree/admin/products/new.html.erb +28 -4
  96. data/app/views/spree/admin/products/new.js.erb +1 -1
  97. data/app/views/spree/admin/properties/index.html.erb +1 -1
  98. data/app/views/spree/admin/properties/new.js.erb +1 -1
  99. data/app/views/spree/admin/prototypes/index.html.erb +1 -1
  100. data/app/views/spree/admin/prototypes/new.js.erb +1 -1
  101. data/app/views/spree/admin/prototypes/show.html.erb +42 -0
  102. data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
  103. data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
  104. data/app/views/spree/admin/shared/_calculator_fields.html.erb +2 -2
  105. data/app/views/spree/admin/shared/_head.html.erb +3 -3
  106. data/app/views/spree/admin/shared/_order_details.html.erb +1 -1
  107. data/app/views/spree/admin/shared/_order_tabs.html.erb +6 -6
  108. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +0 -1
  109. data/app/views/spree/admin/shared/_report_criteria.html.erb +3 -3
  110. data/app/views/spree/admin/shared/_tabs.html.erb +1 -1
  111. data/app/views/spree/admin/shared/_update_order_state.js +5 -4
  112. data/app/views/spree/admin/shipments/index.html.erb +1 -1
  113. data/app/views/spree/admin/shipping_categories/index.html.erb +1 -1
  114. data/app/views/spree/admin/shipping_methods/index.html.erb +1 -1
  115. data/app/views/spree/admin/states/_state_list.html.erb +1 -1
  116. data/app/views/spree/admin/states/new.js.erb +1 -1
  117. data/app/views/spree/admin/tax_categories/index.html.erb +2 -2
  118. data/app/views/spree/admin/tax_rates/index.html.erb +2 -2
  119. data/app/views/spree/admin/taxonomies/_list.html.erb +1 -1
  120. data/app/views/spree/admin/trackers/_form.html.erb +1 -1
  121. data/app/views/spree/admin/trackers/index.html.erb +1 -1
  122. data/app/views/spree/admin/users/_form.html.erb +1 -16
  123. data/app/views/spree/admin/users/index.html.erb +3 -4
  124. data/app/views/spree/admin/variants/index.html.erb +2 -2
  125. data/app/views/spree/admin/variants/new.js.erb +1 -1
  126. data/app/views/spree/admin/zones/index.html.erb +1 -1
  127. data/app/views/spree/checkout/_address.html.erb +1 -1
  128. data/app/views/spree/checkout/edit.html.erb +1 -1
  129. data/app/views/spree/checkout/registration.html.erb +2 -2
  130. data/app/views/spree/order_mailer/confirm_email.text.erb +3 -3
  131. data/app/views/spree/orders/show.html.erb +2 -2
  132. data/app/views/spree/products/_cart_form.html.erb +1 -2
  133. data/app/views/spree/products/_image.html.erb +1 -1
  134. data/app/views/spree/products/show.html.erb +3 -3
  135. data/app/views/spree/shared/_filters.html.erb +26 -24
  136. data/app/views/spree/shared/_google_analytics.html.erb +26 -26
  137. data/app/views/spree/shared/_products.html.erb +2 -2
  138. data/app/views/spree/shared/_search.html.erb +1 -1
  139. data/app/views/spree/shared/_store_menu.html.erb +1 -1
  140. data/app/views/spree/states/index.js.erb +1 -1
  141. data/config/initializers/rails_3_1.rb +3 -3
  142. data/config/locales/en.yml +40 -35
  143. data/config/routes.rb +5 -13
  144. data/db/migrate/20101026184714_migrate_transactions_to_payment_state.rb +4 -4
  145. data/db/migrate/20111007143030_namespace_top_level_models.rb +0 -3
  146. data/db/migrate/20120203001428_rename_state_events_to_state_changes.rb +9 -0
  147. data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +35 -0
  148. data/lib/generators/spree/dummy/templates/rails/database.yml +48 -20
  149. data/lib/generators/spree/install/install_generator.rb +17 -1
  150. data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
  151. data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
  152. data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
  153. data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
  154. data/lib/generators/spree/sandbox/sandbox_generator.rb +9 -2
  155. data/lib/spree/core/calculated_adjustments.rb +29 -34
  156. data/lib/spree/core/controller_helpers.rb +36 -34
  157. data/lib/spree/core/custom_fixtures.rb +1 -1
  158. data/lib/spree/core/delegate_belongs_to.rb +22 -24
  159. data/lib/spree/core/engine.rb +3 -3
  160. data/lib/spree/core/environment_extension.rb +12 -15
  161. data/lib/spree/core/mail_settings.rb +1 -1
  162. data/lib/spree/core/permalinks.rb +24 -16
  163. data/lib/spree/core/preference_rescue.rb +1 -1
  164. data/lib/spree/core/respond_with.rb +13 -8
  165. data/lib/spree/core/responder.rb +1 -2
  166. data/lib/spree/core/search/base.rb +36 -19
  167. data/lib/spree/core/ssl_requirement.rb +18 -10
  168. data/lib/spree/core/testing_support/common_rake.rb +1 -1
  169. data/lib/spree/core/testing_support/factories/product_factory.rb +9 -9
  170. data/lib/spree/core/testing_support/factories/role_factory.rb +1 -1
  171. data/lib/spree/core/testing_support/factories/shipping_category_factory.rb +1 -1
  172. data/lib/spree/core/testing_support/factories/shipping_method_factory.rb +3 -3
  173. data/lib/spree/core/testing_support/factories/user_factory.rb +1 -1
  174. data/lib/spree/core/testing_support/factories/zone_factory.rb +4 -2
  175. data/lib/spree/core/validators/email.rb +23 -0
  176. data/lib/spree/core/version.rb +1 -1
  177. data/lib/spree/core.rb +2 -2
  178. data/lib/spree/product_filters.rb +10 -19
  179. data/lib/tasks/core.rake +1 -1
  180. data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css.erb +5 -5
  181. data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +1 -1
  182. metadata +68 -140
  183. data/app/assets/images/noimage/large.png +0 -0
  184. data/app/controllers/spree/admin/product_groups_controller.rb +0 -49
  185. data/app/controllers/spree/admin/product_scopes_controller.rb +0 -39
  186. data/app/helpers/spree/admin/product_groups_helper.rb +0 -14
  187. data/app/helpers/spree/admin/product_properties_helper.rb +0 -24
  188. data/app/models/spree/product_group.rb +0 -200
  189. data/app/models/spree/product_scope.rb +0 -79
  190. data/app/views/spree/admin/banners/_gateway.html.erb +0 -14
  191. data/app/views/spree/admin/product_groups/_preview.html.erb +0 -33
  192. data/app/views/spree/admin/product_groups/_product_scope.html.erb +0 -24
  193. data/app/views/spree/admin/product_groups/edit.html.erb +0 -59
  194. data/app/views/spree/admin/product_groups/index.html.erb +0 -37
  195. data/app/views/spree/admin/product_groups/new.html.erb +0 -12
  196. data/app/views/spree/admin/product_groups/show.html.erb +0 -32
  197. data/app/views/spree/admin/product_scopes/create.js.erb +0 -6
  198. data/app/views/spree/admin/product_scopes/destroy.js.erb +0 -3
  199. data/app/views/spree/admin/product_scopes/new.html.erb +0 -1
  200. data/app/views/spree/admin/shared/_group_from_products_form.html.erb +0 -12
  201. data/db/migrate/20091012120519_product_groups_and_scopes.rb +0 -18
  202. data/db/migrate/20100126103714_create_products_product_groups.rb +0 -8
  203. data/db/migrate/20100306153445_fix_by_popularity.rb +0 -9
  204. data/db/migrate/20120523061241_convert_sales_tax_to_default_tax.rb +0 -9
  205. data/lib/spree/core/testing_support/factories/product_group_factory.rb +0 -5
  206. data/lib/spree/core/testing_support/factories/product_scope_factory.rb +0 -7
  207. data/lib/spree/core/theme_support/hook_listener.rb +0 -145
  208. data/lib/spree/core/theme_support.rb +0 -1
  209. data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css +0 -57
@@ -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_order_payment_path(@order) } }
49
+ respond_with(@payment) { |format| format.html { redirect_to new_admin_payment_path(@order) } }
50
50
  end
51
51
  end
52
52
 
@@ -5,10 +5,9 @@ module Spree
5
5
  before_filter :find_properties
6
6
 
7
7
  private
8
-
9
- def find_properties
10
- @properties = Spree::Property.all.map(&:name)
11
- end
8
+ def find_properties
9
+ @properties = Spree::Property.pluck(:name)
10
+ end
12
11
  end
13
12
  end
14
13
  end
@@ -5,6 +5,7 @@ module Spree
5
5
 
6
6
  before_filter :check_json_authenticity, :only => :index
7
7
  before_filter :load_data, :except => :index
8
+ create.before :create_before
8
9
  update.before :update_before
9
10
 
10
11
  def show
@@ -48,67 +49,68 @@ module Spree
48
49
 
49
50
  protected
50
51
 
51
- def find_resource
52
- Product.find_by_permalink!(params[:id])
53
- end
52
+ def find_resource
53
+ Product.find_by_permalink!(params[:id])
54
+ end
54
55
 
55
- def location_after_save
56
- edit_admin_product_url(@product)
57
- end
56
+ def location_after_save
57
+ edit_admin_product_url(@product)
58
+ end
58
59
 
59
- # Allow different formats of json data to suit different ajax calls
60
- def json_data
61
- json_format = params[:json_format] or 'default'
62
- case json_format
63
- when 'basic'
64
- collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json
65
- else
66
- collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},
67
- :images => {:only => [:id], :methods => :mini_url}}},
68
- :images => {:only => [:id], :methods => :mini_url}, :master => {}})
60
+ # Allow different formats of json data to suit different ajax calls
61
+ def json_data
62
+ json_format = params[:json_format] or 'default'
63
+ case json_format
64
+ when 'basic'
65
+ collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json
66
+ else
67
+ collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},
68
+ :images => {:only => [:id], :methods => :mini_url}}},
69
+ :images => {:only => [:id], :methods => :mini_url}, :master => {}})
70
+ end
69
71
  end
70
- end
71
72
 
72
- def load_data
73
- @tax_categories = TaxCategory.order(:name)
74
- @shipping_categories = ShippingCategory.order(:name)
75
- end
73
+ def load_data
74
+ @tax_categories = TaxCategory.order(:name)
75
+ @shipping_categories = ShippingCategory.order(:name)
76
+ end
76
77
 
77
- def collection
78
- return @collection if @collection.present?
78
+ def collection
79
+ return @collection if @collection.present?
79
80
 
80
- unless request.xhr?
81
- params[:search] ||= {}
82
- # Note: the MetaSearch scopes are on/off switches, so we need to select "not_deleted" explicitly if the switch is off
83
- if params[:search][:deleted_at_is_null].nil?
84
- params[:search][:deleted_at_is_null] = "1"
85
- end
81
+ unless request.xhr?
82
+ params[:q] ||= {}
83
+ params[:q][:deleted_at_null] ||= "1"
86
84
 
87
- params[:search][:meta_sort] ||= "name.asc"
88
- @search = super.metasearch(params[:search])
85
+ params[:q][:s] ||= "name asc"
89
86
 
90
- @collection = @search.relation.group_by_products_id.includes([:master, {:variants => [:images, :option_values]}]).page(params[:page]).per(Spree::Config[:admin_products_per_page])
91
- else
92
- includes = [{:variants => [:images, {:option_values => :option_type}]}, :master, :images]
87
+ @search = super.search(params[:q])
88
+ @collection = @search.result.group_by_products_id.includes([:master, {:variants => [:images, :option_values]}]).page(params[:page]).per(Spree::Config[:admin_products_per_page])
89
+ else
90
+ includes = [{:variants => [:images, {:option_values => :option_type}]}, {:master => :images}]
93
91
 
94
- @collection = super.where(["name #{LIKE} ?", "%#{params[:q]}%"])
95
- @collection = @collection.includes(includes).limit(params[:limit] || 10)
92
+ @collection = super.where(["name #{LIKE} ?", "%#{params[:q]}%"])
93
+ @collection = @collection.includes(includes).limit(params[:limit] || 10)
96
94
 
97
- tmp = super.where(["#{Variant.table_name}.sku #{LIKE} ?", "%#{params[:q]}%"])
98
- tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
99
- @collection.concat(tmp)
95
+ tmp = super.where(["#{Variant.table_name}.sku #{LIKE} ?", "%#{params[:q]}%"])
96
+ tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
97
+ @collection.concat(tmp)
100
98
 
101
- @collection.uniq
102
- end
99
+ @collection
100
+ end
103
101
 
104
- end
102
+ end
105
103
 
106
- def update_before
107
- # note: we only reset the product properties if we're receiving a post from the form on that tab
108
- return unless params[:clear_product_properties]
109
- params[:product] ||= {}
110
- end
104
+ def create_before
105
+ return if params[:product][:prototype_id].blank?
106
+ @prototype = Spree::Prototype.find(params[:product][:prototype_id])
107
+ end
111
108
 
109
+ def update_before
110
+ # note: we only reset the product properties if we're receiving a post from the form on that tab
111
+ return unless params[:clear_product_properties]
112
+ params[:product] ||= {}
113
+ end
112
114
  end
113
115
  end
114
116
  end
@@ -6,7 +6,7 @@ module Spree
6
6
  def filtered
7
7
  @properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
8
8
  respond_with(@properties) do |format|
9
- format.html { render :template => "spree/admin/properties/filtered.html.erb", :layout => false }
9
+ format.html { render :template => "spree/admin/properties/filtered", :formats => [:html], :handlers => [:erb], :layout => false }
10
10
  end
11
11
  end
12
12
  end
@@ -3,7 +3,13 @@ module Spree
3
3
  class PrototypesController < ResourceController
4
4
  after_filter :set_habtm_associations, :only => [:create, :update]
5
5
 
6
- helper 'spree/admin/product_properties'
6
+ def show
7
+ if request.xhr?
8
+ render :layout => false
9
+ else
10
+ redirect_to admin_prototypes_path
11
+ end
12
+ end
7
13
 
8
14
  def available
9
15
  @prototypes = Prototype.order('name asc')
@@ -21,11 +27,11 @@ module Spree
21
27
  end
22
28
 
23
29
  private
24
-
25
- def set_habtm_associations
26
- @prototype.property_ids = params[:property][:id] if params[:property]
27
- @prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
28
- end
30
+
31
+ def set_habtm_associations
32
+ @prototype.property_ids = params[:property][:id] if params[:property]
33
+ @prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -14,32 +14,31 @@ module Spree
14
14
  end
15
15
 
16
16
  def sales_total
17
- params[:search] = {} unless params[:search]
17
+ params[:q] = {} unless params[:q]
18
18
 
19
- if params[:search][:created_at_greater_than].blank?
20
- params[:search][:created_at_greater_than] = Time.zone.now.beginning_of_month
19
+ if params[:q][:created_at_gt].blank?
20
+ params[:q][:created_at_gt] = Time.zone.now.beginning_of_month
21
21
  else
22
- params[:search][:created_at_greater_than] = Time.zone.parse(params[:search][:created_at_greater_than]).beginning_of_day rescue Time.zone.now.beginning_of_month
22
+ params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue Time.zone.now.beginning_of_month
23
23
  end
24
24
 
25
- if params[:search] && !params[:search][:created_at_less_than].blank?
26
- params[:search][:created_at_less_than] =
27
- Time.zone.parse(params[:search][:created_at_less_than]).end_of_day rescue ""
25
+ if params[:q] && !params[:q][:created_at_lt].blank?
26
+ params[:q][:created_at_lt] = Time.zone.parse(params[:q][:created_at_lt]).end_of_day rescue ""
28
27
  end
29
28
 
30
- if params[:search].delete(:completed_at_is_not_null) == "1"
31
- params[:search][:completed_at_is_not_null] = true
29
+ if params[:q].delete(:completed_at_not_null) == "1"
30
+ params[:q][:completed_at_not_null] = true
32
31
  else
33
- params[:search][:completed_at_is_not_null] = false
32
+ params[:q][:completed_at_not_null] = false
34
33
  end
35
34
 
36
- params[:search][:meta_sort] ||= "created_at.desc"
35
+ params[:q][:meta_sort] ||= "created_at.desc"
37
36
 
38
- @search = Order.metasearch(params[:search])
39
- @orders = @search
40
- @item_total = @search.sum(:item_total)
41
- @adjustment_total = @search.sum(:adjustment_total)
42
- @sales_total = @search.sum(:total)
37
+ @search = Order.complete.search(params[:q])
38
+ @orders = @search.result
39
+ @item_total = @orders.sum(:item_total)
40
+ @adjustment_total = @orders.sum(:adjustment_total)
41
+ @sales_total = @orders.sum(:total)
43
42
 
44
43
  respond_with
45
44
  end
@@ -34,7 +34,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
34
34
  end
35
35
  else
36
36
  invoke_callbacks(:update, :fails)
37
- respond_with(@object, :location => [:admin, @object])
37
+ respond_with(@object)
38
38
  end
39
39
  end
40
40
 
@@ -14,7 +14,7 @@ module Spree
14
14
 
15
15
  protected
16
16
  def associate_inventory_units
17
- params[:return_quantity].each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }
17
+ (params[:return_quantity] || []).each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }
18
18
  end
19
19
  end
20
20
  end
@@ -14,9 +14,6 @@ module Spree
14
14
 
15
15
  def new
16
16
  build_shipment
17
- @shipment.address ||= @order.ship_address
18
- @shipment.address ||= Address.new(:country_id => Spree::Config[:default_country_id])
19
- @shipment.shipping_method = @order.shipping_method
20
17
  respond_with(@shipment)
21
18
  end
22
19
 
@@ -13,17 +13,17 @@ module Spree
13
13
 
14
14
  protected
15
15
 
16
- def location_after_save
17
- admin_country_states_url(@country)
18
- end
16
+ def location_after_save
17
+ admin_country_states_url(@country)
18
+ end
19
19
 
20
- def collection
21
- super.order(:name)
22
- end
20
+ def collection
21
+ super.order(:name)
22
+ end
23
23
 
24
- def load_data
25
- @countries = Country.order(:name)
26
- end
24
+ def load_data
25
+ @countries = Country.order(:name)
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -4,11 +4,6 @@ module Spree
4
4
 
5
5
  # http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
6
6
  before_filter :check_json_authenticity, :only => :index
7
- before_filter :load_roles, :only => [:edit, :new, :update, :create]
8
-
9
- create.after :save_user_roles
10
- update.before :save_user_roles
11
- update.after :sign_in_if_change_own_password
12
7
 
13
8
  def index
14
9
  respond_with(@collection) do |format|
@@ -25,35 +20,25 @@ module Spree
25
20
  end
26
21
 
27
22
  protected
28
- def collection
29
- return @collection if @collection.present?
30
- unless request.xhr?
31
- @search = Spree::User.registered.metasearch(params[:search])
32
- @collection = @search.relation.page(params[:page]).per(Spree::Config[:admin_products_per_page])
33
- else
34
- #disabling proper nested include here due to rails 3.1 bug
35
- #@collection = User.includes(:bill_address => [:state, :country], :ship_address => [:state, :country]).
36
- @collection = Spree::User.includes(:bill_address, :ship_address).
37
- where("spree_users.email #{LIKE} :search
38
- OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
39
- OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
40
- OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)
41
- OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)",
42
- { :search => "#{params[:q].strip}%" }).
43
- limit(params[:limit] || 100)
44
- end
45
- end
46
23
 
47
- def save_user_roles
48
- return unless params[:user]
49
- return unless @user.respond_to?(:roles) # since roles are technically added by the auth module
50
- @user.roles.delete_all
51
- params[:user][:role] ||= {}
52
- Role.all.each { |role|
53
- @user.roles << role unless params[:user][:role][role.name].blank?
54
- }
55
- params[:user].delete(:role)
56
- end
24
+ def collection
25
+ return @collection if @collection.present?
26
+ unless request.xhr?
27
+ @search = Spree::User.registered.search(params[:q])
28
+ @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
29
+ else
30
+ #disabling proper nested include here due to rails 3.1 bug
31
+ #@collection = User.includes(:bill_address => [:state, :country], :ship_address => [:state, :country]).
32
+ @collection = Spree::User.includes(:bill_address, :ship_address).
33
+ where("spree_users.email #{LIKE} :search
34
+ OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
35
+ OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
36
+ OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)
37
+ OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)",
38
+ { :search => "#{params[:q].strip}%" }).
39
+ limit(params[:limit] || 100)
40
+ end
41
+ end
57
42
 
58
43
  private
59
44
 
@@ -78,15 +63,6 @@ module Spree
78
63
  end
79
64
  end
80
65
 
81
- def load_roles
82
- @roles = Role.all
83
- end
84
-
85
- def sign_in_if_change_own_password
86
- if current_user == @user && @user.password.present?
87
- sign_in(@user, :event => :authentication, :bypass => true)
88
- end
89
- end
90
66
  end
91
67
  end
92
68
  end
@@ -42,34 +42,35 @@ module Spree
42
42
  end
43
43
 
44
44
  protected
45
- def create_before
46
- option_values = params[:new_variant]
47
- option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
48
- @object.save
49
- end
45
+
46
+ def create_before
47
+ option_values = params[:new_variant]
48
+ option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
49
+ @object.save
50
+ end
50
51
 
51
52
 
52
- def new_before
53
- @object.attributes = @object.product.master.attributes.except('id', 'created_at', 'deleted_at',
54
- 'sku', 'is_master', 'count_on_hand')
55
- end
53
+ def new_before
54
+ @object.attributes = @object.product.master.attributes.except('id', 'created_at', 'deleted_at',
55
+ 'sku', 'is_master', 'count_on_hand')
56
+ end
56
57
 
57
- def collection
58
- @deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
58
+ def collection
59
+ @deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
59
60
 
60
- if @deleted.blank?
61
- @collection ||= super
62
- else
63
- @collection ||= Variant.where(:product_id => parent.id).deleted
61
+ if @deleted.blank?
62
+ @collection ||= super
63
+ else
64
+ @collection ||= Variant.where(:product_id => parent.id).deleted
65
+ end
66
+ @collection
64
67
  end
65
- @collection
66
- end
67
68
 
68
- def json_data
69
- ( parent.variants.presence || [parent.master] ).map do |v|
70
- { :label => v.options_text.presence || v.name, :id => v.id }
69
+ def json_data
70
+ ( parent.variants.presence || [parent.master] ).map do |v|
71
+ { :label => v.options_text.presence || v.name, :id => v.id }
72
+ end
71
73
  end
72
- end
73
74
 
74
75
  end
75
76
  end
@@ -10,18 +10,18 @@ module Spree
10
10
 
11
11
  protected
12
12
 
13
- def collection
14
- params[:search] ||= {}
15
- params[:search][:meta_sort] ||= "ascend_by_name"
16
- @search = super.metasearch(params[:search])
17
- @zones = @search.relation.page(params[:page]).per(Spree::Config[:orders_per_page])
18
- end
13
+ def collection
14
+ params[:q] ||= {}
15
+ params[:q][:meta_sort] ||= "ascend_by_name"
16
+ @search = super.search(params[:q])
17
+ @zones = @search.result.page(params[:page]).per(Spree::Config[:orders_per_page])
18
+ end
19
19
 
20
- def load_data
21
- @countries = Country.order(:name)
22
- @states = State.order(:name)
23
- @zones = Zone.order(:name)
24
- end
20
+ def load_data
21
+ @countries = Country.order(:name)
22
+ @states = State.order(:name)
23
+ @zones = Zone.order(:name)
24
+ end
25
25
  end
26
26
  end
27
27
  end
@@ -16,7 +16,7 @@ module Spree
16
16
 
17
17
  def cvv
18
18
  respond_with do |format|
19
- format.html { render 'cvv', :layout => false }
19
+ format.html { render 'cvv', :layout => false }
20
20
  end
21
21
  end
22
22
  end
@@ -4,8 +4,8 @@ module Spree
4
4
  if request.referer && request.referer.starts_with?('http://' + request.host)
5
5
  session['user_return_to'] = request.referer
6
6
  end
7
- if params[:locale] && I18n.available_locales.map(&:to_s).include?(params[:locale])
8
- session[:locale] = I18n.locale = params[:locale]
7
+ if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
8
+ session[:locale] = I18n.locale = params[:locale].to_sym
9
9
  flash.notice = t(:locale_changed)
10
10
  else
11
11
  flash[:error] = t(:locale_not_changed)
@@ -13,7 +13,7 @@ module Spree
13
13
  def update
14
14
  @order = current_order
15
15
  if @order.update_attributes(params[:order])
16
- @order.line_items = @order.line_items.select { |li| li.quantity > 0 }
16
+ @order.line_items = @order.line_items.select {|li| li.quantity > 0 }
17
17
  fire_event('spree.order.contents_changed')
18
18
  respond_with(@order) { |format| format.html { redirect_to cart_path } }
19
19
  else
@@ -63,10 +63,8 @@ module Spree
63
63
  redirect_to spree.cart_path
64
64
  end
65
65
 
66
- private
67
-
68
- def accurate_title
69
- @order && @order.completed? ? "#{Order.model_name.human} #{@order.number}" : t(:shopping_cart)
70
- end
66
+ def accurate_titles
67
+ @order && @order.completed? ? "#{Order.model_name.human} #{@order.number}" : t(:shopping_cart)
68
+ end
71
69
  end
72
70
  end
@@ -13,7 +13,7 @@ module Spree
13
13
  end
14
14
 
15
15
  def show
16
- @product = Product.active.find_by_permalink!(params[:id])
16
+ @product = Product.find_by_permalink!(params[:id])
17
17
  return unless @product
18
18
 
19
19
  @variants = Variant.active.includes([:option_values, :images]).where(:product_id => @product.id)
@@ -2,15 +2,12 @@ module Spree
2
2
  class StatesController < BaseController
3
3
  ssl_allowed :index
4
4
 
5
+ respond_to :js
6
+
5
7
  def index
6
- # table of {country.id => [ state.id , state.name ]}, arrays sorted by name
7
- # blank is added elsewhere, if needed
8
8
  # we return ALL known information, since billing country isn't restricted
9
- # by shipping country
10
- @state_info = Hash.new { |h, k| h[k] = [] }
11
- Spree::State.order('name ASC').each { |state|
12
- @state_info[state.country_id.to_s].push [state.id, state.name]
13
- }
9
+ # by shipping country
10
+ respond_with @state_info = Spree::State.states_group_by_country_id.to_json
14
11
  end
15
12
  end
16
13
  end
@@ -198,6 +198,10 @@ module Spree
198
198
  f.hidden_field(:_destroy) + link_to_with_icon(:delete, name, '#', :class => 'remove_fields')
199
199
  end
200
200
 
201
+ def spree_dom_id(record)
202
+ dom_id(record, 'spree')
203
+ end
204
+
201
205
  private
202
206
  def attribute_name_for(field_name)
203
207
  field_name.gsub(' ', '_').downcase
@@ -63,7 +63,7 @@ module Spree
63
63
  options.reverse_merge! :caption => t(:are_you_sure)
64
64
  options.reverse_merge! :title => t(:confirm_delete)
65
65
  options.reverse_merge! :dataType => 'script'
66
- options.reverse_merge! :success => "function(r){ $('##{dom_id resource}').fadeOut('hide'); }"
66
+ options.reverse_merge! :success => "function(r){ $('##{spree_dom_id resource}').fadeOut('hide'); }"
67
67
  options.reverse_merge! :error => "function(jqXHR, textStatus, errorThrown){ show_flash_error(jqXHR.responseText); }"
68
68
  options.reverse_merge! :name => icon('delete') + ' ' + t(:delete)
69
69
 
@@ -109,15 +109,15 @@ module Spree
109
109
  end
110
110
 
111
111
  def button(text, icon_name = nil, button_type = 'submit', options={})
112
- content_tag('button', content_tag('span', icon(icon_name) + ' ' + text), options.merge(:type => button_type))
112
+ button_tag(content_tag('span', icon(icon_name) + ' ' + text), options.merge(:type => button_type))
113
113
  end
114
114
 
115
115
  def button_link_to(text, url, html_options = {})
116
116
  if (html_options[:method] &&
117
117
  html_options[:method].to_s.downcase != 'get' &&
118
118
  !html_options[:remote])
119
- form_tag(url, :method => html_options[:method]) do
120
- button(text, html_options[:icon])
119
+ form_tag(url, :method => html_options.delete(:method)) do
120
+ button(text, html_options.delete(:icon), nil, html_options)
121
121
  end
122
122
  else
123
123
  if html_options['data-update'].nil? && html_options[:remote]
@@ -133,18 +133,6 @@ module Spree
133
133
  link_to_function(text_for_button_link(text, html_options), function, html_options_for_button_link(html_options))
134
134
  end
135
135
 
136
- # RAILS 3 TODO - no longer needed
137
- # def button_link_to_remote(text, url, html_options = {})
138
- # html_options.reverse_merge! :remote => true
139
- # link_to(text_for_button_link(text, html_options), url, html_options_for_button_link(html_options))
140
- # end
141
- #
142
- # def link_to_remote(name, options = {}, html_options = {})
143
- # options[:before] ||= "jQuery(this).parent().hide(); jQuery('#busy_indicator').show();"
144
- # options[:complete] ||= "jQuery('#busy_indicator').hide()"
145
- # link_to_function(name, remote_function(options), html_options || options.delete(:html))
146
- # end
147
-
148
136
  def text_for_button_link(text, html_options)
149
137
  s = ''
150
138
  if html_options[:icon]