spree_core 1.1.6 → 1.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/{creditcards → credit_cards}/amex_cid.gif +0 -0
- data/app/assets/images/{creditcards/creditcard.gif → credit_cards/credit_card.gif} +0 -0
- data/app/assets/images/{creditcards → credit_cards}/discover_cid.gif +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/american_express.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/cirrus.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/delta.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/dinersclub.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/directdebit.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/discover.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/egold.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/maestro.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/master.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/paypal.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/solo.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/switch.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/visa.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/visaelectron.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/westernunion.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/wirecard.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/worldpay.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/master_cid.jpg +0 -0
- data/app/assets/images/{creditcards → credit_cards}/visa_cid.gif +0 -0
- data/app/assets/javascripts/admin/admin.js.erb +12 -136
- data/app/assets/javascripts/admin/checkouts/edit.js +18 -35
- data/app/assets/javascripts/admin/gateway.js +2 -2
- data/app/assets/javascripts/admin/images/index.js.coffee +12 -0
- data/app/assets/javascripts/admin/images/new.js.coffee +4 -0
- data/app/assets/javascripts/admin/orders/edit.js +1 -1
- data/app/assets/javascripts/admin/orders/edit_form.js +0 -2
- data/app/assets/javascripts/admin/product_autocomplete.js.erb +116 -0
- data/app/assets/javascripts/store/cart.js.coffee +7 -0
- data/app/assets/javascripts/store/checkout.js.coffee +57 -0
- data/app/assets/javascripts/store/product.js.coffee +36 -0
- data/app/assets/stylesheets/admin/admin.css.erb +5 -0
- data/app/assets/stylesheets/admin/spree_core.css +1 -0
- data/app/assets/stylesheets/store/screen.css.scss +15 -1
- data/app/assets/stylesheets/store/variables.css.scss +29 -29
- data/app/controllers/spree/admin/banners_controller.rb +14 -0
- data/app/controllers/spree/admin/base_controller.rb +11 -0
- data/app/controllers/spree/admin/images_controller.rb +13 -5
- data/app/controllers/spree/admin/line_items_controller.rb +16 -25
- data/app/controllers/spree/admin/mail_methods_controller.rb +1 -8
- data/app/controllers/spree/admin/option_types_controller.rb +0 -25
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -3
- data/app/controllers/spree/admin/orders_controller.rb +23 -14
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -7
- data/app/controllers/spree/admin/payments_controller.rb +5 -5
- data/app/controllers/spree/admin/products_controller.rb +15 -5
- data/app/controllers/spree/admin/prototypes_controller.rb +2 -2
- data/app/controllers/spree/admin/reports_controller.rb +1 -7
- data/app/controllers/spree/admin/resource_controller.rb +130 -130
- data/app/controllers/spree/admin/search_controller.rb +47 -0
- data/app/controllers/spree/admin/taxons_controller.rb +0 -43
- data/app/controllers/spree/base_controller.rb +2 -1
- data/app/controllers/spree/checkout_controller.rb +29 -10
- data/app/controllers/spree/orders_controller.rb +7 -11
- data/app/controllers/spree/products_controller.rb +5 -1
- data/app/helpers/spree/account_helper.rb +4 -0
- data/app/helpers/spree/admin/base_helper.rb +2 -44
- data/app/helpers/spree/admin/navigation_helper.rb +1 -3
- data/app/helpers/spree/admin/orders_helper.rb +3 -2
- data/app/helpers/spree/admin/products_helper.rb +21 -0
- data/app/helpers/spree/base_helper.rb +14 -11
- data/app/helpers/spree/checkout_helper.rb +5 -1
- data/app/helpers/spree/orders_helper.rb +5 -0
- data/app/helpers/spree/products_helper.rb +4 -0
- data/app/helpers/spree/trackers_helper.rb +4 -0
- data/app/models/spree/ability.rb +70 -0
- data/app/models/spree/address.rb +4 -12
- data/app/models/spree/adjustment.rb +30 -8
- data/app/models/spree/app_configuration.rb +1 -1
- data/app/models/spree/calculator/price_sack.rb +3 -5
- data/app/models/spree/country.rb +1 -4
- data/app/models/spree/{creditcard.rb → credit_card.rb} +4 -4
- data/app/models/spree/gateway.rb +2 -2
- data/app/models/spree/gateway/bogus.rb +10 -10
- data/app/models/spree/gateway/bogus_simple.rb +4 -4
- data/app/models/spree/image.rb +3 -12
- data/app/models/spree/inventory_unit.rb +4 -6
- data/app/models/spree/{user.rb → legacy_user.rb} +7 -6
- data/app/models/spree/line_item.rb +4 -5
- data/app/models/spree/option_type.rb +4 -6
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order.rb +90 -132
- data/app/models/spree/order/checkout.rb +124 -0
- data/app/models/spree/payment.rb +6 -6
- data/app/models/spree/payment/processing.rb +34 -38
- data/app/models/spree/payment_method.rb +2 -2
- data/app/models/spree/preference.rb +2 -0
- data/app/models/spree/preferences/preferable_class_methods.rb +0 -2
- data/app/models/spree/preferences/store.rb +3 -21
- data/app/models/spree/product.rb +41 -43
- data/app/models/spree/product/scopes.rb +9 -25
- data/app/models/spree/product_option_type.rb +2 -2
- data/app/models/spree/product_property.rb +9 -4
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/prototype.rb +2 -2
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/shipment.rb +6 -5
- data/app/models/spree/shipping_method.rb +19 -13
- data/app/models/spree/state.rb +2 -5
- data/app/models/spree/state_change.rb +1 -1
- data/app/models/spree/tax_rate.rb +8 -1
- data/app/models/spree/taxon.rb +5 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/tokenized_permission.rb +6 -0
- data/app/models/spree/tracker.rb +1 -1
- data/app/models/spree/variant.rb +13 -40
- data/app/models/spree/zone.rb +15 -14
- data/app/models/spree/zone_member.rb +1 -1
- data/app/views/spree/admin/image_settings/edit.html.erb +2 -2
- data/app/views/spree/admin/images/_form.html.erb +8 -4
- data/app/views/spree/admin/images/index.html.erb +1 -1
- data/app/views/spree/admin/line_items/create.js.erb +1 -1
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
- data/app/views/spree/admin/option_types/index.html.erb +1 -1
- data/app/views/spree/admin/orders/_add_product.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/index.html.erb +4 -4
- data/app/views/spree/admin/orders/show.html.erb +1 -1
- data/app/views/spree/admin/payments/_form.html.erb +1 -1
- data/app/views/spree/admin/payments/new.html.erb +0 -4
- data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +1 -1
- data/app/views/spree/admin/payments/source_views/_gateway.html.erb +2 -2
- data/app/views/spree/admin/products/_form.html.erb +21 -5
- data/app/views/spree/admin/products/index.html.erb +2 -2
- data/app/views/spree/admin/properties/_form.html.erb +1 -1
- data/app/views/spree/admin/properties/index.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +33 -17
- data/app/views/spree/admin/return_authorizations/edit.html.erb +2 -2
- data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +12 -2
- data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -4
- data/app/views/spree/admin/shared/_product_tabs.html.erb +0 -6
- data/app/views/spree/admin/shared/_show_resource_links.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
- data/app/views/spree/admin/shipments/edit.html.erb +2 -2
- data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/states/_state_list.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/index.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/_taxon_table.html.erb +2 -2
- data/app/views/spree/admin/variants/_form.html.erb +13 -13
- data/app/views/spree/admin/variants/index.html.erb +1 -7
- data/app/views/spree/checkout/_address.html.erb +10 -4
- data/app/views/spree/checkout/edit.html.erb +0 -1
- data/app/views/spree/checkout/payment/_gateway.html.erb +5 -5
- data/app/views/spree/checkout/registration.html.erb +2 -2
- data/app/views/spree/content/cvv.html.erb +6 -6
- data/app/views/spree/layouts/spree_application.html.erb +4 -48
- data/app/views/spree/order_mailer/cancel_email.text.erb +5 -5
- data/app/views/spree/order_mailer/confirm_email.text.erb +6 -7
- data/app/views/spree/orders/_adjustments.html.erb +14 -0
- data/app/views/spree/orders/_form.html.erb +1 -0
- data/app/views/spree/orders/show.html.erb +3 -3
- data/app/views/spree/products/_thumbnails.html.erb +1 -1
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/shared/_footer.html.erb +6 -0
- data/app/views/spree/shared/_google_analytics.html.erb +15 -16
- data/app/views/spree/shared/_head.html.erb +3 -9
- data/app/views/spree/shared/_header.html.erb +5 -0
- data/app/views/spree/shared/_main_nav_bar.html.erb +6 -0
- data/app/views/spree/shared/_nav_bar.html.erb +7 -3
- data/app/views/spree/shared/_order_details.html.erb +14 -11
- data/app/views/spree/shared/_sidebar.html.erb +3 -0
- data/app/views/spree/shared/unauthorized.html.erb +0 -0
- data/app/views/spree/shipment_mailer/shipped_email.text.erb +7 -7
- data/app/views/spree/taxons/show.html.erb +1 -1
- data/config/initializers/check_for_orphaned_preferences.rb +1 -1
- data/config/initializers/spree.rb +0 -12
- data/config/initializers/user_class_extensions.rb +25 -0
- data/config/initializers/workarounds_for_ruby19.rb +72 -0
- data/config/locales/en.yml +11 -24
- data/config/routes.rb +7 -37
- data/db/migrate/20090823005402_spree_zero_nine_zero.rb +14 -12
- data/db/migrate/20091015153048_add_openid_field_to_users.rb +9 -7
- data/db/migrate/20100209144531_polymorphic_payments.rb +5 -5
- data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +4 -4
- data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +3 -1
- data/db/migrate/20100811163637_add_guest_flag.rb +3 -1
- data/db/migrate/20100901171814_change_guest_flag_to_anonymous.rb +3 -1
- data/db/migrate/20101026184959_generate_anonymous_users.rb +3 -3
- data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +3 -1
- data/db/migrate/20111007143030_namespace_top_level_models.rb +18 -1
- data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +6 -4
- data/db/migrate/20120509055454_create_tokenized_permissions_table.rb +16 -0
- data/db/migrate/20120530012000_rename_creditcards_to_credit_cards.rb +11 -0
- data/db/migrate/20120604203654_remove_credit_total_from_orders.rb +5 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +53 -0
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +28 -0
- data/lib/generators/spree/custom_user/templates/initializer.rb.tt +1 -0
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +3 -0
- data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +1 -0
- data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
- data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
- data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
- data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +2 -0
- data/lib/spree/core.rb +15 -2
- data/lib/spree/core/controller_helpers.rb +123 -62
- data/lib/spree/core/current_order.rb +5 -0
- data/lib/spree/core/engine.rb +1 -1
- data/lib/spree/core/mail_settings.rb +1 -2
- data/lib/spree/core/permalinks.rb +1 -5
- data/lib/spree/core/preference_rescue.rb +8 -4
- data/lib/spree/core/relation_serialization.rb +9 -0
- data/lib/spree/core/respond_with.rb +1 -1
- data/lib/spree/core/s3_support.rb +25 -0
- data/lib/spree/core/search/base.rb +2 -5
- data/lib/spree/core/ssl_requirement.rb +2 -2
- data/lib/spree/core/store_helpers.rb +1 -2
- data/lib/spree/core/testing_support/controller_requests.rb +1 -0
- data/lib/spree/core/testing_support/env.rb +2 -0
- data/lib/spree/core/testing_support/factories/{creditcard_factory.rb → credit_card_factory.rb} +3 -3
- data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/product_factory.rb +4 -4
- data/lib/spree/core/testing_support/factories/user_factory.rb +3 -3
- data/lib/spree/core/testing_support/factories/zone_factory.rb +2 -3
- data/lib/spree/core/token_resource.rb +27 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/product_filters.rb +12 -13
- data/lib/tasks/core.rake +1 -1
- metadata +146 -154
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/javascripts/admin/images/index.js +0 -10
- data/app/assets/javascripts/admin/images/new.js +0 -5
- data/app/assets/javascripts/admin/products.js +0 -2
- data/app/assets/javascripts/store/cart.js +0 -11
- data/app/assets/javascripts/store/checkout.js +0 -78
- data/app/assets/javascripts/store/product.js +0 -49
- data/app/controllers/spree/admin/users_controller.rb +0 -68
- data/app/views/spree/admin/option_types/_available.html.erb +0 -28
- data/app/views/spree/admin/option_types/_selected.html.erb +0 -26
- data/app/views/spree/admin/option_types/available.js.erb +0 -2
- data/app/views/spree/admin/option_types/select.js.erb +0 -3
- data/app/views/spree/admin/option_types/selected.html.erb +0 -6
- data/app/views/spree/admin/orders/history.html.erb +0 -29
- data/app/views/spree/admin/products/_option_types.html.erb +0 -40
- data/app/views/spree/admin/shared/_additional_field.html.erb +0 -5
- data/app/views/spree/admin/shared/_routes.html.erb +0 -8
- data/app/views/spree/admin/shared/_translations.html.erb +0 -17
- data/app/views/spree/admin/taxons/available.js.erb +0 -26
- data/app/views/spree/admin/taxons/remove.html.erb +0 -1
- data/app/views/spree/admin/taxons/select.js.erb +0 -2
- data/app/views/spree/admin/taxons/selected.html.erb +0 -42
- data/app/views/spree/admin/users/_form.html.erb +0 -19
- data/app/views/spree/admin/users/edit.html.erb +0 -14
- data/app/views/spree/admin/users/index.html.erb +0 -48
- data/app/views/spree/admin/users/new.html.erb +0 -14
- data/app/views/spree/admin/users/show.html.erb +0 -21
- data/app/views/spree/shared/_store_menu.html.erb +0 -2
- data/config/initializers/rails_5868.rb +0 -8
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +0 -10
- data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +0 -11
- data/db/sample/users.rb +0 -61
- data/lib/generators/spree/sandbox/sandbox_generator.rb +0 -36
- data/lib/generators/spree/sandbox/templates/rails/routes.rb +0 -7
- data/lib/spree/core/ext/array.rb +0 -14
- data/lib/spree/core/ext/hash.rb +0 -75
- data/lib/spree/core/ext/string.rb +0 -10
- data/lib/tasks/install.rake +0 -18
@@ -0,0 +1 @@
|
|
1
|
+
# Spree.user_class = "User"
|
data/lib/spree/core.rb
CHANGED
@@ -37,8 +37,21 @@ require 'active_merchant'
|
|
37
37
|
require 'ransack'
|
38
38
|
require 'jquery-rails'
|
39
39
|
require 'deface'
|
40
|
+
require 'cancan'
|
41
|
+
require 'select2-rails'
|
40
42
|
|
41
43
|
module Spree
|
44
|
+
|
45
|
+
mattr_accessor :user_class
|
46
|
+
|
47
|
+
def self.user_class
|
48
|
+
if @@user_class.is_a?(Class)
|
49
|
+
raise "Spree.user_class MUST be a String object, not a Class object."
|
50
|
+
elsif @@user_class.is_a?(String)
|
51
|
+
@@user_class.constantize
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
module Core
|
43
56
|
end
|
44
57
|
|
@@ -58,7 +71,6 @@ module Spree
|
|
58
71
|
end
|
59
72
|
|
60
73
|
require 'spree/core/ext/active_record'
|
61
|
-
require 'spree/core/ext/hash'
|
62
74
|
|
63
75
|
require 'spree/core/delegate_belongs_to'
|
64
76
|
|
@@ -74,6 +86,8 @@ require 'spree/core/mail_interceptor'
|
|
74
86
|
require 'spree/core/middleware/redirect_legacy_product_url'
|
75
87
|
require 'spree/core/middleware/seo_assist'
|
76
88
|
require 'spree/core/permalinks'
|
89
|
+
require 'spree/core/token_resource'
|
90
|
+
require 'spree/core/s3_support'
|
77
91
|
|
78
92
|
silence_warnings do
|
79
93
|
require 'spree/core/authorize_net_cim_hack'
|
@@ -83,7 +97,6 @@ require 'spree/core/version'
|
|
83
97
|
|
84
98
|
require 'spree/core/engine'
|
85
99
|
require 'generators/spree/dummy/dummy_generator'
|
86
|
-
require 'generators/spree/sandbox/sandbox_generator'
|
87
100
|
|
88
101
|
ActiveRecord::Base.class_eval do
|
89
102
|
include Spree::Core::CalculatedAdjustments
|
@@ -1,27 +1,40 @@
|
|
1
|
+
# This module exists so that controllers that don't inherit from Spree::BaseController
|
2
|
+
# Can still inherit the important bits of functionality and use the Spree layout by default.
|
1
3
|
module Spree
|
2
4
|
module Core
|
3
5
|
module ControllerHelpers
|
4
|
-
def self.included(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
receiver.send :helper_method, 'title='
|
10
|
-
receiver.send :helper_method, 'accurate_title'
|
11
|
-
receiver.send :helper_method, 'get_taxonomies'
|
12
|
-
receiver.send :helper_method, 'current_order'
|
13
|
-
receiver.send :include, SslRequirement
|
14
|
-
receiver.send :include, Spree::Core::CurrentOrder
|
15
|
-
end
|
6
|
+
def self.included(base)
|
7
|
+
base.class_eval do
|
8
|
+
include Spree::Core::CurrentOrder
|
9
|
+
include Spree::Core::RespondWith
|
10
|
+
include SslRequirement
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
helper_method :title
|
13
|
+
helper_method :title=
|
14
|
+
helper_method :accurate_title
|
15
|
+
helper_method :current_order
|
16
|
+
helper_method :try_spree_current_user
|
17
|
+
|
18
|
+
before_filter :set_user_language
|
19
|
+
before_filter :set_current_order
|
20
|
+
|
21
|
+
rescue_from CanCan::AccessDenied do |exception|
|
22
|
+
return unauthorized
|
23
|
+
end
|
20
24
|
|
25
|
+
layout :get_layout
|
26
|
+
end
|
27
|
+
end
|
21
28
|
# can be used in views as well as controllers.
|
22
29
|
# e.g. <% title = 'This is a custom title for this view' %>
|
23
30
|
attr_writer :title
|
24
31
|
|
32
|
+
# proxy method to *possible* spree_current_user method
|
33
|
+
# Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user
|
34
|
+
def try_spree_current_user
|
35
|
+
respond_to?(:spree_current_user) ? spree_current_user : nil
|
36
|
+
end
|
37
|
+
|
25
38
|
def title
|
26
39
|
title_string = @title.present? ? @title : accurate_title
|
27
40
|
if title_string.present?
|
@@ -37,69 +50,117 @@ module Spree
|
|
37
50
|
|
38
51
|
protected
|
39
52
|
|
40
|
-
|
41
|
-
|
53
|
+
def set_current_order
|
54
|
+
if user = try_spree_current_user
|
55
|
+
last_incomplete_order = user.last_incomplete_spree_order
|
56
|
+
if session[:order_id].nil? && last_incomplete_order
|
57
|
+
session[:order_id] = last_incomplete_order.id
|
58
|
+
elsif current_order && last_incomplete_order && current_order != last_incomplete_order
|
59
|
+
current_order.merge!(last_incomplete_order)
|
60
|
+
end
|
42
61
|
end
|
62
|
+
end
|
43
63
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
64
|
+
# Needs to be overriden so that we use Spree's Ability rather than anyone else's.
|
65
|
+
def current_ability
|
66
|
+
@current_ability ||= Spree::Ability.new(try_spree_current_user)
|
67
|
+
end
|
48
68
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
69
|
+
def store_location
|
70
|
+
# disallow return to login, logout, signup pages
|
71
|
+
authentication_routes = [:spree_signup_path, :spree_login_path, :spree_logout_path]
|
72
|
+
disallowed_urls = []
|
73
|
+
authentication_routes.each do |route|
|
74
|
+
if respond_to?(route)
|
75
|
+
disallowed_urls << send(route)
|
53
76
|
end
|
54
77
|
end
|
55
78
|
|
56
|
-
|
57
|
-
|
58
|
-
|
79
|
+
disallowed_urls.map!{ |url| url[/\/\w+$/] }
|
80
|
+
unless disallowed_urls.include?(request.fullpath)
|
81
|
+
session['user_return_to'] = request.fullpath.gsub('//', '/')
|
59
82
|
end
|
83
|
+
end
|
84
|
+
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
|
85
|
+
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
|
86
|
+
# to access the requested action. For example, a popup window might simply close itself.
|
87
|
+
def unauthorized
|
88
|
+
respond_to do |format|
|
89
|
+
format.html do
|
90
|
+
if try_spree_current_user
|
91
|
+
flash.now[:error] = t(:authorization_failure)
|
92
|
+
render 'spree/shared/unauthorized', :layout => '/spree/layouts/spree_application', :status => 401
|
93
|
+
else
|
94
|
+
store_location
|
95
|
+
url = respond_to?(:spree_login_path) ? spree_login_path : root_path
|
96
|
+
redirect_to url
|
97
|
+
end
|
98
|
+
end
|
99
|
+
format.xml do
|
100
|
+
request_http_basic_authentication 'Web Password'
|
101
|
+
end
|
102
|
+
format.json do
|
103
|
+
render :text => "Not Authorized \n", :status => 401
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
60
107
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
108
|
+
|
109
|
+
def default_title
|
110
|
+
Spree::Config[:site_name]
|
111
|
+
end
|
112
|
+
|
113
|
+
# this is a hook for subclasses to provide title
|
114
|
+
def accurate_title
|
115
|
+
Spree::Config[:default_seo_title]
|
116
|
+
end
|
117
|
+
|
118
|
+
def render_404(exception = nil)
|
119
|
+
respond_to do |type|
|
120
|
+
type.html { render :status => :not_found, :file => "#{::Rails.root}/public/404", :formats => [:html], :layout => nil}
|
121
|
+
type.all { render :status => :not_found, :nothing => true }
|
66
122
|
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Convenience method for firing instrumentation events with the default payload hash
|
126
|
+
def fire_event(name, extra_payload = {})
|
127
|
+
ActiveSupport::Notifications.instrument(name, default_notification_payload.merge(extra_payload))
|
128
|
+
end
|
129
|
+
|
130
|
+
# Creates the hash that is sent as the payload for all notifications. Specific notifications will
|
131
|
+
# add additional keys as appropriate. Override this method if you need additional data when
|
132
|
+
# responding to a notification
|
133
|
+
def default_notification_payload
|
134
|
+
{:user => try_spree_current_user, :order => current_order}
|
135
|
+
end
|
67
136
|
|
68
137
|
private
|
69
138
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
139
|
+
def redirect_back_or_default(default)
|
140
|
+
redirect_to(session["user_return_to"] || default)
|
141
|
+
session["user_return_to"] = nil
|
142
|
+
end
|
74
143
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
144
|
+
def set_user_language
|
145
|
+
locale = session[:locale]
|
146
|
+
locale ||= Spree::Config[:default_locale] unless Spree::Config[:default_locale].blank?
|
147
|
+
locale ||= Rails.application.config.i18n.default_locale
|
148
|
+
locale ||= I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
|
149
|
+
I18n.locale = locale.to_sym
|
150
|
+
end
|
79
151
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
152
|
+
# Returns which layout to render.
|
153
|
+
#
|
154
|
+
# You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
|
155
|
+
#
|
156
|
+
# Default layout is: +app/views/spree/layouts/spree_application+
|
157
|
+
#
|
158
|
+
def get_layout
|
159
|
+
layout ||= Spree::Config[:layout]
|
160
|
+
end
|
85
161
|
|
86
|
-
def set_user_language
|
87
|
-
locale = session[:locale]
|
88
|
-
locale ||= Spree::Config[:default_locale] unless Spree::Config[:default_locale].blank?
|
89
|
-
locale ||= Rails.application.config.i18n.default_locale
|
90
|
-
locale ||= I18n.default_locale unless I18n.available_locales.map(&:to_s).include?(locale)
|
91
|
-
I18n.locale = locale
|
92
|
-
end
|
93
162
|
|
94
|
-
# Returns which layout to render.
|
95
|
-
#
|
96
|
-
# You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
|
97
|
-
#
|
98
|
-
# Default layout is: +app/views/spree/layouts/spree_application+
|
99
|
-
#
|
100
|
-
def get_layout
|
101
|
-
layout ||= Spree::Config[:layout]
|
102
|
-
end
|
103
163
|
end
|
104
164
|
end
|
105
165
|
end
|
166
|
+
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Spree
|
2
2
|
module Core
|
3
3
|
module CurrentOrder
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
helper_method :current_order
|
7
|
+
end
|
8
|
+
end
|
4
9
|
|
5
10
|
# This should be overridden by an auth-related extension which would then have the
|
6
11
|
# opportunity to associate the new order with the # current user before saving.
|
data/lib/spree/core/engine.rb
CHANGED
@@ -10,6 +10,7 @@ module Spree
|
|
10
10
|
config.autoload_paths += %W(#{config.root}/lib)
|
11
11
|
|
12
12
|
def self.activate
|
13
|
+
Spree::Order.define_state_machine!
|
13
14
|
end
|
14
15
|
|
15
16
|
config.to_prepare &method(:activate).to_proc
|
@@ -22,7 +23,6 @@ module Spree
|
|
22
23
|
activator.activate(payload)
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
26
26
|
end
|
27
27
|
|
28
28
|
# We need to reload the routes here due to how Spree sets them up.
|
@@ -21,8 +21,7 @@ module Spree
|
|
21
21
|
mail_server_settings[:password] = mail_method.preferred_smtp_password
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
mail_server_settings[:enable_starttls_auto] = tls
|
24
|
+
mail_server_settings[:enable_starttls_auto] = (mail_method.preferred_secure_connection_type == 'TLS')
|
26
25
|
|
27
26
|
ActionMailer::Base.smtp_settings = mail_server_settings
|
28
27
|
ActionMailer::Base.perform_deliveries = true
|
@@ -10,10 +10,14 @@ module Spree
|
|
10
10
|
OldPrefs.where(:key => nil).each do |old_pref|
|
11
11
|
next unless owner = (old_pref.owner rescue nil)
|
12
12
|
unless old_pref.owner_type == "Spree::Activator" || old_pref.owner_type == "Spree::Configuration"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
begin
|
14
|
+
old_pref.key = [owner.class.name, old_pref.name, owner.id].join('::').underscore
|
15
|
+
old_pref.value_type = owner.preference_type(old_pref.name)
|
16
|
+
puts "Migrating Preference: #{old_pref.key}"
|
17
|
+
old_pref.save
|
18
|
+
rescue NoMethodError => ex
|
19
|
+
puts ex.message
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spree
|
2
|
+
module Core
|
3
|
+
# This module exists to reduce duplication in S3 settings between
|
4
|
+
# the Image and Taxon models in Spree
|
5
|
+
module S3Support
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
def self.supports_s3(field)
|
10
|
+
# Load user defined paperclip settings
|
11
|
+
config = Spree::Config
|
12
|
+
if config[:use_s3]
|
13
|
+
s3_creds = { :access_key_id => config[:s3_access_key], :secret_access_key => config[:s3_secret], :bucket => config[:s3_bucket] }
|
14
|
+
self.attachment_definitions[field][:storage] = :s3
|
15
|
+
self.attachment_definitions[field][:s3_credentials] = s3_creds
|
16
|
+
self.attachment_definitions[field][:s3_headers] = ActiveSupport::JSON.decode(config[:s3_headers])
|
17
|
+
self.attachment_definitions[field][:bucket] = config[:s3_bucket]
|
18
|
+
self.attachment_definitions[field][:s3_protocol] = config[:s3_protocol] unless config[:s3_protocol].blank?
|
19
|
+
self.attachment_definitions[field][:s3_host_alias] = config[:s3_host_alias] unless config[:s3_host_alias].blank?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -28,7 +28,7 @@ module Spree
|
|
28
28
|
def get_base_scope
|
29
29
|
base_scope = Spree::Product.active
|
30
30
|
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
|
31
|
-
base_scope = get_products_conditions_for(base_scope, keywords)
|
31
|
+
base_scope = get_products_conditions_for(base_scope, keywords) unless keywords.blank?
|
32
32
|
base_scope = base_scope.on_hand unless Spree::Config[:show_zero_stock_products]
|
33
33
|
base_scope = add_search_scopes(base_scope)
|
34
34
|
base_scope
|
@@ -48,10 +48,7 @@ module Spree
|
|
48
48
|
|
49
49
|
# method should return new scope based on base_scope
|
50
50
|
def get_products_conditions_for(base_scope, query)
|
51
|
-
|
52
|
-
base_scope = base_scope.like_any([:name, :description], query.split)
|
53
|
-
end
|
54
|
-
base_scope
|
51
|
+
base_scope.like_any([:name, :description], query.split)
|
55
52
|
end
|
56
53
|
|
57
54
|
def prepare(params)
|