spree 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree might be problematic. Click here for more details.

Files changed (182) hide show
  1. data/CHANGELOG +35 -0
  2. data/CONTRIBUTORS +2 -1
  3. data/README.markdown +8 -52
  4. data/app/controllers/account_controller.rb +1 -1
  5. data/app/controllers/addresses_controller.rb +5 -1
  6. data/app/controllers/admin/inventory_settings_controller.rb +13 -0
  7. data/app/controllers/admin/option_types_controller.rb +1 -1
  8. data/app/controllers/admin/orders_controller.rb +14 -8
  9. data/app/controllers/admin/products_controller.rb +2 -0
  10. data/app/controllers/admin/variants_controller.rb +7 -0
  11. data/app/controllers/content_controller.rb +5 -0
  12. data/app/controllers/creditcard_payments_controller.rb +2 -2
  13. data/app/controllers/orders_controller.rb +18 -2
  14. data/app/helpers/admin/inventory_settings_helper.rb +5 -0
  15. data/app/helpers/admin/product_properties_helper.rb +10 -2
  16. data/app/helpers/products_helper.rb +2 -2
  17. data/app/models/address.rb +2 -2
  18. data/app/models/app_configuration.rb +1 -0
  19. data/app/models/creditcard_payment.rb +6 -14
  20. data/app/models/order.rb +6 -12
  21. data/app/models/order_filter.rb +1 -0
  22. data/app/models/product.rb +9 -0
  23. data/app/models/product_property.rb +1 -0
  24. data/app/models/property.rb +0 -1
  25. data/app/models/zone.rb +17 -3
  26. data/app/views/account/login.html.erb +2 -14
  27. data/app/views/admin/configurations/index.html.erb +4 -0
  28. data/app/views/admin/inventory_settings/edit.html.erb +18 -0
  29. data/app/views/admin/inventory_settings/show.html.erb +11 -0
  30. data/app/views/admin/orders/_address.html.erb +1 -1
  31. data/app/views/admin/orders/index.html.erb +5 -1
  32. data/app/views/admin/orders/show.html.erb +3 -3
  33. data/app/views/admin/product_properties/_product_property.html.erb +6 -3
  34. data/app/views/admin/products/_form.html.erb +9 -1
  35. data/app/views/admin/prototypes/select.rjs +3 -1
  36. data/app/views/admin/variants/_form.html.erb +6 -0
  37. data/app/views/admin/variants/index.html.erb +7 -1
  38. data/app/views/creditcard_payments/_form_credit_card.html.erb +1 -1
  39. data/app/views/creditcard_payments/new.html.erb +7 -2
  40. data/app/views/products/show.html.erb +8 -2
  41. data/app/views/shared/_login.html.erb +17 -0
  42. data/app/views/shared/_products.html.erb +1 -1
  43. data/app/views/users/_form.html.erb +1 -1
  44. data/app/views/users/new.html.erb +19 -8
  45. data/config/boot.rb +1 -1
  46. data/config/database.yml +7 -3
  47. data/config/environment.rb +16 -2
  48. data/config/routes.rb +4 -0
  49. data/db/migrate/20081016002224_remove_defunct_order_fields.rb +10 -0
  50. data/db/migrate/20081016162924_drop_category_id_from_products.rb +9 -0
  51. data/db/sample/addresses.yml +14 -0
  52. data/db/sample/orders.yml +0 -1
  53. data/lang/ui/de-DE.yml +2 -1
  54. data/lang/ui/en-US.yml +50 -25
  55. data/lang/ui/es-ES.yml +2 -1
  56. data/lang/ui/it-IT.yml +2 -1
  57. data/lang/ui/pl-PL.yml +1 -0
  58. data/lang/ui/pt-BR.yml +5 -2
  59. data/lib/authenticated_system.rb +1 -1
  60. data/lib/generators/extension/extension_generator.rb +1 -0
  61. data/lib/generators/extension/templates/extension.rb +4 -5
  62. data/lib/generators/extension/templates/tasks.rake +12 -0
  63. data/lib/generators/extension_migration/extension_migration_generator.rb +32 -0
  64. data/lib/generators/extension_migration/templates/migration.rb +7 -0
  65. data/lib/spree.rb +2 -2
  66. data/lib/spree/extension.rb +0 -7
  67. data/lib/spree/extension_loader.rb +0 -8
  68. data/lib/tasks/extensions.rake +47 -0
  69. data/public/javascripts/application.js +34 -0
  70. data/public/javascripts/spree-yui.js +2 -2
  71. data/public/stylesheets/spree.css +11 -1
  72. data/spec/fixtures/preferences.yml +14 -6
  73. data/spec/models/address_spec.rb +78 -0
  74. data/spec/models/country_spec.rb +29 -0
  75. data/spec/models/option_type_spec.rb +36 -0
  76. data/spec/models/option_value_spec.rb +39 -0
  77. data/spec/models/product_option_type_spec.rb +38 -0
  78. data/spec/models/product_property_spec.rb +36 -0
  79. data/spec/models/product_spec.rb +109 -32
  80. data/spec/models/property_spec.rb +38 -0
  81. data/spec/models/prototype_spec.rb +35 -0
  82. data/spec/models/state_spec.rb +28 -0
  83. data/spec/models/taxon_spec.rb +38 -0
  84. data/spec/models/taxonomy_spec.rb +37 -0
  85. data/spec/models/variant_spec.rb +73 -12
  86. data/spec/models/zone_spec.rb +35 -15
  87. data/spec/spec_helper.rb +15 -0
  88. data/spec/views/admin/configurations/index.html.erb_spec.rb +29 -0
  89. data/spec/views/admin/mail_settings/show.html.erb_spec.rb +3 -3
  90. data/spec/views/products/index.html.erb_spec.rb +46 -0
  91. data/spec/views/products/show.html.erb_spec.rb +46 -0
  92. data/vendor/extensions/flat_rate_shipping/README.markdown +3 -0
  93. data/vendor/extensions/flat_rate_shipping/Rakefile +120 -0
  94. data/vendor/extensions/flat_rate_shipping/flat_rate_shipping_extension.rb +17 -0
  95. data/vendor/extensions/flat_rate_shipping/lib/flat_rate_shipping_configuration.rb +7 -0
  96. data/vendor/extensions/flat_rate_shipping/lib/spree/flat_rate_shipping/calculator.rb +9 -0
  97. data/vendor/extensions/flat_rate_shipping/lib/spree/flat_rate_shipping/config.rb +22 -0
  98. data/vendor/extensions/flat_rate_shipping/lib/tasks/flat_rate_shipping_extension_tasks.rake +29 -0
  99. data/vendor/extensions/flat_rate_shipping/spec/spec.opts +6 -0
  100. data/vendor/extensions/flat_rate_shipping/spec/spec_helper.rb +37 -0
  101. data/vendor/extensions/localization/localization_extension.rb +1 -6
  102. data/vendor/extensions/payment_gateway/lib/gateway_config.rb +7 -0
  103. data/vendor/extensions/payment_gateway/lib/spree/gateway/config.rb +22 -0
  104. data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +27 -3
  105. data/vendor/extensions/payment_gateway/payment_gateway_extension.rb +0 -4
  106. data/vendor/extensions/shipping/README.markdown +3 -0
  107. data/vendor/extensions/shipping/Rakefile +120 -0
  108. data/vendor/extensions/shipping/app/controllers/admin/shipping_categories_controller.rb +17 -0
  109. data/vendor/extensions/shipping/app/controllers/admin/shipping_methods_controller.rb +21 -0
  110. data/vendor/extensions/shipping/app/controllers/shipments_controller.rb +84 -0
  111. data/vendor/extensions/shipping/app/helpers/admin/shipping_categories_helper.rb +2 -0
  112. data/vendor/extensions/shipping/app/helpers/admin/shipping_methods_helper.rb +2 -0
  113. data/vendor/extensions/shipping/app/helpers/shipments_helper.rb +20 -0
  114. data/vendor/extensions/shipping/app/models/shipment.rb +11 -0
  115. data/vendor/extensions/shipping/app/models/shipping_category.rb +3 -0
  116. data/vendor/extensions/shipping/app/models/shipping_method.rb +12 -0
  117. data/vendor/extensions/shipping/app/views/admin/shipping_categories/_form.html.erb +6 -0
  118. data/vendor/extensions/shipping/app/views/admin/shipping_categories/edit.html.erb +8 -0
  119. data/vendor/extensions/shipping/app/views/admin/shipping_categories/index.html.erb +24 -0
  120. data/vendor/extensions/shipping/app/views/admin/shipping_categories/new.html.erb +10 -0
  121. data/vendor/extensions/shipping/app/views/admin/shipping_methods/_form.html.erb +14 -0
  122. data/vendor/extensions/shipping/app/views/admin/shipping_methods/edit.html.erb +8 -0
  123. data/vendor/extensions/shipping/app/views/admin/shipping_methods/index.html.erb +28 -0
  124. data/vendor/extensions/shipping/app/views/admin/shipping_methods/new.html.erb +10 -0
  125. data/vendor/extensions/shipping/app/views/orders/fatal_shipping.html.erb +6 -0
  126. data/vendor/extensions/shipping/app/views/shipments/_form.html.erb +46 -0
  127. data/vendor/extensions/shipping/app/views/shipments/edit.html.erb +8 -0
  128. data/vendor/extensions/shipping/app/views/shipments/new.html.erb +8 -0
  129. data/vendor/extensions/shipping/db/migrate/20081003211336_create_shipping_methods.rb +14 -0
  130. data/vendor/extensions/shipping/db/migrate/20081003233427_create_shipping_categories.rb +15 -0
  131. data/vendor/extensions/shipping/db/migrate/20081015001711_create_shipments.rb +14 -0
  132. data/vendor/extensions/shipping/db/migrate/20081023134446_add_product_dimensions.rb +19 -0
  133. data/vendor/extensions/shipping/db/sample/shipping_categories.yml +2 -0
  134. data/vendor/extensions/shipping/db/sample/shipping_methods.yml +12 -0
  135. data/vendor/extensions/shipping/db/sample/zone_members.yml +8 -0
  136. data/vendor/extensions/shipping/db/sample/zones.yml +3 -0
  137. data/vendor/extensions/shipping/lang/en-US.yml +9 -0
  138. data/vendor/extensions/shipping/lib/spree/shipping_calculator.rb +37 -0
  139. data/vendor/extensions/shipping/lib/spree/shipping_error.rb +3 -0
  140. data/vendor/extensions/shipping/lib/tasks/shipping_extension_tasks.rake +29 -0
  141. data/vendor/extensions/shipping/shipping_extension.rb +39 -0
  142. data/vendor/extensions/shipping/spec/controllers/admin/shipping_categories_controller_spec.rb +10 -0
  143. data/vendor/extensions/shipping/spec/controllers/admin/shipping_methods_controller_spec.rb +10 -0
  144. data/vendor/extensions/shipping/spec/models/order_spec.rb +98 -0
  145. data/vendor/extensions/shipping/spec/models/shipment_spec.rb +26 -0
  146. data/vendor/extensions/shipping/spec/models/shipping_category_spec.rb +8 -0
  147. data/vendor/extensions/shipping/spec/models/shipping_method_spec.rb +53 -0
  148. data/vendor/extensions/shipping/spec/spec.opts +6 -0
  149. data/vendor/extensions/shipping/spec/spec_helper.rb +37 -0
  150. data/vendor/extensions/tax_calculator/lib/spree/sales_tax_calculator.rb +12 -4
  151. data/vendor/extensions/tax_calculator/spec/controllers/tax_calculator_spec.rb +0 -4
  152. data/vendor/extensions/tax_calculator/spec/models/sales_tax_calculator_spec.rb +14 -14
  153. data/vendor/extensions/tax_calculator/tax_calculator_extension.rb +0 -4
  154. data/vendor/plugins/resource_controller/README.rdoc +38 -6
  155. data/vendor/plugins/resource_controller/Rakefile +7 -20
  156. data/vendor/plugins/resource_controller/TODO +0 -1
  157. data/vendor/plugins/resource_controller/lib/resource_controller/helpers/current_objects.rb +71 -69
  158. data/vendor/plugins/resource_controller/lib/resource_controller/helpers/internal.rb +69 -65
  159. data/vendor/plugins/resource_controller/lib/resource_controller/helpers/nested.rb +62 -57
  160. data/vendor/plugins/resource_controller/lib/resource_controller/helpers/singleton_customizations.rb +50 -46
  161. data/vendor/plugins/resource_controller/lib/resource_controller/helpers/urls.rb +73 -69
  162. data/vendor/plugins/resource_controller/resource_controller.gemspec +4 -3
  163. data/vendor/plugins/resource_controller/test/app/controllers/cms/personnel_controller.rb +2 -0
  164. data/vendor/plugins/resource_controller/test/app/controllers/cms/photos_controller.rb +6 -0
  165. data/vendor/plugins/resource_controller/test/app/models/personnel.rb +3 -0
  166. data/vendor/plugins/resource_controller/test/app/models/photo.rb +1 -0
  167. data/vendor/plugins/resource_controller/test/app/views/cms/photos/edit.rhtml +17 -0
  168. data/vendor/plugins/resource_controller/test/app/views/cms/photos/index.rhtml +20 -0
  169. data/vendor/plugins/resource_controller/test/app/views/cms/photos/new.rhtml +16 -0
  170. data/vendor/plugins/resource_controller/test/app/views/cms/photos/show.rhtml +8 -0
  171. data/vendor/plugins/resource_controller/test/config/database.yml +9 -0
  172. data/vendor/plugins/resource_controller/test/config/environment.rb +1 -18
  173. data/vendor/plugins/resource_controller/test/config/initializers/inflections.rb +14 -0
  174. data/vendor/plugins/resource_controller/test/config/routes.rb +3 -0
  175. data/vendor/plugins/resource_controller/test/db/migrate/013_create_personnel.rb +11 -0
  176. data/vendor/plugins/resource_controller/test/db/migrate/014_add_personnel_id_to_photos.rb +9 -0
  177. data/vendor/plugins/resource_controller/test/test/fixtures/personnel.yml +5 -0
  178. data/vendor/plugins/resource_controller/test/test/functional/cms/photos_controller_test.rb +43 -0
  179. metadata +136 -6
  180. data/app/models/spree/extension_meta.rb +0 -5
  181. data/app/models/variants.rb +0 -2
  182. data/vendor/plugins/resource_controller/lib/resource_controller/version.rb +0 -9
