spree 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. data/CHANGELOG +30 -0
  2. data/CONTRIBUTORS +38 -20
  3. data/app/controllers/admin/creditcard_payments_controller.rb +10 -3
  4. data/app/controllers/admin/orders_controller.rb +17 -16
  5. data/app/controllers/admin/products_controller.rb +12 -14
  6. data/app/controllers/admin/reports_controller.rb +12 -14
  7. data/app/controllers/admin/users_controller.rb +10 -5
  8. data/app/controllers/admin/zones_controller.rb +4 -1
  9. data/app/controllers/application.rb +0 -1
  10. data/app/controllers/checkout_controller.rb +96 -0
  11. data/app/controllers/content_controller.rb +11 -1
  12. data/app/controllers/orders_controller.rb +12 -33
  13. data/app/controllers/products_controller.rb +12 -7
  14. data/app/controllers/spree/base_controller.rb +1 -1
  15. data/app/controllers/states_controller.rb +14 -2
  16. data/app/controllers/taxons_controller.rb +6 -2
  17. data/app/controllers/users_controller.rb +9 -6
  18. data/app/helpers/application_helper.rb +1 -11
  19. data/app/helpers/products_helper.rb +3 -1
  20. data/app/helpers/spree/base_helper.rb +0 -26
  21. data/app/models/address.rb +3 -3
  22. data/app/models/app_configuration.rb +1 -0
  23. data/app/models/country.rb +4 -0
  24. data/app/models/creditcard.rb +6 -1
  25. data/app/models/creditcard_payment.rb +1 -1
  26. data/app/models/inventory_unit.rb +4 -1
  27. data/app/models/order.rb +37 -21
  28. data/app/models/product.rb +19 -8
  29. data/{vendor/extensions/shipping/app → app}/models/shipment.rb +20 -4
  30. data/{vendor/extensions/shipping/app → app}/models/shipping_category.rb +0 -0
  31. data/{vendor/extensions/shipping/app → app}/models/shipping_method.rb +6 -4
  32. data/app/models/state.rb +5 -0
  33. data/app/models/user.rb +4 -2
  34. data/app/models/variant.rb +19 -1
  35. data/app/presenters/checkout_presenter.rb +58 -0
  36. data/app/views/admin/creditcard_payments/edit.html.erb +1 -1
  37. data/app/views/admin/option_types/available.html.erb +1 -1
  38. data/app/views/admin/orders/index.html.erb +28 -18
  39. data/app/views/admin/orders/show.html.erb +1 -1
  40. data/app/views/admin/payments/index.html.erb +1 -1
  41. data/app/views/admin/products/_images.html.erb +1 -1
  42. data/app/views/admin/products/index.html.erb +17 -13
  43. data/app/views/admin/users/index.html.erb +8 -8
  44. data/app/views/admin/zones/index.html.erb +5 -2
  45. data/app/views/checkout/_form.html.erb +165 -0
  46. data/app/views/{creditcards → checkout}/cvv.html.erb +1 -1
  47. data/app/views/checkout/new.html.erb +6 -0
  48. data/app/views/layouts/admin.html.erb +2 -3
  49. data/app/views/layouts/application.html.erb +1 -1
  50. data/app/views/orders/_form.html.erb +6 -4
  51. data/app/views/orders/_google_order.html.erb +24 -0
  52. data/app/views/orders/_line_item.html.erb +2 -1
  53. data/app/views/orders/show.html.erb +4 -1
  54. data/app/views/products/index.html.erb +2 -1
  55. data/app/views/products/show.html.erb +4 -4
  56. data/app/views/shared/_footer.html.erb +12 -1
  57. data/app/views/shared/_login.html.erb +1 -1
  58. data/app/views/shared/_order_details.html.erb +8 -9
  59. data/app/views/shared/_products.html.erb +1 -1
  60. data/app/views/shared/_report_criteria.html.erb +28 -28
  61. data/app/views/states/index.js.erb +10 -1
  62. data/config/environment.rb +10 -4
  63. data/config/initializers/searchlogic.rb +6 -0
  64. data/config/locales/de.yml +14 -0
  65. data/config/locales/en-GB.yml +20 -6
  66. data/config/locales/en-US.yml +20 -4
  67. data/config/locales/es.yml +14 -0
  68. data/config/locales/fr-FR.yml +463 -0
  69. data/config/locales/fr-FR_rails.yml +115 -0
  70. data/config/locales/it.yml +14 -0
  71. data/config/locales/nb-NO.yml +457 -0
  72. data/config/locales/nb-NO_rails.yml +105 -0
  73. data/config/locales/pl.yml +14 -0
  74. data/config/locales/pt-BR.yml +14 -0
  75. data/config/locales/pt-PT.yml +14 -0
  76. data/config/locales/ru-RU.yml +458 -0
  77. data/config/locales/ru-RU_rails.yml +154 -0
  78. data/config/routes.rb +11 -4
  79. data/db/migrate/20090204200045_add_order_permalink.rb +13 -0
  80. data/db/migrate/20090225231119_add_more_needed_keys_items_and_conf.rb +19 -0
  81. data/db/migrate/20090302221152_give_all_users_user_role.rb +13 -0
  82. data/db/sample/orders.yml +1 -1
  83. data/lib/generators/instance/instance_generator.rb +1 -1
  84. data/lib/spree.rb +1 -1
  85. data/lib/spree/setup.rb +1 -1
  86. data/lib/tasks/database.rake +5 -2
  87. data/lib/tasks/release.rake +1 -1
  88. data/lib/tasks/upgrade.rake +11 -0
  89. data/public/assets/products/1009/mini/sean.jpg +0 -0
  90. data/public/assets/products/1009/original/sean.jpg +0 -0
  91. data/public/assets/products/1009/product/sean.jpg +0 -0
  92. data/public/assets/products/1009/small/sean.jpg +0 -0
  93. data/public/images/ajax_loader.gif +0 -0
  94. data/public/javascripts/checkout.js +284 -0
  95. data/public/javascripts/jquery-1.3.2.min.js +19 -0
  96. data/public/javascripts/jquery.validate.pack.js +15 -0
  97. data/public/stylesheets/checkout.css +25 -0
  98. data/public/stylesheets/spree-admin.css +6 -2
  99. data/public/stylesheets/spree.css +419 -432
  100. data/spec/controllers/countries_controller_spec.rb +3 -2
  101. data/spec/controllers/orders_controller_spec.rb +7 -5
  102. data/spec/controllers/states_controller_spec.rb +4 -2
  103. data/spec/models/creditcard_payment_spec.rb +6 -2
  104. data/spec/models/order_spec.rb +164 -157
  105. data/spec/models/product_spec.rb +2 -2
  106. data/vendor/extensions/payment_gateway/db/migrate/20090218091936_create_protx_gateway.rb +18 -0
  107. data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +7 -5
  108. data/vendor/extensions/shipping/app/controllers/admin/shipments_controller.rb +6 -5
  109. data/vendor/extensions/shipping/app/views/admin/shipments/index.html.erb +1 -1
  110. data/vendor/extensions/shipping/config/locales/nb-NO.yml +25 -0
  111. data/vendor/extensions/shipping/config/locales/ru-RU.yml +25 -0
  112. data/vendor/extensions/shipping/db/sample/shipping_methods.yml +5 -1
  113. data/vendor/extensions/shipping/db/sample/zone_members.yml +9 -1
  114. data/vendor/extensions/shipping/db/sample/zones.yml +4 -1
  115. data/vendor/extensions/shipping/lib/spree/shipping_calculator.rb +0 -16
  116. data/vendor/extensions/shipping/shipping_extension.rb +0 -15
  117. data/vendor/extensions/shipping/spec/models/shipping_method_spec.rb +16 -10
  118. data/vendor/extensions/shipping/spec/models/shipping_order_spec.rb +3 -17
  119. data/vendor/extensions/tax_calculator/config/locales/nb-NO.yml +30 -0
  120. data/vendor/extensions/tax_calculator/spec/models/{order_spec.rb → order_tax_calc_spec.rb} +2 -2
  121. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/.specification +3 -5
  122. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/LICENSE +0 -0
  123. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/README +9 -2
  124. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/Rakefile +0 -0
  125. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter.rb +0 -0
  126. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/base.rb +38 -8
  127. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/version.rb +1 -1
  128. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/doc.rake +0 -0
  129. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/gem.rake +0 -0
  130. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/base_test.rb +66 -30
  131. data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/test_helper.rb +36 -0
  132. data/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb +12 -4
  133. data/vendor/plugins/find_by_param/MIT-LICENSE +1 -1
  134. data/vendor/plugins/find_by_param/{README → README.markdown} +7 -1
  135. data/vendor/plugins/find_by_param/init.rb +0 -1
  136. data/vendor/plugins/find_by_param/lib/find_by_param.rb +23 -87
  137. data/vendor/plugins/find_by_param/test/find_by_param_test.rb +22 -8
  138. data/vendor/plugins/find_by_param/test/test_helper.rb +0 -1
  139. metadata +65 -193
  140. data/app/controllers/creditcards_controller.rb +0 -73
  141. data/app/models/order_filter.rb +0 -28
  142. data/app/models/user_filter.rb +0 -6
  143. data/app/views/creditcards/_form_credit_card.html.erb +0 -30
  144. data/app/views/creditcards/new.html.erb +0 -25
  145. data/app/views/shared/_paginate.html.erb +0 -34
  146. data/lib/plugins/paginating_find/CHANGELOG +0 -120
  147. data/lib/plugins/paginating_find/README +0 -89
  148. data/lib/plugins/paginating_find/init.rb +0 -2
  149. data/lib/plugins/paginating_find/lib/paginating_find.rb +0 -138
  150. data/lib/plugins/paginating_find/lib/paging_enumerator.rb +0 -158
  151. data/lib/plugins/paginating_find/lib/paging_helper.rb +0 -47
  152. data/lib/plugins/paginating_find/test_app/Rakefile +0 -10
  153. data/lib/plugins/paginating_find/test_app/app/controllers/application.rb +0 -2
  154. data/lib/plugins/paginating_find/test_app/config/boot.rb +0 -44
  155. data/lib/plugins/paginating_find/test_app/config/database.yml +0 -6
  156. data/lib/plugins/paginating_find/test_app/config/environment.rb +0 -53
  157. data/lib/plugins/paginating_find/test_app/config/environments/test.rb +0 -19
  158. data/lib/plugins/paginating_find/test_app/config/routes.rb +0 -22
  159. data/lib/plugins/paginating_find/test_app/script/breakpointer +0 -3
  160. data/lib/plugins/paginating_find/test_app/script/console +0 -3
  161. data/lib/plugins/paginating_find/test_app/test/fixtures/articles.yml +0 -19
  162. data/lib/plugins/paginating_find/test_app/test/fixtures/authors.yml +0 -7
  163. data/lib/plugins/paginating_find/test_app/test/fixtures/edits.yml +0 -11
  164. data/lib/plugins/paginating_find/test_app/test/fixtures/models.rb +0 -18
  165. data/lib/plugins/paginating_find/test_app/test/test_helper.rb +0 -33
  166. data/lib/plugins/paginating_find/test_app/test/unit/abstract_test.rb +0 -7
  167. data/lib/plugins/paginating_find/test_app/test/unit/group_test.rb +0 -40
  168. data/lib/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +0 -194
  169. data/lib/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +0 -143
  170. data/public/assets/products/1012/mini/bt.jpg +0 -0
  171. data/public/assets/products/1012/original/bt.jpg +0 -0
  172. data/public/assets/products/1012/product/bt.jpg +0 -0
  173. data/public/assets/products/1012/small/bt.jpg +0 -0
  174. data/spec/views/products/index.html.erb_spec.rb +0 -46
  175. data/spec/views/products/show.html.erb_spec.rb +0 -46
  176. data/vendor/extensions/shipping/app/controllers/shipments_controller.rb +0 -96
  177. data/vendor/extensions/shipping/app/helpers/shipments_helper.rb +0 -20
  178. data/vendor/extensions/shipping/app/views/orders/fatal_shipping.html.erb +0 -6
  179. data/vendor/extensions/shipping/app/views/shipments/_form.html.erb +0 -46
  180. data/vendor/extensions/shipping/app/views/shipments/edit.html.erb +0 -57
  181. data/vendor/extensions/shipping/app/views/shipments/new.html.erb +0 -10
