spree 0.6.0 → 0.7.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.
- data/CHANGELOG +30 -0
- data/CONTRIBUTORS +38 -20
- data/app/controllers/admin/creditcard_payments_controller.rb +10 -3
- data/app/controllers/admin/orders_controller.rb +17 -16
- data/app/controllers/admin/products_controller.rb +12 -14
- data/app/controllers/admin/reports_controller.rb +12 -14
- data/app/controllers/admin/users_controller.rb +10 -5
- data/app/controllers/admin/zones_controller.rb +4 -1
- data/app/controllers/application.rb +0 -1
- data/app/controllers/checkout_controller.rb +96 -0
- data/app/controllers/content_controller.rb +11 -1
- data/app/controllers/orders_controller.rb +12 -33
- data/app/controllers/products_controller.rb +12 -7
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/controllers/states_controller.rb +14 -2
- data/app/controllers/taxons_controller.rb +6 -2
- data/app/controllers/users_controller.rb +9 -6
- data/app/helpers/application_helper.rb +1 -11
- data/app/helpers/products_helper.rb +3 -1
- data/app/helpers/spree/base_helper.rb +0 -26
- data/app/models/address.rb +3 -3
- data/app/models/app_configuration.rb +1 -0
- data/app/models/country.rb +4 -0
- data/app/models/creditcard.rb +6 -1
- data/app/models/creditcard_payment.rb +1 -1
- data/app/models/inventory_unit.rb +4 -1
- data/app/models/order.rb +37 -21
- data/app/models/product.rb +19 -8
- data/{vendor/extensions/shipping/app → app}/models/shipment.rb +20 -4
- data/{vendor/extensions/shipping/app → app}/models/shipping_category.rb +0 -0
- data/{vendor/extensions/shipping/app → app}/models/shipping_method.rb +6 -4
- data/app/models/state.rb +5 -0
- data/app/models/user.rb +4 -2
- data/app/models/variant.rb +19 -1
- data/app/presenters/checkout_presenter.rb +58 -0
- data/app/views/admin/creditcard_payments/edit.html.erb +1 -1
- data/app/views/admin/option_types/available.html.erb +1 -1
- data/app/views/admin/orders/index.html.erb +28 -18
- data/app/views/admin/orders/show.html.erb +1 -1
- data/app/views/admin/payments/index.html.erb +1 -1
- data/app/views/admin/products/_images.html.erb +1 -1
- data/app/views/admin/products/index.html.erb +17 -13
- data/app/views/admin/users/index.html.erb +8 -8
- data/app/views/admin/zones/index.html.erb +5 -2
- data/app/views/checkout/_form.html.erb +165 -0
- data/app/views/{creditcards → checkout}/cvv.html.erb +1 -1
- data/app/views/checkout/new.html.erb +6 -0
- data/app/views/layouts/admin.html.erb +2 -3
- data/app/views/layouts/application.html.erb +1 -1
- data/app/views/orders/_form.html.erb +6 -4
- data/app/views/orders/_google_order.html.erb +24 -0
- data/app/views/orders/_line_item.html.erb +2 -1
- data/app/views/orders/show.html.erb +4 -1
- data/app/views/products/index.html.erb +2 -1
- data/app/views/products/show.html.erb +4 -4
- data/app/views/shared/_footer.html.erb +12 -1
- data/app/views/shared/_login.html.erb +1 -1
- data/app/views/shared/_order_details.html.erb +8 -9
- data/app/views/shared/_products.html.erb +1 -1
- data/app/views/shared/_report_criteria.html.erb +28 -28
- data/app/views/states/index.js.erb +10 -1
- data/config/environment.rb +10 -4
- data/config/initializers/searchlogic.rb +6 -0
- data/config/locales/de.yml +14 -0
- data/config/locales/en-GB.yml +20 -6
- data/config/locales/en-US.yml +20 -4
- data/config/locales/es.yml +14 -0
- data/config/locales/fr-FR.yml +463 -0
- data/config/locales/fr-FR_rails.yml +115 -0
- data/config/locales/it.yml +14 -0
- data/config/locales/nb-NO.yml +457 -0
- data/config/locales/nb-NO_rails.yml +105 -0
- data/config/locales/pl.yml +14 -0
- data/config/locales/pt-BR.yml +14 -0
- data/config/locales/pt-PT.yml +14 -0
- data/config/locales/ru-RU.yml +458 -0
- data/config/locales/ru-RU_rails.yml +154 -0
- data/config/routes.rb +11 -4
- data/db/migrate/20090204200045_add_order_permalink.rb +13 -0
- data/db/migrate/20090225231119_add_more_needed_keys_items_and_conf.rb +19 -0
- data/db/migrate/20090302221152_give_all_users_user_role.rb +13 -0
- data/db/sample/orders.yml +1 -1
- data/lib/generators/instance/instance_generator.rb +1 -1
- data/lib/spree.rb +1 -1
- data/lib/spree/setup.rb +1 -1
- data/lib/tasks/database.rake +5 -2
- data/lib/tasks/release.rake +1 -1
- data/lib/tasks/upgrade.rake +11 -0
- data/public/assets/products/1009/mini/sean.jpg +0 -0
- data/public/assets/products/1009/original/sean.jpg +0 -0
- data/public/assets/products/1009/product/sean.jpg +0 -0
- data/public/assets/products/1009/small/sean.jpg +0 -0
- data/public/images/ajax_loader.gif +0 -0
- data/public/javascripts/checkout.js +284 -0
- data/public/javascripts/jquery-1.3.2.min.js +19 -0
- data/public/javascripts/jquery.validate.pack.js +15 -0
- data/public/stylesheets/checkout.css +25 -0
- data/public/stylesheets/spree-admin.css +6 -2
- data/public/stylesheets/spree.css +419 -432
- data/spec/controllers/countries_controller_spec.rb +3 -2
- data/spec/controllers/orders_controller_spec.rb +7 -5
- data/spec/controllers/states_controller_spec.rb +4 -2
- data/spec/models/creditcard_payment_spec.rb +6 -2
- data/spec/models/order_spec.rb +164 -157
- data/spec/models/product_spec.rb +2 -2
- data/vendor/extensions/payment_gateway/db/migrate/20090218091936_create_protx_gateway.rb +18 -0
- data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +7 -5
- data/vendor/extensions/shipping/app/controllers/admin/shipments_controller.rb +6 -5
- data/vendor/extensions/shipping/app/views/admin/shipments/index.html.erb +1 -1
- data/vendor/extensions/shipping/config/locales/nb-NO.yml +25 -0
- data/vendor/extensions/shipping/config/locales/ru-RU.yml +25 -0
- data/vendor/extensions/shipping/db/sample/shipping_methods.yml +5 -1
- data/vendor/extensions/shipping/db/sample/zone_members.yml +9 -1
- data/vendor/extensions/shipping/db/sample/zones.yml +4 -1
- data/vendor/extensions/shipping/lib/spree/shipping_calculator.rb +0 -16
- data/vendor/extensions/shipping/shipping_extension.rb +0 -15
- data/vendor/extensions/shipping/spec/models/shipping_method_spec.rb +16 -10
- data/vendor/extensions/shipping/spec/models/shipping_order_spec.rb +3 -17
- data/vendor/extensions/tax_calculator/config/locales/nb-NO.yml +30 -0
- data/vendor/extensions/tax_calculator/spec/models/{order_spec.rb → order_tax_calc_spec.rb} +2 -2
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/.specification +3 -5
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/LICENSE +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/README +9 -2
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/Rakefile +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter.rb +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/base.rb +38 -8
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/version.rb +1 -1
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/doc.rake +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/gem.rake +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/base_test.rb +66 -30
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/test_helper.rb +36 -0
- data/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb +12 -4
- data/vendor/plugins/find_by_param/MIT-LICENSE +1 -1
- data/vendor/plugins/find_by_param/{README → README.markdown} +7 -1
- data/vendor/plugins/find_by_param/init.rb +0 -1
- data/vendor/plugins/find_by_param/lib/find_by_param.rb +23 -87
- data/vendor/plugins/find_by_param/test/find_by_param_test.rb +22 -8
- data/vendor/plugins/find_by_param/test/test_helper.rb +0 -1
- metadata +65 -193
- data/app/controllers/creditcards_controller.rb +0 -73
- data/app/models/order_filter.rb +0 -28
- data/app/models/user_filter.rb +0 -6
- data/app/views/creditcards/_form_credit_card.html.erb +0 -30
- data/app/views/creditcards/new.html.erb +0 -25
- data/app/views/shared/_paginate.html.erb +0 -34
- data/lib/plugins/paginating_find/CHANGELOG +0 -120
- data/lib/plugins/paginating_find/README +0 -89
- data/lib/plugins/paginating_find/init.rb +0 -2
- data/lib/plugins/paginating_find/lib/paginating_find.rb +0 -138
- data/lib/plugins/paginating_find/lib/paging_enumerator.rb +0 -158
- data/lib/plugins/paginating_find/lib/paging_helper.rb +0 -47
- data/lib/plugins/paginating_find/test_app/Rakefile +0 -10
- data/lib/plugins/paginating_find/test_app/app/controllers/application.rb +0 -2
- data/lib/plugins/paginating_find/test_app/config/boot.rb +0 -44
- data/lib/plugins/paginating_find/test_app/config/database.yml +0 -6
- data/lib/plugins/paginating_find/test_app/config/environment.rb +0 -53
- data/lib/plugins/paginating_find/test_app/config/environments/test.rb +0 -19
- data/lib/plugins/paginating_find/test_app/config/routes.rb +0 -22
- data/lib/plugins/paginating_find/test_app/script/breakpointer +0 -3
- data/lib/plugins/paginating_find/test_app/script/console +0 -3
- data/lib/plugins/paginating_find/test_app/test/fixtures/articles.yml +0 -19
- data/lib/plugins/paginating_find/test_app/test/fixtures/authors.yml +0 -7
- data/lib/plugins/paginating_find/test_app/test/fixtures/edits.yml +0 -11
- data/lib/plugins/paginating_find/test_app/test/fixtures/models.rb +0 -18
- data/lib/plugins/paginating_find/test_app/test/test_helper.rb +0 -33
- data/lib/plugins/paginating_find/test_app/test/unit/abstract_test.rb +0 -7
- data/lib/plugins/paginating_find/test_app/test/unit/group_test.rb +0 -40
- data/lib/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +0 -194
- data/lib/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +0 -143
- data/public/assets/products/1012/mini/bt.jpg +0 -0
- data/public/assets/products/1012/original/bt.jpg +0 -0
- data/public/assets/products/1012/product/bt.jpg +0 -0
- data/public/assets/products/1012/small/bt.jpg +0 -0
- data/spec/views/products/index.html.erb_spec.rb +0 -46
- data/spec/views/products/show.html.erb_spec.rb +0 -46
- data/vendor/extensions/shipping/app/controllers/shipments_controller.rb +0 -96
- data/vendor/extensions/shipping/app/helpers/shipments_helper.rb +0 -20
- data/vendor/extensions/shipping/app/views/orders/fatal_shipping.html.erb +0 -6
- data/vendor/extensions/shipping/app/views/shipments/_form.html.erb +0 -46
- data/vendor/extensions/shipping/app/views/shipments/edit.html.erb +0 -57
- data/vendor/extensions/shipping/app/views/shipments/new.html.erb +0 -10
data/CHANGELOG
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
== 0.7.0
|
2
|
+
|
3
|
+
* # 166 - Order numbers should also use permalink
|
4
|
+
* # 220 - Security holes in a few controllers
|
5
|
+
* # 234 - Sales tax should recalculate after a change in shipping address
|
6
|
+
* # 239 - Rake task for upgrade an existing Spree deployment
|
7
|
+
* # 242 - State events show the UTC version of the timestamp
|
8
|
+
* # 246 - Rake tasks failing if highline is not installed on the system
|
9
|
+
* # 247 - Restrict shipping methods based on order contents
|
10
|
+
* # 249 - Backorders not updated with new quantity
|
11
|
+
* # 251 - Missing message
|
12
|
+
* # 253 - Norwegian Translation
|
13
|
+
* # 255 - Admin has problems with "Available On"
|
14
|
+
* # 260 - Remove the automatic pay event from the order model
|
15
|
+
* # 261 - Do not allow creditcard capture without a response code
|
16
|
+
* # 263 - Support for Protx Gateway
|
17
|
+
* # 264 - Change credit card month and year to drop down
|
18
|
+
* # 265 - Google Analytics Order Tracking
|
19
|
+
* # 266 - Allow quantities when adding a variant to an order
|
20
|
+
* # 268 - Cannot cancel an incomplete order
|
21
|
+
* # 269 - Adjusting inventory on a 1 variant product does not update backorder status properly
|
22
|
+
* # 270 - Additional database indexes
|
23
|
+
* # 276 - French Translation
|
24
|
+
* # 277 - New users should be assigned the 'user' role by default
|
25
|
+
* # 278 - Allow backordering to be set at the variant level instead of all-or-nothing
|
26
|
+
* # 279 - No variant is pre-selected
|
27
|
+
* # 280 - Even deleted variants are available
|
28
|
+
* # 284 - Russian Translation
|
29
|
+
* # 288 - Credit card information should be filtered in logs
|
30
|
+
|
1
31
|
== 0.6.0
|
2
32
|
|
3
33
|
* # 129 - Public extension assets don't respect order when mirrored.
|
data/CONTRIBUTORS
CHANGED
@@ -4,30 +4,48 @@ Sean Schofield is the founder of the Spree project. It was originally started in
|
|
4
4
|
a Google Code project with the name Rails Cart. The name of the project was changed to Spree
|
5
5
|
in March 2008 in order to avoid any confusion about it being endorsed by the Ruby on Rails team.
|
6
6
|
|
7
|
-
== Contributors
|
7
|
+
== Contributors (Alphabetical)
|
8
8
|
|
9
9
|
The following people have submitted changes which have been applied to the
|
10
10
|
core:
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
Ben Marini
|
13
|
+
Bernd Ahlers
|
14
|
+
Bobby Santiago
|
15
|
+
Brian Quinn
|
16
|
+
Caius Durling
|
17
|
+
Chris Gaskett
|
18
|
+
Dale Hofkens
|
19
|
+
Edmundo Valle Neto
|
20
|
+
Eric Budd
|
21
|
+
Fabio Akita
|
22
|
+
Gregg Pollack
|
23
|
+
Jason Seifer
|
24
|
+
Jon Jensen
|
25
|
+
Jorge Calás Lozano
|
26
|
+
Joshua Nussbaum
|
27
|
+
Manuel Stuefer
|
28
|
+
Nate Murray
|
29
|
+
Paul Saieg
|
30
|
+
Peter Berkenbosch
|
31
|
+
Ricardo Shiota Yasuda
|
32
|
+
Robert Kuhr
|
33
|
+
Sean Schofield
|
34
|
+
Sonny Cook
|
35
|
+
Stephanie Powell
|
36
|
+
Tomasz Mazur
|
37
|
+
Tor Hovland
|
38
|
+
Will Emerson
|
39
|
+
Wynn Netherland
|
40
|
+
Yves Dufour
|
41
|
+
mjwall
|
42
|
+
mwestover
|
43
|
+
paulcc
|
44
|
+
pierre
|
45
|
+
ron
|
46
|
+
spariev
|
47
|
+
tom
|
48
|
+
yitzhakbg
|
31
49
|
|
32
50
|
== Legacy Contributors
|
33
51
|
|
@@ -50,9 +50,12 @@ class Admin::CreditcardPaymentsController < Admin::BaseController
|
|
50
50
|
if @creditcard_payment.can_capture?
|
51
51
|
creditcard = @creditcard_payment.creditcard
|
52
52
|
authorization = @creditcard_payment.find_authorization
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
Creditcard.transaction do
|
54
|
+
creditcard.order.state_events.create(:name => t('pay'), :user => current_user, :previous_state => creditcard.order.state)
|
55
|
+
creditcard.capture(authorization)
|
56
|
+
@creditcard_payment.amount = authorization.amount
|
57
|
+
@creditcard_payment.save
|
58
|
+
end
|
56
59
|
flash[:notice] = t("credit_card_capture_complete")
|
57
60
|
else
|
58
61
|
flash[:error] = t("unable_to_capture_credit_card")
|
@@ -69,6 +72,10 @@ class Admin::CreditcardPaymentsController < Admin::BaseController
|
|
69
72
|
|
70
73
|
@states = State.find_all_by_country_id(@selected_country_id, :order => 'name')
|
71
74
|
@countries = Country.find(:all)
|
75
|
+
|
76
|
+
month = (params[:payment_presenter] && params[:payment_presenter][:creditcard_month]) ? params[:payment_presenter][:creditcard_month].to_i : Date.today.month
|
77
|
+
year = (params[:payment_presenter] && params[:payment_presenter][:creditcard_year]) ? params[:payment_presenter][:creditcard_year].to_i : Date.today.year
|
78
|
+
@date = Date.new(year, month, 1)
|
72
79
|
end
|
73
80
|
|
74
81
|
def load_amount
|
@@ -24,27 +24,28 @@ class Admin::OrdersController < Admin::BaseController
|
|
24
24
|
|
25
25
|
def resend
|
26
26
|
OrderMailer.deliver_confirm(@order, true)
|
27
|
-
flash[:notice] = t('
|
27
|
+
flash[:notice] = t('order_email_resent')
|
28
28
|
redirect_to :back
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
|
-
|
33
|
-
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
|
33
|
+
def collection
|
34
|
+
@search = Order.new_search(params[:search])
|
35
|
+
|
36
|
+
if params[:search].nil? || params[:search][:conditions].nil?
|
37
|
+
@search.conditions.checkout_complete = true
|
38
|
+
end
|
39
|
+
|
40
|
+
#set order by to default or form result
|
41
|
+
@search.order_by ||= :created_at
|
42
|
+
@search.order_as ||= "DESC"
|
43
|
+
#set results per page to default or form result
|
44
|
+
@search.per_page = Spree::Config[:orders_per_page]
|
45
|
+
|
46
|
+
@collection = @search.find(:all, :include => [:user, :shipments, {:creditcards => :address}] )
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
# Allows extensions to add new forms of payment to provide their own display of transactions
|
49
50
|
def initialize_txn_partials
|
50
51
|
@txn_partials = []
|
@@ -56,23 +56,21 @@ class Admin::ProductsController < Admin::BaseController
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def collection
|
59
|
-
@name = params[:name] || ""
|
60
|
-
@sku = params[:sku] || ""
|
61
|
-
@deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
|
62
59
|
|
63
|
-
if
|
64
|
-
|
65
|
-
|
66
|
-
else
|
67
|
-
@collection ||= end_of_association_chain.deleted.by_name(@name).find(:all, :order => :name, :page => {:start => 1, :size => Spree::Config[:admin_products_per_page], :current => params[:p]})
|
68
|
-
end
|
60
|
+
#use the active named scope only if the 'show deleted' checkbox is unchecked
|
61
|
+
if params[:search].nil? || params[:search][:conditions].nil? || params[:search][:conditions][:deleted_at_is_not_null].blank?
|
62
|
+
@search = end_of_association_chain.not_deleted.new_search(params[:search])
|
69
63
|
else
|
70
|
-
|
71
|
-
@collection ||= end_of_association_chain.active.by_name(@name).by_sku(@sku).find(:all, :order => :name, :page => {:start => 1, :size => Spree::Config[:admin_products_per_page], :current => params[:p]})
|
72
|
-
else
|
73
|
-
@collection ||= end_of_association_chain.deleted.by_name(@name).by_sku(@sku).find(:all, :order => :name, :page => {:start => 1, :size => Spree::Config[:admin_products_per_page], :current => params[:p]})
|
74
|
-
end
|
64
|
+
@search = end_of_association_chain.new_search(params[:search])
|
75
65
|
end
|
66
|
+
|
67
|
+
#set order by to default or form result
|
68
|
+
@search.order_by ||= :name
|
69
|
+
@search.order_as ||= "ASC"
|
70
|
+
#set results per page to default or form result
|
71
|
+
@search.per_page = Spree::Config[:admin_products_per_page]
|
72
|
+
@search.include = :images
|
73
|
+
@collection = @search.all
|
76
74
|
end
|
77
75
|
|
78
76
|
# override rc_default build b/c we need to make sure there's an empty variant added to each product
|
@@ -9,26 +9,24 @@ class Admin::ReportsController < Admin::BaseController
|
|
9
9
|
@reports = AVAILABLE_REPORTS
|
10
10
|
end
|
11
11
|
|
12
|
-
def sales_total
|
13
|
-
scope = Order.scoped({})
|
14
|
-
scope = scope.between(@filter.start, (@filter.stop.blank? ? @default_stop : @filter.stop.to_date + 1 )) unless @filter.start.blank?
|
12
|
+
def sales_total
|
15
13
|
|
16
|
-
@
|
14
|
+
@search = Order.new_search(params[:search])
|
15
|
+
#set order by to default or form result
|
16
|
+
@search.order_by ||= :created_at
|
17
|
+
@search.order_as ||= "DESC"
|
18
|
+
|
19
|
+
@orders = @search.find(:all)
|
17
20
|
|
18
|
-
@item_total =
|
19
|
-
@ship_total =
|
20
|
-
@tax_total =
|
21
|
-
@sales_total =
|
21
|
+
@item_total = @search.sum(:item_total)
|
22
|
+
@ship_total = @search.sum(:ship_amount)
|
23
|
+
@tax_total = @search.sum(:tax_amount)
|
24
|
+
@sales_total = @search.sum(:total)
|
22
25
|
end
|
23
26
|
|
24
27
|
private
|
25
28
|
def load_data
|
26
|
-
|
27
|
-
unless @filter.valid?
|
28
|
-
flash.now[:error] = t('invalid_search')
|
29
|
-
return nil
|
30
|
-
end
|
31
|
-
@default_stop = (Date.today + 1).to_s(:db)
|
29
|
+
|
32
30
|
end
|
33
31
|
|
34
32
|
end
|
@@ -13,11 +13,16 @@ class Admin::UsersController < Admin::BaseController
|
|
13
13
|
|
14
14
|
private
|
15
15
|
def collection
|
16
|
-
@
|
16
|
+
@search = User.new_search(params[:search])
|
17
|
+
#set order by to default or form result
|
18
|
+
@search.order_by ||= :email
|
19
|
+
@search.order_as ||= "ASC"
|
20
|
+
#set results per page to default or form result
|
21
|
+
@search.per_page = Spree::Config[:admin_products_per_page]
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
@collection, @collection_count = @search.all, @search.count
|
24
|
+
|
25
|
+
#scope = scope.conditions "lower(email) = ?", @filter.email.downcase unless @filter.email.blank?
|
21
26
|
end
|
22
27
|
|
23
28
|
def load_roles
|
@@ -28,7 +33,7 @@ class Admin::UsersController < Admin::BaseController
|
|
28
33
|
return unless params[:user]
|
29
34
|
@user.roles.delete_all
|
30
35
|
Role.find(:all).each { |role|
|
31
|
-
@user.roles << role if !params[:user]['role_' + role.name].blank?
|
36
|
+
@user.roles << role if !params[:user]['role_' + role.name].blank? || role.name.downcase == "user"
|
32
37
|
}
|
33
38
|
end
|
34
39
|
end
|
@@ -30,7 +30,10 @@ class Admin::ZonesController < Admin::BaseController
|
|
30
30
|
|
31
31
|
private
|
32
32
|
def collection
|
33
|
-
@
|
33
|
+
@search = end_of_association_chain.new_search(params[:search])
|
34
|
+
@search.order_by ||= :name
|
35
|
+
@search.per_page = Spree::Config[:orders_per_page]
|
36
|
+
@collection, @collection_count = @search.all, @search.count
|
34
37
|
end
|
35
38
|
|
36
39
|
def load_data
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class CheckoutController < Spree::BaseController
|
2
|
+
before_filter :stop_monkey_business
|
3
|
+
before_filter :require_user_account
|
4
|
+
before_filter :load_data
|
5
|
+
before_filter :build_object, :except => [:new, :create]
|
6
|
+
|
7
|
+
ssl_required :new, :create
|
8
|
+
|
9
|
+
resource_controller
|
10
|
+
model_name :checkout_presenter
|
11
|
+
object_name :checkout_presenter
|
12
|
+
|
13
|
+
# modified version of r_c create method (easier then all the before after hooks - especially for gateway error handling)
|
14
|
+
def create
|
15
|
+
build_object
|
16
|
+
load_object
|
17
|
+
|
18
|
+
@order.user = current_user
|
19
|
+
@order.ip_address = request.env['REMOTE_ADDR']
|
20
|
+
|
21
|
+
begin
|
22
|
+
if object.save
|
23
|
+
# remove the order from the session
|
24
|
+
session[:order_id] = nil if @order.checkout_complete
|
25
|
+
else
|
26
|
+
flash[:error] = t("unable_to_save_order")
|
27
|
+
render :action => "new" and return
|
28
|
+
end
|
29
|
+
rescue Spree::GatewayError => ge
|
30
|
+
flash.now[:error] = t("unable_to_authorize_credit_card") + ": #{ge.message}"
|
31
|
+
render :action => "new" and return
|
32
|
+
end
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.html {redirect_to order_url(@order, :checkout_complete => true) }
|
36
|
+
format.js {render :json => { :order => @checkout_presenter.order_hash,
|
37
|
+
:available_methods => @order.shipment.rates }.to_json,
|
38
|
+
:layout => false}
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def cvv
|
44
|
+
render :layout => false
|
45
|
+
end
|
46
|
+
|
47
|
+
def select_country
|
48
|
+
@states = @object.bill_address.country.states#, :order => 'name')
|
49
|
+
respond_to do |format|
|
50
|
+
format.js
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
def require_user_account
|
56
|
+
return if logged_in?
|
57
|
+
store_location
|
58
|
+
redirect_to signup_path
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def build_object
|
64
|
+
@order = Order.find_by_number(params[:order_number])
|
65
|
+
if params[:checkout_presenter]
|
66
|
+
@object ||= end_of_association_chain.send parent? ? :build : :new, params[:checkout_presenter]
|
67
|
+
else
|
68
|
+
# user has not yet submitted checkout parameters, we can use defaults of current_user and order objects
|
69
|
+
bill_address = current_user.last_address unless current_user == :false
|
70
|
+
bill_address ||= Address.new
|
71
|
+
ship_address = @order.ship_address || Address.new
|
72
|
+
shipping_method = @order.shipment ? @order.shipment.shipping_method : nil
|
73
|
+
@object ||= end_of_association_chain.send parent? ? :build : :new, {:bill_address => bill_address,
|
74
|
+
:ship_address => ship_address,
|
75
|
+
:shipping_method => shipping_method }
|
76
|
+
end
|
77
|
+
@object.final_answer = params[:final_answer] unless params[:final_answer].blank?
|
78
|
+
@object.order = @order
|
79
|
+
@object.shipping_method = ShippingMethod.find_by_id(params[:method_id]) if params[:method_id]
|
80
|
+
end
|
81
|
+
|
82
|
+
def load_data
|
83
|
+
@countries = Country.find(:all).sort
|
84
|
+
@shipping_countries = @object.order.shipping_countries.sort
|
85
|
+
@states = Country.find(214).states.sort
|
86
|
+
|
87
|
+
month = @object.creditcard.month ? @object.creditcard.month.to_i : Date.today.month
|
88
|
+
year = @object.creditcard.year ? object.creditcard.year.to_i : Date.today.year
|
89
|
+
@date = Date.new(year, month, 1)
|
90
|
+
end
|
91
|
+
|
92
|
+
def stop_monkey_business
|
93
|
+
build_object
|
94
|
+
redirect_to order_url(@order) and return if @order.checkout_complete
|
95
|
+
end
|
96
|
+
end
|
@@ -1,5 +1,15 @@
|
|
1
1
|
class ContentController < Spree::BaseController
|
2
|
+
rescue_from ActionView::MissingTemplate, :with => :render_404
|
3
|
+
|
2
4
|
def show
|
3
5
|
render :action => params[:path].join('/')
|
4
|
-
end
|
6
|
+
end
|
7
|
+
|
8
|
+
protected
|
9
|
+
def render_404(exception)
|
10
|
+
respond_to do |type|
|
11
|
+
type.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" }
|
12
|
+
type.all { render :nothing => true, :status => "404 Not Found" }
|
13
|
+
end
|
14
|
+
end
|
5
15
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class OrdersController < Spree::BaseController
|
2
|
-
before_filter :
|
3
|
-
before_filter :load_object, :only => [:checkout]
|
2
|
+
# before_filter :load_object, :only => [:checkout]
|
4
3
|
before_filter :prevent_editing_complete_order, :only => [:edit, :update]
|
5
4
|
|
6
5
|
ssl_required :show
|
@@ -13,8 +12,14 @@ class OrdersController < Spree::BaseController
|
|
13
12
|
helper :products
|
14
13
|
|
15
14
|
create.after do
|
16
|
-
# add the specified
|
17
|
-
|
15
|
+
# add the specified products in given quantities to the order
|
16
|
+
# the information is specified in a hash.
|
17
|
+
|
18
|
+
params[:quantities].each do |product_id,vq|
|
19
|
+
(variant_id,quantity) = vq.split '='
|
20
|
+
quantity = quantity.to_i
|
21
|
+
@order.add_variant(Variant.find(variant_id), quantity) if quantity > 0
|
22
|
+
end
|
18
23
|
@order.save
|
19
24
|
end
|
20
25
|
|
@@ -23,26 +28,7 @@ class OrdersController < Spree::BaseController
|
|
23
28
|
flash nil
|
24
29
|
wants.html {redirect_to edit_order_url(@order)}
|
25
30
|
end
|
26
|
-
|
27
|
-
edit.before { @order.edit! }
|
28
31
|
|
29
|
-
def checkout
|
30
|
-
if @order.state == "in_progress"
|
31
|
-
@order.update_attribute :user, current_user
|
32
|
-
@order.update_attribute :ip_address, request.env['REMOTE_ADDR']
|
33
|
-
@order.next!
|
34
|
-
end
|
35
|
-
if object.checkout_complete
|
36
|
-
# remove the order from the session
|
37
|
-
session[:order_id] = nil
|
38
|
-
redirect_to object_url(:checkout_complete => true) and return
|
39
|
-
else
|
40
|
-
# note: controllers participating in checkout process are responsible for calling Order#next!
|
41
|
-
next_url = self.send("new_order_#{object.state}_url", @order)
|
42
|
-
redirect_to next_url
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
32
|
# override the default r_c flash behavior
|
47
33
|
update.flash nil
|
48
34
|
update.response do |wants|
|
@@ -53,13 +39,6 @@ class OrdersController < Spree::BaseController
|
|
53
39
|
flash nil
|
54
40
|
wants.html {redirect_to new_order_url}
|
55
41
|
end
|
56
|
-
|
57
|
-
protected
|
58
|
-
def require_user_account
|
59
|
-
return if logged_in?
|
60
|
-
store_location
|
61
|
-
redirect_to signup_path
|
62
|
-
end
|
63
42
|
|
64
43
|
private
|
65
44
|
def build_object
|
@@ -69,7 +48,7 @@ class OrdersController < Spree::BaseController
|
|
69
48
|
def object
|
70
49
|
if params[:id]
|
71
50
|
begin
|
72
|
-
@order = Order.
|
51
|
+
@order = Order.find_by_param! params[:id]
|
73
52
|
rescue ActiveRecord::RecordNotFound
|
74
53
|
@order = find_order
|
75
54
|
ensure
|
@@ -80,6 +59,6 @@ class OrdersController < Spree::BaseController
|
|
80
59
|
end
|
81
60
|
|
82
61
|
def prevent_editing_complete_order
|
83
|
-
redirect_to object_url
|
62
|
+
redirect_to object_url if @order.checkout_complete
|
84
63
|
end
|
85
|
-
end
|
64
|
+
end
|