data/CHANGELOG CHANGED
@@ -1,3 +1,38 @@
1
+ == 0.5.0
2
+
3
+ * # 55 - Variants need shipping weights to do shipping calculations.
4
+ * # 66 - Add a migration generator for extensions
5
+ * # 83 - Internal Server Error when adding product property to product
6
+ * # 90 - Support for sample data in extensions
7
+ * # 91 - Shipping address should be limited to the countries that are configured by a shipping zone
8
+ * # 92 - Configuration screen for inventory settings.
9
+ * # 95 - Bogus gateway should decline card instead of raising an exception
10
+ * # 96 - Creating first Taxon fails with blank database
11
+ * # 97 - Exception when returning to cart from shipping method selection screen
12
+ * # 98 - Exception occurs when changing country dropdown for Ship Address
13
+ * # 99 - Provide built-in mechanism for dealing with near static content
14
+ * # 100 - Add support for require gems inside extensions and an easy way to install them.
15
+ * # 101 - Add configuration setting to make bogus gateway in development mode optional
16
+ * # 102 - Credit card information is not being stored.
17
+ * # 103 - Rails 2.1.2 Support
18
+ * # 105 - Error when viewing order with non US state in either address.
19
+ * # 106 - Adding a new variant causes NoMethodError
20
+ * # 107 - SKU not saving for products (empty variant)
21
+ * # 108 - Correct after_transition for paid state in Order model
22
+ * # 109 - Add pruchase method to Spree::PaymentGateway
23
+ * # 110 - Empty address cannot be validated
24
+ * # 112 - Check for user before emailing order confirmations
25
+ * # 113 - Property model references bogus value table.
26
+ * # 114 - Remove unsupported deactivate method from extensions
27
+ * # 116 - Updating option types causes all option values to disappear
28
+ * # 118 - Default authenticaiton screen should be login
29
+ * # 119 - Include login fields on user creation screen
30
+ * # 120 - Orders search does not return any results.
31
+ * # 122 - Credit card Number text field enforces 17 character restriction
32
+ * # 124 - Move the pay action out of the FSM for order.
33
+ * # 125 - Sales Tax calculation causes exception
34
+ * # 126 - Incomplete orders are appearing in admin orders views.
35
+
1
36
  == 0.4.1