@@ -0,0 +1,154 @@
1
+ ru-RU:
2
+ number:
3
+ # Used in number_with_delimiter()
4
+ # These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
5
+ format:
6
+ # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
7
+ separator: "."
8
+ # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
9
+ delimiter: ","
10
+ # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
11
+ precision: 3
12
+
13
+ # Used in number_to_currency()
14
+ currency:
15
+ format:
16
+ # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
17
+ format: "%u%n"
18
+ unit: "$"
19
+ # These three are to override number.format and are optional
20
+ separator: "."
21
+ delimiter: ","
22
+ precision: 2
23
+
24
+ # Used in number_to_percentage()
25
+ percentage:
26
+ format:
27
+ # These three are to override number.format and are optional
28
+ # separator:
29
+ delimiter: ""
30
+ # precision:
31
+
32
+ # Used in number_to_precision()
33
+ precision:
34
+ format:
35
+ # These three are to override number.format and are optional
36
+ # separator:
37
+ delimiter: ""
38
+ # precision:
39
+
40
+ # Used in number_to_human_size()
41
+ human:
42
+ format:
43
+ # These three are to override number.format and are optional
44
+ # separator:
45
+ delimiter: ""
46
+ precision: 1
47
+ storage_units: [Bytes, KB, MB, GB, TB]
48
+
49
+ # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
50
+ datetime:
51
+ distance_in_words:
52
+ half_a_minute: "half a minute"
53
+ less_than_x_seconds:
54
+ one: "less than 1 second"
55
+ other: "less than {{count}} seconds"
56
+ x_seconds:
57
+ one: "1 second"
58
+ other: "{{count}} seconds"
59
+ less_than_x_minutes:
60
+ one: "less than a minute"
61
+ other: "less than {{count}} minutes"
62
+ x_minutes:
63
+ one: "1 minute"
64
+ other: "{{count}} minutes"
65
+ about_x_hours:
66
+ one: "about 1 hour"
67
+ other: "about {{count}} hours"
68
+ x_days:
69
+ one: "1 day"
70
+ other: "{{count}} days"
71
+ about_x_months:
72
+ one: "about 1 month"
73
+ other: "about {{count}} months"
74
+ x_months:
75
+ one: "1 month"
76
+ other: "{{count}} months"
77
+ about_x_years:
78
+ one: "about 1 year"
79
+ other: "about {{count}} years"
80
+ over_x_years:
81
+ one: "over 1 year"
82
+ other: "over {{count}} years"
83
+ prompts:
84
+ year: "Year"
85
+ month: "Month"
86
+ day: "Day"
87
+ hour: "Hour"
88
+ minute: "Minute"
89
+ second: "Seconds"
90
+
91
+ activerecord:
92
+ errors:
93
+ template:
94
+ header:
95
+ one: "1 error prohibited this {{model}} from being saved"
96
+ other: "{{count}} errors prohibited this {{model}} from being saved"
97
+ # The variable :count is also available
98
+ body: "There were problems with the following fields:"
99
+
100
+ # The values :model, :attribute and :value are always available for interpolation
101
+ # The value :count is available when applicable. Can be used for pluralization.
102
+ messages:
103
+ inclusion: "is not included in the list"
104
+ exclusion: "is reserved"
105
+ invalid: "is invalid"
106
+ confirmation: "doesn't match confirmation"
107
+ accepted: "must be accepted"
108
+ empty: "can't be empty"
109
+ blank: "can't be blank"
110
+ too_long: "is too long (maximum is {{count}} characters)"
111
+ too_short: "is too short (minimum is {{count}} characters)"
112
+ wrong_length: "is the wrong length (should be {{count}} characters)"
113
+ taken: "has already been taken"
114
+ not_a_number: "is not a number"
115
+ greater_than: "must be greater than {{count}}"
116
+ greater_than_or_equal_to: "must be greater than or equal to {{count}}"
117
+ equal_to: "must be equal to {{count}}"
118
+ less_than: "must be less than {{count}}"
119
+ less_than_or_equal_to: "must be less than or equal to {{count}}"
120
+ odd: "must be odd"
121
+ even: "must be even"
122
+
123
+ date:
124
+ formats:
125
+ # Use the strftime parameters for formats.
126
+ # When no format has been given, it uses default.
127
+ # You can provide other formats here if you like!
128
+ default: "%Y-%m-%d"
129
+ short: "%b %d"
130
+ long: "%B %d, %Y"
131
+
132
+ day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
133
+ abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
134
+
135
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
136
+ month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
137
+ abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
138
+ # Used in date_select and datime_select.
139
+ order: [ :year, :month, :day ]
140
+
141
+ time:
142
+ formats:
143
+ default: "%a, %d %b %Y %H:%M:%S %z"
144
+ short: "%d %b %H:%M"
145
+ long: "%B %d, %Y %H:%M"
146
+ am: "am"
147
+ pm: "pm"
148
+
149
+ # Used in array.to_sentence.
150
+ support:
151
+ array:
152
+ words_connector: ", "
153
+ two_words_connector: " and "
154
+ last_word_connector: ", and "
@@ -18,17 +18,23 @@ ActionController::Routing::Routes.draw do |map|
18
18
 
