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
@@ -1,7 +1,19 @@
1
1
  module Spree
2
2
  module BaseHelper
3
+
4
+ # Defined because Rails' current_page? helper is not working when Spree is mounted at root.
5
+ def current_spree_page?(url)
6
+ path = request.fullpath.gsub(/^\/\//, '/')
7
+ if url.is_a?(String)
8
+ return path == url
9
+ elsif url.is_a?(Hash)
10
+ return path == spree.url_for(url)
11
+ end
12
+ return false
13
+ end
14
+
3
15
  def link_to_cart(text = nil)
4
- return "" if current_page?(cart_path)
16
+ return "" if current_spree_page?(cart_path)
5
17
 
6
18
  text = text ? h(text) : t('cart')
7
19
  css_class = nil
@@ -36,7 +48,6 @@ module Spree
36
48
 
37
49
  # human readable list of variant options
38
50
  def variant_options(v, allow_back_orders = Spree::Config[:allow_backorders], include_style = true)
39
- ActiveSupport::Deprecation.warn('variant_options method is deprecated, and will be removed in 0.80.0', caller)
40
51
  list = v.options_text
41
52
 
42
53
  # We shouldn't show out of stock if the product is infact in stock
@@ -110,7 +121,7 @@ module Spree
110
121
  crumbs << content_tag(:li, content_tag(:span, t(:products)))
111
122
  end
112
123
  crumb_list = content_tag(:ul, raw(crumbs.flatten.map{|li| li.mb_chars}.join), :class => 'inline')
113
- content_tag(:div, crumb_list, :id => 'breadcrumbs')
124
+ content_tag(:nav, crumb_list, :id => 'breadcrumbs')
114
125
  end
115
126
 
116
127
  def taxons_tree(root_taxon, current_taxon, max_level = 1)
@@ -159,5 +170,13 @@ module Spree
159
170
  return current_order.item_count
160
171
  end
161
172
  end
173
+
174
+ def gem_available?(name)
175
+ Gem::Specification.find_by_name(name)
176
+ rescue Gem::LoadError
177
+ false
178
+ rescue
179
+ Gem.available?(name)
180
+ end
162
181
  end
163
182
  end
@@ -13,7 +13,10 @@ module Spree
13
13
  end
14
14
 
15
15
  scope :event_name_starts_with, lambda{ |name| where('event_name LIKE ?', "#{name}%") }
16
- scope :active, where('(starts_at IS NULL OR starts_at < ?) AND (expires_at IS NULL OR expires_at > ?)', Time.now, Time.now)
16
+
17
+ def self.active
18
+ where('(starts_at IS NULL OR starts_at < ?) AND (expires_at IS NULL OR expires_at > ?)', Time.now, Time.now)
19
+ end
17
20
 
18
21
  def activate(payload)
19
22
  end
@@ -23,49 +23,9 @@ module Spree
23
23
  end
24
24
  end
25
25
 
26
- def state_validate
27
- #skip state validation without country (also required)
28
- #or when disabled by perfernce
29
- return if self.country_id.blank? || !Spree::Config[:address_requires_state]
30
-
31
- #ensure associated state belongs to country
32
- if self.state_id.present?
33
- if self.state.country_id == self.country_id
34
- self.state_name = nil #not required as we have a valid state and country combo
35
- else
36
- if self.state_name.present?
37
-
38
- self.state_id = nil
39
- else
40
- errors.add(:state, :invalid)
41
- end
42
- end
43
- end
44
-
45
- #ensure state_name belongs to country without states, or that it matches a predefined state name/abbr
46
- if self.state_name.present?
47
- if country.states.present?
48
- states = country.states.find_all_by_name_or_abbr(self.state_name)
49
-
50
- if states.size == 1
51
- self.state = states.first
52
- self.state_name = nil
53
- else
54
- errors.add(:state, :invalid)
55
- end
56
- end
57
- end
58
-
59
- #ensure at least one state field is populated
60
- if self.state_id.blank? && self.state_name.blank?
61
- errors.add(:state, :blank)
62
- end
63
-
64
- end
65
-
66
26
  def self.default
67
- country = Spree::Country.find_by_id(Spree::Config[:default_country_id])
68
- new(:country => country || Country.first)
27
+ country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
28
+ new({:country => country}, :without_protection => true)
69
29
  end
70
30
 
71
31
  # can modify an address if it's not been used in an order (but checkouts controller has finer control)
@@ -74,7 +34,7 @@ module Spree
74
34
  # end
75
35
 
76
36
  def full_name
77
- self.firstname + ' ' + self.lastname
37
+ "#{firstname} #{lastname}".strip
78
38
  end
79
39
 
80
40
  def state_text
@@ -82,8 +42,7 @@ module Spree
82
42
  end
83
43
 
84
44
  def zone
85
- (state && state.zone) ||
86
- (country && country.zone)
45
+ (state && state.zone) || (country && country.zone)
87
46
  end
88
47
 
89
48
  def zones
@@ -117,5 +76,46 @@ module Spree
117
76
  def empty?
118
77
  attributes.except('id', 'created_at', 'updated_at', 'order_id', 'country_id').all? { |_, v| v.nil? }
119
78
  end
79
+
80
+ private
81
+
82
+ def state_validate
83
+ #skip state validation without country (also required)
84
+ #or when disabled by perfernce
85
+ return if !country.present? || !Spree::Config[:address_requires_state]
86
+
87
+ #ensure associated state belongs to country
88
+ if state.present?
89
+ if state.country == country
90
+ self.state_name = nil #not required as we have a valid state and country combo
91
+ else
92
+ if state_name.present?
93
+ self.state = nil
94
+ else
95
+ errors.add(:state, :invalid)
96
+ end
97
+ end
98
+ end
99
+
100
+ #ensure state_name belongs to country without states, or that it matches a predefined state name/abbr
101
+ if state_name.present?
102
+ if country.states.present?
103
+ states = country.states.find_all_by_name_or_abbr(state_name)
104
+
105
+ if states.size == 1
106
+ self.state = states.first
107
+ self.state_name = nil
108
+ else
109
+ errors.add(:state, :invalid)
110
+ end
111
+ end
112
+ end
113
+
114
+ #ensure at least one state field is populated
115
+ if !state.present? && state_name.blank?
116
+ errors.add(:state, :blank)
117
+ end
118
+ end
119
+
120
120
  end
121
121
  end
@@ -33,7 +33,7 @@ module Spree
33
33
 
34
34
  scope :tax, lambda { where(:originator_type => 'Spree::TaxRate', :adjustable_type => 'Spree::Order') }
35
35
  scope :price, lambda { where(:adjustable_type => 'Spree::LineItem') }
36
- scope :shipping, lambda { where(:originator_type => 'Spree::ShippingMethod') }
36
+ scope :shipping, lambda { where(:label => I18n.t(:shipping)) }
37
37
  scope :optional, where(:mandatory => false)
38
38
  scope :eligible, where(:eligible => true)
39
39
  scope :charge, where("amount >= 0")
@@ -75,9 +75,9 @@ module Spree
75
75
 
76
76
  private
77
77
 
78
- def update_adjustable
79
- adjustable.update! if adjustable.is_a? Spree::Order
80
- end
78
+ def update_adjustable
79
+ adjustable.update! if adjustable.is_a? Order
80
+ end
81
81
 
82
82
  end
83
83
  end
@@ -48,6 +48,7 @@ module Spree
48
48
  preference :default_seo_title, :string, :default => ''
49
49
  preference :dismissed_spree_alerts, :string, :default => ''
50
50
  preference :last_check_for_spree_alerts, :string, :default => nil
51
+ preference :layout, :string, :default => '/spree/layouts/spree_application'
51
52
  preference :logo, :string, :default => 'admin/bg/spree_50.png'
52
53
  preference :max_level_in_taxons_menu, :integer, :default => 1 # maximum nesting level in taxons menu
53
54
  preference :orders_per_page, :integer, :default => 15
@@ -64,6 +65,17 @@ module Spree
64
65
  preference :tax_using_ship_address, :boolean, :default => true
65
66
  preference :track_inventory_levels, :boolean, :default => true # will not track on_hand values for variants /products
66
67
 
68
+ # Preferences related to image settings
69
+ preference :attachment_default_url, :string, :default => '/spree/products/:id/:style/:basename.:extension'
70
+ preference :attachment_path, :string, :default => ':rails_root/public/spree/products/:id/:style/:basename.:extension'
71
+ preference :attachment_styles, :string, :default => "{\"mini\":\"48x48>\",\"small\":\"100x100>\",\"product\":\"240x240>\",\"large\":\"600x600>\"}"
72
+ preference :attachment_default_style, :string, :default => 'product'
73
+ preference :s3_access_key, :string
74
+ preference :s3_bucket, :string
75
+ preference :s3_secret, :string
76
+ preference :s3_headers, :string, :default => "{\"Cache-Control\":\"max-age=31557600\"}"
77
+ preference :use_s3, :boolean, :default => false # Use S3 for images rather than the file system
78
+
67
79
  # searcher_class allows spree extension writers to provide their own Search class
68
80
  def searcher_class
69
81
  @searcher_class ||= Spree::Core::Search::Base
@@ -1,5 +1,3 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::DefaultTax < Calculator
5
3
  def self.description
@@ -19,7 +17,7 @@ module Spree
19
17
  private
20
18
 
21
19
  def rate
22
- rate = self.calculable
20
+ self.calculable
23
21
  end
24
22
 
25
23
  def compute_order(order)
@@ -1,5 +1,3 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::FlatPercentItemTotal < Calculator
5
3
  preference :flat_percent, :decimal, :default => 0
@@ -1,9 +1,6 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::FlatRate < Calculator
5
3
  preference :amount, :decimal, :default => 0
6
-
7
4
  attr_accessible :preferred_amount
8
5
 
9
6
  def self.description
@@ -1,12 +1,10 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::FlexiRate < Calculator
5
3
  preference :first_item, :decimal, :default => 0.0
6
4
  preference :additional_item, :decimal, :default => 0.0
7
5
  preference :max_items, :integer, :default => 0
8
6
 
9
- attr_accessible :preferred_first_item, :preferred_additional_item, :preferred_max_items
7
+ attr_accessible :preferred_first_item, :preferred_additional_tiem, :preferred_max_items
10
8
 
11
9
  def self.description
12
10
  I18n.t(:flexible_rate)
@@ -1,5 +1,3 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::PerItem < Calculator
5
3
  preference :amount, :decimal, :default => 0
@@ -11,10 +9,7 @@ module Spree
11
9
  end
12
10
 
13
11
  def compute(object=nil)
14
- return 0 if object.nil?
15
- self.preferred_amount * object.line_items.reduce(0) do |sum, value|
16
- sum + value.quantity
17
- end
12
+ self.preferred_amount * object.line_items.length
18
13
  end
19
14
  end
20
15
  end
@@ -1,5 +1,3 @@
1
- require_dependency 'spree/calculator'
2
-
3
1
  module Spree
4
2
  class Calculator::PriceSack < Calculator
5
3
  preference :minimal_amount, :decimal, :default => 0
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class Country < ActiveRecord::Base
3
- has_many :states
3
+ has_many :states, :order => "name ASC"
4
4
 
5
5
  has_one :zone_member, :as => :zoneable
6
6
  has_one :zone, :through => :zone_member
@@ -11,8 +11,7 @@ module Spree
11
11
  validates :number, :presence => true, :unless => :has_payment_profile?, :on => :create
12
12
  validates :verification_value, :presence => true, :unless => :has_payment_profile?, :on => :create
13
13
 
14
- attr_accessible :first_name, :last_name, :number, :verification_value, :year,
15
- :month, :gateway_customer_profile_id, :gateway_payment_profile_id
14
+ attr_accessible :first_name, :last_name, :number, :verification_value, :year, :month, :gateway_customer_profile_id
16
15
 
17
16
  def process!(payment)
18
17
  if Spree::Config[:auto_capture]
@@ -174,12 +173,12 @@ module Spree
174
173
  record_log payment, response
175
174
 
176
175
  if response.success?
177
- Payment.create({ :order => payment.order,
178
- :source => payment,
179
- :payment_method => payment.payment_method,
180
- :amount => amount.abs * -1,
181
- :response_code => response.authorization,
182
- :state => 'completed'}, :without_protection => true)
176
+ Payment.create({:order => payment.order,
177
+ :source => payment,
178
+ :payment_method => payment.payment_method,
179
+ :amount => amount.abs * -1,
180
+ :response_code => response.authorization,
181
+ :state => 'completed'}, :without_protection => true)
183
182
  else
184
183
  gateway_error(response)
185
184
  end
@@ -214,7 +213,7 @@ module Spree
214
213
  end
215
214
 
216
215
  def record_log(payment, response)
217
- payment.log_entries.create(:details => response.to_yaml)
216
+ payment.log_entries.create({:details => response.to_yaml}, :without_protection => true)
218
217
  end
219
218
 
220
219
  def gateway_error(error)
@@ -261,7 +260,7 @@ module Spree
261
260
  end
262
261
 
263
262
  def spree_cc_type
264
- return 'visa' if Rails.env == 'development'
263
+ return 'visa' if Rails.env.development?
265
264
  self.cc_type
266
265
  end
267
266
 
@@ -7,8 +7,6 @@ module Spree
7
7
  preference :server, :string, :default => 'test'
8
8
  preference :test_mode, :boolean, :default => true
9
9
 
10
- attr_accessible :preferred_server, :preferred_test_mode
11
-
12
10
  def payment_source_class
13
11
  Creditcard
14
12
  end
@@ -1,19 +1,35 @@
1
1
  module Spree
2
2
  class Image < Asset
3
+ validates_attachment_presence :attachment
3
4
  validate :no_attachment_errors
4
5
 
5
- attr_accessible :alt, :attachment, :position, :viewable_type, :viewable_id
6
+ attr_accessible :attachment, :alt, :viewable_id
6
7
 
7
8
  has_attached_file :attachment,
8
9
  :styles => { :mini => '48x48>', :small => '100x100>', :product => '240x240>', :large => '600x600>' },
9
10
  :default_style => :product,
10
11
  :url => '/spree/products/:id/:style/:basename.:extension',
11
12
  :path => ':rails_root/public/spree/products/:id/:style/:basename.:extension'
12
-
13
13
  # save the w,h of the original image (from which others can be calculated)
14
14
  # we need to look at the write-queue for images which have not been saved yet
15
15
  after_post_process :find_dimensions
16
16
 
17
+ attr_accessible :attachment, :position
18
+
19
+ # Load user defined paperclip settings
20
+ if Spree::Config[:use_s3]
21
+ s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
22
+ Spree::Image.attachment_definitions[:attachment][:storage] = :s3
23
+ Spree::Image.attachment_definitions[:attachment][:s3_credentials] = s3_creds
24
+ Spree::Image.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
25
+ Spree::Image.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
26
+ end
27
+
28
+ Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
29
+ Spree::Image.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
30
+ Spree::Image.attachment_definitions[:attachment][:default_url] = Spree::Config[:attachment_default_url]
31
+ Spree::Image.attachment_definitions[:attachment][:default_style] = Spree::Config[:attachment_default_style]
32
+
17
33
  #used by admin products autocomplete
18
34
  def mini_url
19
35
  attachment.url(:mini, false)
@@ -99,8 +99,10 @@ module Spree
99
99
 
100
100
  shipment = order.shipments.detect { |shipment| !shipment.shipped? }
101
101
 
102
- sold.times { order.inventory_units.create(:variant => variant, :state => 'sold', :shipment => shipment) }
103
- back_order.times { order.inventory_units.create(:variant => variant, :state => 'backordered', :shipment => shipment) }
102
+ attr_accessible :shipment
103
+
104
+ sold.times { order.inventory_units.create({:variant => variant, :state => 'sold', :shipment => shipment}, :without_protection => true) }
105
+ back_order.times { order.inventory_units.create({:variant => variant, :state => 'backordered', :shipment => shipment}, :without_protection => true) }
104
106
  end
105
107
 
106
108
  def update_order
@@ -16,12 +16,7 @@ module Spree
16
16
  preference :mail_bcc, :string, :default => 'spree@example.com'
17
17
  preference :intercept_email, :string, :default => nil
18
18
 
19
- attr_accessible :environment, :preferred_enable_mail_delivery,
20
- :preferred_mails_from, :preferred_mail_bcc,
21
- :preferred_intercept_email, :preferred_mail_domain,
22
- :preferred_mail_host, :preferred_mail_port,
23
- :preferred_secure_connection_type, :preferred_mail_auth_type,
24
- :preferred_smtp_username, :preferred_smtp_password
19
+ attr_accessible :environment, :preferred_enable_mail_delivery, :preferred_mails_from, :preferred_mail_bcc, :preferred_intercept_email, :preferred_mail_domain, :preferred_mail_host, :preferred_mail_port, :preferred_secure_connection_type, :preferred_mail_auth_type, :preferred_smtp_username, :preferred_smtp_password
25
20
 
26
21
  validates :environment, :presence => true
27
22
 
@@ -4,11 +4,13 @@ module Spree
4
4
  has_many :product_option_types, :dependent => :destroy
5
5
  has_and_belongs_to_many :prototypes, :join_table => 'spree_option_types_prototypes'
6
6
 
7
- attr_accessible :name, :presentation, :option_values_attributes
7
+ attr_accessible :name, :presentation
8
8
 
9
9
  validates :name, :presentation, :presence => true
10
10
  default_scope :order => "#{self.table_name}.position"
11
11
 
12
+ attr_accessible :option_values_attributes
13
+
12
14
  accepts_nested_attributes_for :option_values, :reject_if => lambda { |ov| ov[:name].blank? || ov[:presentation].blank? }, :allow_destroy => true
13
15
  end
14
16
  end