2
37
 
3
38
  * #94 - User must be logged in to empty cart
data/CONTRIBUTORS CHANGED
@@ -14,6 +14,7 @@ core:
14
14
  * Sonny Cook
15
15
  * Brian Quinn
16
16
  * Paul Saieg
17
+ * Edmundo Valle Neto
17
18
  * Gregg Pollack
18
19
  * Jon Jensen
19
20
  * Fabio Akita
@@ -25,8 +26,8 @@ core:
25
26
  * Chris Gaskett
26
27
  * Will Emerson
27
28
  * Ricardo Shiota Yasuda
28
- * Edmundo Valle Neto
29
29
  * tom
30
+ * Yves Dufour
30
31
 
31
32
  == Legacy Contributors
32
33
 
data/README.markdown CHANGED
@@ -14,16 +14,18 @@ Running from sources (latest and greatest features)
14
14
  1. Clone the git repo
15
15
 
16
16
  git clone git://github.com/schof/spree.git spree
17
+
18
+ 2. Create the necessary config/database.yml file
17
19
 
18
- 2. Install the gem dependencies
20
+ 3. Install the gem dependencies
19
21
 
20
22
  rake gems:install
21
23
 
22
- 3. Bootstrap the database (run the migrations, create admin account, optionally load sample data.)
24
+ 4. Bootstrap the database (run the migrations, create admin account, optionally load sample data.)
23
25
 