19
19
  # Allow downloading Web Service WSDL as a file with an extension
20
20
  # instead of a file named 'wsdl'
21
- map.connect ':controller/service.wsdl', :action => 'wsdl'
21
+ #map.connect ':controller/service.wsdl', :action => 'wsdl'
22
22
 
23
23
  # map.connect '/locale/:new_locale', :controller => 'locale', :action => 'set_session_locale'
24
24
 
25
25
  map.root :controller => "products", :action => "index"
26
+
26
27
  # login mappings should appear before all others
27
28
  map.login '/login', :controller => 'account', :action => 'login'
28
29
  map.logout '/logout', :controller => 'account', :action => 'logout'
29
30
  map.signup '/signup', :controller => 'users', :action => 'new'
30
31
  map.admin '/admin', :controller => 'admin/overview', :action => 'index'
31
-
32
+
33
+ # custom route for checkout since its not really a resource
34
+ map.checkout 'orders/:order_number/checkout', :controller => 'checkout', :action => 'new'
35
+ map.checkout 'orders/:order_number/complete', :controller => 'checkout', :action => 'create'
36
+ map.checkout 'orders/:order_number/checkout/:action', :controller => 'checkout'
37
+
32
38
  map.resources :tax_categories
33
39
  map.resources :countries, :has_many => :states, :only => :index