24
26
  rake db:bootstrap
25
27
 
26
- 4. Start the server
28
+ 5. Start the server
27
29
 
28
30
  script/server
29
31
 
@@ -72,8 +74,8 @@ Deploy spree as a normal rails application. If you use apache+cgi/fastcgi take a
72
74
 
73
75
  public/.htaccess.example
74
76
 
75
- i18n/l10n Support?
76
- ==================
77
+ i18n/l10n Support
78
+ =================
77
79
 
78
80
  **Basic** localization and internationalization **support** is now
79
81
  added using the [Globalite Plugin][1] from Matt Aimonetti.
@@ -98,50 +100,4 @@ to be done.
98
100
  [3]: http://code.google.com/p/globalite/wiki/UI_Localization
99
101
  [4]: http://code.google.com/p/globalite/wiki/PluralizationSupport
100
102
 
101
- **UPDATE:** Take a look at [i18n page on Spree wiki](http://support.spreehq.org/wiki/1/I18n)
102
-
103
- Is Spree Ready for Production?
104
- ==============================
105
-
106
- I have been asked by several people about the status of the Spree
107
- project. I thought I would take a moment to address the current state
108
- of the codebase and whether or not its “production ready.”
109
-
110
- In my opinion, you can use Spree in a real world commerce application
111
- right now. This is especially true if you are already committed to
112
- using Ruby on Rails. What are the drawbacks to doing this? The major
113
- drawback is that Spree is still “rough around the edges” so you will
114
- be doing a lot of the polishing yourself. For instance, if you want to
115
- have FedEx shipping calculations you will need to write/port your own.
116
- On the other hand, the basic admin functionality is working and the
117
- ActiveMerchant plugin support means you don’t have to worry about
118
- credit cards. In fact, I have already built two production sites with
119
- this software (under the old RailsCart name).
120
-
121
- The only other Rails commerce application I am aware of is Substruct.
122
- The last I looked at this project it was fairly basic as well. So if
123
- you are going to start building your Rails project today, you have
124
- three choices.
125
-
126
- 1. Write your own
127
- 2. Use Spree as your starting point and do lots of custom coding
128
- 3. Use Substruct as your starting point and do lots of custom coding
129
-
130
- If you are uncomfortable with these three options then you should
131
- consider another application framework.
132
-
133
- The good news is that Spree is rapidly improving with each passing
134
- day. The major effort right now is to rejigger the data model so that
135
- it is rock solid. There is nothing “wrong” with the current data model
136
- which is why it is ok to build a production Spree app with the
137
- existing software. We’re just trying to make the data model as “future
138
- proof” as possible. The more we improve the data model now, the less
139
- disruptive it will be for users to upgrade to subsequent versions of
140
- the software.
141
-
142
- When will this refactoring be done? Our goal is to have our first beta
143
- release in time for RailsConf (May 29). This means we will pushing
144
- hard for another 6-8 weeks on all things data model. Once we go “beta”
145
- we be on the next level of stability. There will be a lot less coding
146
- needed to use Spree for your production site and we also hope to have
147
- a standardized approach for the custom code you do need to write.
103
+ **UPDATE:** Take a look at [i18n page on Spree wiki](http://support.spreehq.org/wiki/1/I18n)
@@ -2,7 +2,7 @@ class AccountController < Spree::BaseController
2
2
  before_filter :login_from_cookie
3
3
 
4
4
  def index
5
- redirect_to(signup_path) unless logged_in? || User.count > 0
5
+ redirect_to(login_path) unless logged_in? || User.count > 0
6
6
  end
7
7
 
8
8
  def login
@@ -1,6 +1,7 @@
1
1
  class AddressesController < Admin::BaseController
2
2
  before_filter :check_existing, :only => :new
3
3
  before_filter :load_data
4
+ before_filter :load_countries, :except => :country_changed
4
5
  layout 'application'
5
6
  resource_controller :singleton
6
7
 
@@ -38,7 +39,10 @@ class AddressesController < Admin::BaseController
38
39
  @selected_country_id ||= Spree::Config[:default_country_id]
39
40
 
40
41
  @states = State.find_all_by_country_id(@selected_country_id, :order => 'name')
41
- @countries = Country.find(:all)
42
+ end
43
+
44
+ def load_countries
45
+ @countries = Country.all
42
46
  end
43
47
 
44
48
  def next_step
@@ -0,0 +1,13 @@
1
+ class Admin::InventorySettingsController < Admin::BaseController
2
+
3
+ def update
4
+ Spree::Config.set(params[:preferences])
5
+
6
+ respond_to do |format|
7
+ format.html {
8
+ redirect_to admin_inventory_settings_path
9
+ }
10
+ end
11
+ end
12
+
13
+ end
@@ -30,7 +30,7 @@ class Admin::OptionTypesController < Admin::BaseController
30
30
  end
31
31
 
32
32
  update.before do
33
- params[:option_type][:option_values] ||= {}
33
+ params[:option_type][:option_value_attributes] ||= {}
34
34
  end
35
35
 
36
36
  # redirect to index (instead of r_c default of show view)
@@ -36,24 +36,30 @@ class Admin::OrdersController < Admin::BaseController
36
36
 
37
37
  private
38
38
  def collection
39
- @filter = OrderFilter.new(params[:filter])
39
+ @filter = params.has_key?(:filter) ? OrderFilter.new(params[:filter]) : OrderFilter.new(:checkout => "1")
40
+
41
+ scopes = []
40
42
  if params[:filter] and @filter.valid?
41
43
  default_stop = (Date.today + 1).to_s(:db)
42
- scopes = []
43
- scopes << [ :by_number, @filter.number ] if @filter.number
44
+
45
+ scopes << [ :by_number, @filter.number ] unless @filter.number.blank?
44
46
  scopes << [ :by_customer, @filter.customer ] unless @filter.customer.blank?
45
47
  scopes << [ :between, @filter.start, (@filter.stop.blank? ? default_stop : @filter.stop) ] unless @filter.start.blank?
46
48
  scopes << [ :by_state, @filter.state.tableize.singularize.gsub(" ", "_") ] unless @filter.state.blank?
47
- @collection = (scopes.inject(Order) {|m,v| m.scopes[v.shift].call(m, *v) }).find(:all, :order => 'orders.created_at DESC', :include => :user,
48
- :page => {:size => 15, :current =>params[:p], :first => 1})
49
+ scopes << [ :checkout_completed, @filter.checkout=='1' ? true : false] unless @filter.checkout.blank?
50
+ else
51
+ scopes << [ :checkout_completed, true]
49
52
  end
50
-
51
- @collection ||= end_of_association_chain.find(:all, :order => 'created_at DESC', :include => :user,
52
- :page => {:size => 15, :current =>params[:p], :first => 1})
53
+
54
+
55
+ @collection = (scopes.inject(Order) {|m,v| m.scopes[v.shift].call(m, *v) }).find(:all, :order => 'orders.created_at DESC', :include => :user,
56
+ :page => {:size => 15, :current =>params[:p], :first => 1})
57
+
53
58
  end
54
59
 
55
60
  # Allows extensions to add new forms of payment to provide their own display of transactions
56
61
  def initialize_txn_partials
57
62
  @txn_partials = []
58
63
  end
64
+
59
65
  end
@@ -18,6 +18,7 @@ class Admin::ProductsController < Admin::BaseController
18
18
  private
19
19
  def load_data
20
20
  @tax_categories = TaxCategory.find(:all, :order=>"name")
21
+ @shipping_categories = ShippingCategory.find(:all, :order=>"name")
21
22
  end
22
23
 
23
24
  def set_image
@@ -44,6 +45,7 @@ class Admin::ProductsController < Admin::BaseController
44
45
  @object.available_on = Time.now
45
46
  @object.variants << Variant.new(:product => @object)
46
47
  end
48
+ @object.variant.sku = params[:product] ? params[:product][:sku] : ""
47
49
  @object
48
50
  end
49
51
  end
@@ -1,6 +1,7 @@
1
1
  class Admin::VariantsController < Admin::BaseController
2
2
  resource_controller
3
3
  belongs_to :product
4
+ before_filter :load_data, :only => [:index, :edit, :new]
4
5
 
5
6
  new_action.response do |wants|
6
7
  wants.html {render :action => :new, :layout => false}
@@ -22,4 +23,10 @@ class Admin::VariantsController < Admin::BaseController
22
23
  wants.html {redirect_to collection_url}
23
24
  end
24
25
 
26
+ private
27
+ def load_data
28
+ # this allows extensions to provide their own additional columns in the index and edit views
29
+ @additional_fields = Variant.column_names - ["id", "price", "sku", "product_id"]
30
+ end
31
+
25
32
  end
@@ -0,0 +1,5 @@
1
+ class ContentController < Spree::BaseController
2
+ def show
3
+ render :action => params[:path].join('/')
4
+ end
5
+ end
@@ -13,8 +13,8 @@ class CreditcardPaymentsController < Admin::BaseController
13
13
  creditcard_payment.creditcard = @payment_presenter.creditcard
14
14
  begin
15
15
  creditcard_payment.save
16
- rescue SecurityError => se
17
- flash.now[:error] = "Authorization Error: #{se.message}"
16
+ rescue Spree::GatewayError => ge
17
+ flash.now[:error] = "Authorization Error: #{ge.message}"
18
18
  render :action => "new" and return
19
19
  end
20
20
  @order.next!
@@ -1,5 +1,5 @@
1
1
  class OrdersController < Admin::BaseController
2
- before_filter :login_required, :except => [:create, :edit, :update]
2
+ before_filter :login_required, :only => [:checkout]
3
3
  before_filter :load_object, :only => [:checkout]
4
4
  layout 'application'
5
5
 
@@ -49,7 +49,23 @@ class OrdersController < Admin::BaseController
49
49
  flash nil
50
50
  wants.html {redirect_to new_order_url}
51
51
  end
52
-
52
+
53
+ protected
54
+ # Custom access denied action for orders. In the case of an order, we'd like the user to be presented with a user
55
+ # signup screen (as opposed to login) since its likely the user does not yet have an account. The signup screen
56
+ # also contains a link to the login screen if they already have an account.
57
+ def access_denied
58
+ respond_to do |format|
59
+ format.html do
60
+ store_location
61
+ redirect_to signup_path
62
+ end
63
+ format.xml do
64
+ request_http_basic_authentication 'Web Password'
65
+ end
66
+ end
67
+ end
68
+
53
69
  private
54
70
  def build_object
55
71
  find_order
@@ -0,0 +1,5 @@
1
+ module Admin::InventorySettingsHelper
2
+ def show_not(true_or_false)
3
+ true_or_false ? '' : 'not'
4
+ end
5
+ end
@@ -3,11 +3,19 @@ module Admin::ProductPropertiesHelper
3
3
  # Generates the appropriate field name for attribute_fu. Normally attribute_fu handles this but we've got a
4
4
  # special case where we need text_field_with_autocomplete and we have to recreate attribute_fu's naming
5
5
  # scheme manually.
6
- def property_fu_name(product_property)
6
+ def property_fu_name(product_property, number)
7
7
  if product_property.new_record?
8
- "product[product_property_attributes][new][-1][property_name]"
8
+ "product[product_property_attributes][new][#{number}][property_name]"
9
9
  else
10
10
  "product[product_property_attributes][#{product_property.id}][property_name]"
11
11
  end
12
12
  end
13
+
14
+ def property_fu_value(product_property, number)
15
+ if product_property.new_record?
16
+ "product[product_property_attributes][new][#{number}][value]"
17
+ else
18
+ "product[product_property_attributes][#{product_property.id}][value]"
19
+ end
20
+ end
13
21
  end
@@ -16,9 +16,9 @@ module ProductsHelper
16
16
  diff = product_price(variant, :format_as_currency => false) - product_price(variant.product, :format_as_currency => false)
17
17
  return nil if diff == 0
18
18
  if diff > 0
19
- "(Add: #{format_price diff.abs})"
19
+ "(#{t("Add")}: #{format_price diff.abs})"
20
20
  else
21
- "(Subtract: #{format_price diff.abs})"
21
+ "(#{t("Subtract")}: #{format_price diff.abs})"
22
22
  end
23
23
  end
24
24
 
@@ -7,8 +7,8 @@ class Address < ActiveRecord::Base
7
7
  validates_presence_of :lastname
8
8
  validates_presence_of :address1
9
9
  validates_presence_of :city
10
- validates_presence_of :state, :unless => Proc.new { |address| address.country.states.length==0 }
11
- validates_presence_of :state_name, :if => Proc.new { |address| address.country.states.length==0 }
10
+ validates_presence_of :state, :unless => Proc.new { |address| address.country && address.country.states.length==0 }
11
+ validates_presence_of :state_name, :if => Proc.new { |address| address.country && address.country.states.length==0 }
12
12
  validates_presence_of :zipcode
13
13
  validates_presence_of :country
14
14
  validates_presence_of :phone
@@ -21,6 +21,7 @@ class AppConfiguration < Configuration
21
21
  preference :default_country_id, :integer, :default => 214
22
22
  preference :allow_backorders, :boolean, :default => true
23
23
  preference :show_descendents, :boolean, :default => true
24
+ preference :show_zero_stock_products, :boolean, :default => true
24
25
 
25
26
  validates_presence_of :name
26
27
  validates_uniqueness_of :name
@@ -14,6 +14,12 @@ class CreditcardPayment < ActiveRecord::Base
14
14
  def creditcard=(creditcard)
15
15
  @creditcard = creditcard
16
16
  self.cc_type = ActiveMerchant::Billing::CreditCard.type?(creditcard.number)
17
+ self.number = creditcard.number if Spree::Config[:store_cc]
18
+ self.display_number = creditcard.display_number
19
+ self.month = creditcard.month
20
+ self.year = creditcard.year
21
+ self.first_name = creditcard.first_name
22
+ self.last_name = creditcard.last_name
17
23
  end
18
24
 
19
25
  def find_authorization
@@ -23,18 +29,4 @@ class CreditcardPayment < ActiveRecord::Base
23
29
  :conditions => ["txn_type = ? or txn_type = ?", CreditcardTxn::TxnType::AUTHORIZE, CreditcardTxn::TxnType::CAPTURE],
24
30
  :order => 'created_at DESC')
25
31
  end
26
-
27
- # creates a new instance of CreditCard using the active merchant version
28
- def self.new_from_active_merchant(cc)
29
- card = self.new
30
- card.number = cc.number if Spree::Config[:store_cc]
31
- card.cc_type = ActiveMerchant::Billing::CreditCard.type?(cc.number)
32
- card.display_number = cc.display_number
33
- card.verification_value = cc.verification_value if Spree::Config[:store_cc]
34
- card.month = cc.month
35
- card.year = cc.year
36
- card.first_name = cc.first_name
37
- card.last_name = cc.last_name
38
- card
39
- end
40
32
  end
data/app/models/order.rb CHANGED
@@ -12,9 +12,7 @@ class Order < ActiveRecord::Base
12
12
  has_many :state_events
13
13
  has_one :creditcard_payment
14
14
  belongs_to :user
15
- has_one :address, :as => :addressable
16
- belongs_to :bill_address, :class_name => "Address", :foreign_key => :bill_address_id
17
- belongs_to :ship_address, :class_name => "Address", :foreign_key => :ship_address_id
15
+ has_one :address, :as => :addressable, :dependent => :destroy
18
16
 
19
17
  validates_associated :line_items, :message => "are not valid"
20
18
  validates_numericality_of :tax_amount
@@ -26,6 +24,8 @@ class Order < ActiveRecord::Base
26
24
  named_scope :between, lambda {|*dates| {:conditions => ["orders.created_at between :start and :stop", {:start => dates.first.to_date, :stop => dates.last.to_date}]}}
27
25
  named_scope :by_customer, lambda {|customer| {:include => :user, :conditions => ["users.email = ?", customer]}}
28
26
  named_scope :by_state, lambda {|state| {:conditions => ["state = ?", state]}}
27
+ named_scope :checkout_completed, lambda {|state| {:conditions => ["checkout_complete = ?", state]}}
28
+
29
29
 
30
30
  # attr_accessible is a nightmare with attachment_fu, so use attr_protected instead.
31
31
  attr_protected :ship_amount, :tax_amount, :item_total, :total, :user, :number, :ip_address, :checkout_complete, :state
@@ -34,7 +34,6 @@ class Order < ActiveRecord::Base
34
34
  state_machine :initial => 'in_progress' do
35
35
  after_transition :to => 'in_progress', :do => lambda {|order| order.update_attribute(:checkout_complete, false)}
36
36
  after_transition :to => 'authorized', :do => :complete_order
37
- after_transition :to => 'paid', :do => lambda {|order| InventoryUnit.sell_units(order)}
38
37
  after_transition :to => 'shipped', :do => :mark_shipped
39
38
  after_transition :to => 'canceled', :do => :cancel_order
40
39
  after_transition :to => 'returned', :do => :restock_inventory
@@ -54,15 +53,8 @@ class Order < ActiveRecord::Base
54
53
  event :capture do
55
54
  transition :to => 'captured', :from => 'authorized'
56
55
  end
57
- # the pay transition is not used by spree for default, just a starting point for offsite payment plugins
58
- # like google checkout, and paypal website payments pro. (no sense in having these types of extensions
59
- # defining possibly conflicting state names)
60
- event :pay do
61
- transition :to => 'paid', :from => 'pending_payment'
62
- end
63
56
  event :ship do
64
57
  transition :to => 'shipped', :from => 'captured'
65
- transition :to => 'shipped', :from => 'paid'
66
58
  # todo: also allow from authorized state (but we need to make sure capture is applied first)
67
59
  end
68
60
  event :cancel do
@@ -115,7 +107,9 @@ class Order < ActiveRecord::Base
115
107
  def complete_order
116
108
  self.update_attribute(:checkout_complete, true)
117
109
  InventoryUnit.sell_units(self)
118
- OrderMailer.deliver_confirm(self)
110
+ if user && user.email
111
+ OrderMailer.deliver_confirm(self)
112
+ end
119
113
  end
120
114
 
121
115
  def cancel_order