34
40
  map.resources :states, :only => :index
@@ -62,6 +68,7 @@ ActionController::Routing::Routes.draw do |map|
62
68
  admin.resources :prototypes, :member => {:select => :post}, :collection => {:available => :get}
63
69
  admin.resource :mail_settings
64
70
  admin.resource :inventory_settings
71
+ admin.resources :google_analytics
65
72
  admin.resources :orders, :has_many => [:payments, :creditcards], :member => {:fire => :put, :resend => :post}
66
73
  admin.resources :orders do |order|
67
74
  order.resources :creditcard_payments, :member => {:capture => :get}
@@ -71,8 +78,8 @@ ActionController::Routing::Routes.draw do |map|
71
78
  taxonomy.resources :taxons
72
79
  end
73
80
  admin.resources :reports, :only => [:index, :show], :collection => {:sales_total => :get}
74
- end
75
-
81
+ end
82
+
76
83
  map.connect ':controller/:action/:id.:format'
77
84
  map.connect ':controller/:action/:id'
78
85
 
@@ -0,0 +1,13 @@
1
+ class AddOrderPermalink < ActiveRecord::Migration
2
+ def self.up
3
+ add_index :orders, :number
4
+ Order.all.each do |order|
5
+ next unless order.number.is_integer? || order.number.starts_with?("0")
6
+ order.update_attribute("number", "R#{order.number}")
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ remove_index :orders, :number
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class AddMoreNeededKeysItemsAndConf < ActiveRecord::Migration
2
+ def self.up
3
+ add_index :line_items, [:order_id]
4
+ add_index :line_items, [:variant_id]
5
+
6
+ add_index :configurations, [:name, :type]
7
+ add_index :creditcards, [:order_id]
8
+ add_index :orders, [:checkout_complete]
9
+ end
10
+
11
+ def self.down
12
+ remove_index :orders, :column => [:checkout_complete]
13
+ remove_index :creditcards, :column => [:order_id]
14
+ remove_index :configurations, :column => [:name, :type]
15
+
16
+ remove_index :line_items, :column => [:variant_id]
17
+ remove_index :line_items, :column => [:order_id]
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ class GiveAllUsersUserRole < ActiveRecord::Migration
2
+ def self.up
3
+ user_role = Role.find_by_name("user")
4
+ users = User.find(:all)
5
+ users.each{|u|
6
+ u.roles << user_role
7
+ u.save
8
+ }
9
+ end
10
+
11
+ def self.down
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  <% 1.upto(30) do |i| %>
2
2
  order_<%= i %>:
3
3
  user: frank
4
- number: <%= Array.new(9){rand(9)}.join %>
4
+ number: <%= "R#{Array.new(9){rand(9)}.join}" %>
5
5
  state: new
6
6
  ship_amount: 5.00
7
7
  tax_amount: 2.78
@@ -69,7 +69,7 @@ class InstanceGenerator < Rails::Generator::Base
69
69
  files.map! { |f| f = $1 if f =~ %r{^#{root}/(.+)$}; f }
70
70
 
71
71
  # hack to add specification (we're ignoring other hidden files)
72
- files << "vendor/gems/active_presenter-0.0.4/.specification"
72
+ files << "vendor/gems/active_presenter-0.0.6/.specification"
73
73
  files.sort!
74
74
 
75
75
  files.each do |file|
@@ -8,7 +8,7 @@ unless defined? Spree::Version
8
8
  module Spree
9
9
  module Version
10
10
  Major = '0'
11
- Minor = '6'
11
+ Minor = '7'
12
12
  Tiny = '0'
13
13
 
14
14
  class << self
@@ -1,7 +1,7 @@
1
1
  #######################################################################################################
2
2
  # Substantial portions of this code were adapted from the Radiant CMS project (http://radiantcms.org) #
3
3
  #######################################################################################################
4
- require "highline"
4
+ require 'highline/import'
5
5
  require 'custom_fixtures'
6
6
  require 'find'
7
7
 
@@ -1,9 +1,10 @@
1
- require 'activerecord'
2
- require 'highline/import'
1
+ require 'activerecord'
3
2
 
4
3
  namespace :db do
5
4
  desc "Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!"
6
5
  task :remigrate => :environment do
6
+ require 'highline/import'
7
+
7
8
  if ENV['SKIP_NAG'] or ENV['OVERWRITE'].to_s.downcase == 'true' or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
8
9
 
9
10
  # Drop all tables
@@ -29,6 +30,8 @@ namespace :db do
29
30
 
30
31
  desc "Bootstrap your database for Spree."
31
32
  task :bootstrap => :environment do
33
+ require 'highline/import'
34
+
32
35
  raise "Cannot bootstrap in production mode (for saftey reasons.)" unless %w[demo development test].include? RAILS_ENV
33
36
  if ENV['AUTO_ACCEPT'] or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
34
37
 
@@ -57,7 +57,7 @@ namespace 'spree' do
57
57
  #files.include 'log/.keep'
58
58
  files.exclude /^pkg/
59
59
  files.include 'public/.htaccess.example'
60
- files.include 'vendor/gems/active_presenter-0.0.4/.specification'
60
+ files.include 'vendor/gems/active_presenter-0.0.6/.specification'
61
61
  files.exclude 'public/images/products'
62
62
  files.exclude 'tmp/'
63
63
  s.files = files.to_a
@@ -0,0 +1,11 @@
1
+ namespace :spree do
2
+ desc "Assistance for upgrading an existing Spree deployment. WARNING: Will replace certain javascript and stylesheet assets."
3
+ task :upgrade => :environment do
4
+
5
+ Spree::FileUtilz.mirror_files "#{SPREE_ROOT}/public/javascripts", "#{RAILS_ROOT}/public/javascripts"
6
+ Spree::FileUtilz.mirror_files "#{SPREE_ROOT}/public/stylesheets", "#{RAILS_ROOT}/public/stylesheets"
7
+ Spree::FileUtilz.mirror_files "#{SPREE_ROOT}/public/images", "#{RAILS_ROOT}/public/images"
8
+ Spree::FileUtilz.mirror_files "#{SPREE_ROOT}/config/initializers", "#{RAILS_ROOT}/config/initializers"
9
+ end
10
+ end
11
+
@@ -0,0 +1,284 @@
1
+ var regions = new Array('billing', 'shipping', 'shipping_method', 'creditcard', 'confirm_order');
2
+
3
+ $(document).ajaxSend(function(event, request, settings) {
4
+ if (typeof(AUTH_TOKEN) == "undefined") return;
5
+ // settings.data is a serialized string like "foo=bar&baz=boink" (or null)
6
+ settings.data = settings.data || "";
7
+ settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
8
+ });
9
+
10
+ // public/javascripts/application.js
11
+ jQuery.ajaxSetup({
12
+ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
13
+ })
14
+
15
+ jQuery.fn.submitWithAjax = function() {
16
+ this.change(function() {
17
+ $.post('select_country', $(this).serialize(), null, "script");
18
+ return false;
19
+ })
20
+ return this;
21
+ };
22
+
23
+ jQuery.fn.sameAddress = function() {
24
+ this.click(function() {
25
+ if(!$(this).attr('checked')) {
26
+ //Clear ship values?
27
+ return;
28
+ }
29
+ $('input#hidden_sstate').val($('input#hidden_bstate').val());
30
+ $("#billing input, #billing select").each(function() {
31
+ $("#shipping #"+ $(this).attr('id').replace('bill', 'ship')).val($(this).val());
32
+ })
33
+ update_state('s');
34
+ })
35
+ }
36
+
37
+ //On page load
38
+ $(function() {
39
+ //$("#checkout_presenter_bill_address_country_id").submitWithAjax();
40
+ $('#checkout_presenter_same_address').sameAddress();
41
+ $('span#bcountry select').change(function() { update_state('b'); });
42
+ $('span#scountry select').change(function() { update_state('s'); });
43
+ get_states();
44
+
45
+ $('#validate_billing').click(function() { if(validate_section('billing')) { submit_billing(); }});
46
+ $('#validate_shipping').click(function() { if(validate_section('shipping')) { submit_shipping(); }});
47
+ $('#select_shipping_method').click(function() { submit_shipping_method(); });
48
+ $('#confirm_payment').click(function() { if(validate_section('creditcard')) { confirm_payment(); }});
49
+ $('form#checkout_form').submit(function() { return !($('div#confirm_order').hasClass('checkout_disabled')); });
50
+ })
51
+
52
+ //Initial state mapper on page load
53
+ var state_mapper;
54
+ var get_states = function() {
55
+ $.getJSON('/states.js', function(json) {
56
+ state_mapper = json;
57
+ $('span#bcountry select').val($('input#hidden_bcountry').val());
58
+ update_state('b');
59
+ $('span#bstate :only-child').val($('input#hidden_bstate').val());
60
+ $('span#scountry select').val($('input#hidden_scountry').val());
61
+ update_state('s');
62
+ $('span#sstate :only-child').val($('input#hidden_sstate').val());
63
+ });
64
+ };
65
+
66
+ // replace the :only child of the parent with the given html, and transfer
67
+ // {name,id} attributes over, returning the new child
68
+ var chg_state_input_element = function (parent, html) {
69
+ var child = parent.find(':only-child');
70
+ var name = child.attr('name');
71
+ var id = child.attr('id');
72
+ //Toggle back and forth between id and name
73
+ if(html.attr('type') == 'text' && child.attr('type') != 'text') {
74
+ name = name.replace('_id', '_name');
75
+ id = id.replace('_id', '_name');
76
+ } else if(html.attr('type') != 'text' && child.attr('type') == 'text') {
77
+ name = name.replace('_name', '_id');
78
+ id = id.replace('_name', '_id');
79
+ }
80
+ html.addClass('required')
81
+ .attr('name', name)
82
+ .attr('id', id);
83
+ child.remove(); // better as parent-relative?
84
+ parent.append(html);
85
+ return html;
86
+ };
87
+
88
+
89
+ // TODO: better as sibling dummy state ?
90
+ // Update the input method for address.state
91
+ //
92
+ var update_state = function(region) {
93
+ var country = $('span#' + region + 'country :only-child').val();
94
+ var states = state_mapper[country];
95
+ var hidden_element = $('input#hidden_' + region + 'state');
96
+
97
+ var replacement;
98
+ if(states) {
99
+ // recreate state selection list
100
+ replacement = $(document.createElement('select'));
101
+ $.each(states, function(id,nm) {
102
+ var opt = $(document.createElement('option'))
103
+ .attr('value', id)
104
+ .html(nm);
105
+ replacement.append(opt)
106
+ if (id == hidden_element.val()) { opt.attr('selected', 'true') }
107
+ // set this directly IFF the old value is still valid
108
+ });
109
+ } else {
110
+ // recreate an input box
111
+ replacement = $(document.createElement('input'));
112
+ if (! hidden_element.val().match(/^\d+$/)) { replacement.val(hidden_element.val()) }
113
+ }
114
+
115
+ chg_state_input_element($('span#' + region + 'state'), replacement);
116
+ hidden_element.val(replacement.val());
117
+
118
+ // callback to update val when form object is changed
119
+ // This is only needed if we want to preserve state when someone refreshes the checkout page
120
+ // Or... if someone changes between countries with no given states
121
+ replacement.change(function() {
122
+ $('input#hidden_' + region + 'state').val($(this).val());
123
+ });
124
+ };
125
+
126
+
127
+ var validate_section = function(region) {
128
+ var validator = $('form#checkout_form').validate();
129
+ var valid = true;
130
+ $('div#' + region + ' input, div#' + region + ' select, div#' + region + ' textarea').each(function() {
131
+ if(!validator.element(this)) {
132
+ valid = false;
133
+ }
134
+ });
135
+ return valid;
136
+ };
137
+
138
+ var shift_to_region = function(active) {
139
+ $('div#flash-errors').remove();
140
+ var found = 0;
141
+ for(var i=0; i<regions.length; i++) {
142
+ if(!found) {
143
+ if(active == regions[i]) {
144
+ $('div#' + regions[i] + ' h2').unbind('click').css('cursor', 'default');
145
+ $('div#' + regions[i] + ' div.inner').show('fast');
146
+ $('div#' + regions[i]).removeClass('checkout_disabled');
147
+ found = 1;
148
+ }
149
+ else {
150
+ $('div#' + regions[i] + ' h2').unbind('click').css('cursor', 'pointer').click(function() {shift_to_region($(this).parent().attr('id'));});
151
+ $('div#' + regions[i] + ' div.inner').hide('fast');
152
+ }
153
+ } else {
154
+ $('div#' + regions[i] + ' h2').unbind('click').css('cursor', 'default');
155
+ $('div#' + regions[i] + ' div.inner').hide('fast');
156
+ $('div#' + regions[i]).addClass('checkout_disabled');
157
+ }
158
+ }
159
+ if (active == 'confirm_order') {
160
+ $("input#final_answer").attr("value", "yes");
161
+ } else {
162
+ // indicates order is ready to be processed (as opposed to simply updated)
163
+ $("input#final_answer").attr("value", "");
164
+ }
165
+ return;
166
+ };
167
+
168
+ var submit_billing = function() {
169
+ shift_to_region('shipping');
170
+ build_address('Billing Address', 'b');
171
+ return;
172
+ };
173
+
174
+ var build_address = function(title, region) {
175
+ var address = '<h3>' + title + '</h3>';
176
+ address += $('p#' + region + 'fname input').val() + ' ' + $('p#blname input').val() + '<br />';
177
+ address += $('p#' + region + 'address input').val() + '<br />';
178
+ if($('p#' + region + 'address2').val() != '') {
179
+ address += $('p#' + region + 'address2').val() + '<br />';
180
+ }
181
+ address += $('p#' + region + 'city input').val() + ', ';
182
+ if($('span#' + region + 'state input').length > 0) {
183
+ address += $('span#' + region + 'state input').val();
184
+ } else {
185
+ address += $('span#' + region + 'state :selected').html();
186
+ }
187
+ address += ' ' + $('p#' + region + 'zip input').val() + '<br />';
188
+ address += $('p#' + region + 'country :selected').html() + '<br />';
189
+ address += $('p#' + region + 'phone input').val();
190
+ $('div#' + region + 'display').html(address);
191
+ return;
192
+ };
193
+
194
+ var submit_shipping = function() {
195
+ $('div#methods :child').remove();
196
+ $('div#methods').append($(document.createElement('img')).attr('src', '/images/ajax_loader.gif').attr('id', 'shipping_loader'));
197
+ // Save what we have so far and get the list of shipping methods via AJAX
198
+ $.ajax({
199
+ type: "POST",
200
+ url: 'complete',
201
+ beforeSend : function (xhr) {
202
+ xhr.setRequestHeader('Accept-Encoding', 'identity');
203
+ },
204
+ dataType: "json",
205
+ data: $('#checkout_form').serialize(),
206
+ success: function(json) {
207
+ update_shipping_methods(json.available_methods);
208
+ },
209
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
210
+ // TODO - put some real error handling in here
211
+ $("#error").html(XMLHttpRequest.responseText);
212
+ }
213
+ });
214
+ shift_to_region('shipping_method');
215
+ build_address('Shipping Address', 's');
216
+ return;
217
+ };
218
+
219
+ var submit_shipping_method = function() {
220
+ //TODO: Move to validate_section('shipping_method'), but must debug how to validate radio buttons
221
+ var valid = false;
222
+ $('div#methods :child input').each(function() {
223
+ if($(this).attr('checked')) {
224
+ valid = true;
225
+ }
226
+ });
227
+ if(valid) {
228
+ // Save what we have so far and get the updated order totals via AJAX
229
+ $.ajax({
230
+ type: "POST",
231
+ url: 'complete',
232
+ beforeSend : function (xhr) {
233
+ xhr.setRequestHeader('Accept-Encoding', 'identity');
234
+ },
235
+ dataType: "json",
236
+ data: $('#checkout_form').serialize(),
237
+ success: function(json) {
238
+ update_confirmation(json.order);
239
+ },
240
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
241
+ // TODO - put some real error handling in here
242
+ //$("#error").html(XMLHttpRequest.responseText);
243
+ }
244
+ });
245
+ shift_to_region('creditcard');
246
+ } else {
247
+ var p = document.createElement('p');
248
+ $(p).append($(document.createElement('label')).addClass('error').html('Please select a shipping method').css('width', '300px').css('top', '0px'));
249
+ $('div#methods').append(p);
250
+ }
251
+ };
252
+
253
+ var update_shipping_methods = function(methods) {
254
+ $(methods).each( function(i) {
255
+ $('div$methods img#shipping_loader').remove();
256
+ var p = document.createElement('p');
257
+ var s = this.name + ' ' + this.rate;
258
+ $(p).append($(document.createElement('input'))
259
+ .attr('id', s)
260
+ .attr('type', 'radio')
261
+ .attr('name', 'method_id')
262
+ .attr(1 == $(methods).length ? 'checked' : 'notchecked', 'foo')
263
+ .val(this.id)
264
+ );
265
+ $(p).append($(document.createElement('label'))
266
+ .attr('for', s)
267
+ .html(s)
268
+ .css('top', '-1px'));
269
+ $('div#methods').append(p);
270
+ });
271
+ $('div#methods input:first').attr('validate', 'required:true');
272
+ return;
273
+ }
274
+
275
+ var update_confirmation = function(order) {
276
+ $('span#order_total').html(order.order_total);
277
+ $('span#ship_amount').html(order.ship_amount);
278
+ $('span#tax_amount').html(order.tax_amount);
279
+ $('span#ship_method').html(order.ship_method);
280
+ }
281
+
282
+ var confirm_payment = function() {
283
+ shift_to_region('confirm_order');
284
+ };