spree_core 0.40.4 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/app/controllers/admin/base_controller.rb +0 -57
- data/app/controllers/admin/configurations_controller.rb +1 -1
- data/app/controllers/admin/general_settings_controller.rb +1 -1
- data/app/controllers/admin/images_controller.rb +18 -8
- data/app/controllers/admin/inventory_settings_controller.rb +1 -1
- data/app/controllers/admin/mail_settings_controller.rb +1 -1
- data/app/controllers/admin/option_types_controller.rb +11 -0
- data/app/controllers/admin/orders_controller.rb +16 -20
- data/app/controllers/admin/overview_controller.rb +1 -1
- data/app/controllers/admin/payment_methods_controller.rb +6 -6
- data/app/controllers/admin/product_groups_controller.rb +10 -11
- data/app/controllers/admin/product_properties_controller.rb +5 -5
- data/app/controllers/admin/product_scopes_controller.rb +12 -4
- data/app/controllers/admin/products_controller.rb +17 -12
- data/app/controllers/admin/properties_controller.rb +7 -7
- data/app/controllers/admin/prototypes_controller.rb +15 -15
- data/app/controllers/admin/reports_controller.rb +12 -11
- data/app/controllers/admin/shipments_controller.rb +0 -5
- data/app/controllers/admin/shipping_categories_controller.rb +6 -6
- data/app/controllers/admin/shipping_methods_controller.rb +1 -2
- data/app/controllers/admin/states_controller.rb +12 -12
- data/app/controllers/admin/tax_categories_controller.rb +2 -2
- data/app/controllers/admin/tax_rates_controller.rb +8 -8
- data/app/controllers/admin/tax_settings_controller.rb +1 -1
- data/app/controllers/admin/taxonomies_controller.rb +3 -3
- data/app/controllers/admin/taxons_controller.rb +1 -8
- data/app/controllers/admin/trackers_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +6 -9
- data/app/controllers/admin/variants_controller.rb +13 -2
- data/app/controllers/admin/zones_controller.rb +9 -9
- data/app/controllers/checkout_controller.rb +5 -5
- data/app/controllers/products_controller.rb +1 -1
- data/app/controllers/taxons_controller.rb +3 -1
- data/app/helpers/admin/navigation_helper.rb +36 -19
- data/app/helpers/admin/payments_helper.rb +1 -1
- data/app/helpers/admin/product_groups_helper.rb +1 -1
- data/app/helpers/admin/product_properties_helper.rb +5 -5
- data/app/helpers/admin/products_helper.rb +2 -2
- data/app/helpers/admin/users_helper.rb +5 -2
- data/app/helpers/hook_helper.rb +3 -3
- data/app/helpers/products_helper.rb +0 -19
- data/app/helpers/spree/base_helper.rb +33 -2
- data/app/helpers/taxons_helper.rb +3 -3
- data/app/mailers/order_mailer.rb +2 -2
- data/app/mailers/shipment_mailer.rb +2 -2
- data/app/models/address.rb +42 -9
- data/app/models/adjustment.rb +8 -8
- data/app/models/app_configuration.rb +0 -6
- data/app/models/billing_integration.rb +1 -1
- data/app/models/calculator/sales_tax.rb +3 -3
- data/app/models/configuration.rb +1 -1
- data/app/models/country.rb +4 -5
- data/app/models/creditcard.rb +38 -31
- data/app/models/gateway.rb +14 -14
- data/app/models/gateway/beanstream.rb +4 -4
- data/app/models/gateway/bogus.rb +6 -6
- data/app/models/gateway/braintree.rb +88 -0
- data/app/models/gateway/eway.rb +3 -3
- data/app/models/image.rb +5 -4
- data/app/models/option_type.rb +1 -0
- data/app/models/order.rb +60 -21
- data/app/models/payment.rb +5 -32
- data/app/models/preference.rb +7 -7
- data/app/models/product.rb +22 -7
- data/app/models/product_group.rb +22 -26
- data/app/models/product_property.rb +5 -5
- data/app/models/product_scope.rb +26 -6
- data/app/models/property.rb +1 -1
- data/app/models/state.rb +2 -3
- data/app/models/tax_category.rb +1 -0
- data/app/models/tax_rate.rb +1 -2
- data/app/models/taxon.rb +12 -10
- data/app/models/taxonomy.rb +7 -4
- data/app/models/tracker.rb +1 -1
- data/app/models/user.rb +4 -0
- data/app/models/variant.rb +1 -1
- data/app/models/zone.rb +1 -1
- data/app/models/zone_member.rb +3 -3
- data/app/views/admin/{shared → adjustments}/_adjustments_table.html.erb +7 -4
- data/app/views/admin/adjustments/edit.html.erb +1 -1
- data/app/views/admin/adjustments/index.html.erb +2 -2
- data/app/views/admin/adjustments/new.html.erb +2 -1
- data/app/views/admin/general_settings/edit.html.erb +4 -12
- data/app/views/admin/general_settings/show.html.erb +0 -5
- data/app/views/admin/images/index.html.erb +8 -5
- data/app/views/admin/inventory_settings/show.html.erb +1 -1
- data/app/views/admin/mail_methods/index.html.erb +4 -4
- data/app/views/admin/option_types/_form.html.erb +4 -4
- data/app/views/admin/option_types/_option_value_fields.html.erb +2 -2
- data/app/views/admin/option_types/edit.html.erb +4 -2
- data/app/views/admin/option_types/index.html.erb +5 -5
- data/app/views/admin/orders/_line_item.html.erb +2 -1
- data/app/views/admin/orders/history.html.erb +6 -2
- data/app/views/admin/orders/index.html.erb +22 -19
- data/app/views/admin/orders/show.html.erb +1 -1
- data/app/views/admin/orders/user.html.erb +1 -1
- data/app/views/admin/payment_methods/index.html.erb +7 -5
- data/app/views/admin/payments/_list.html.erb +3 -3
- data/app/views/admin/payments/index.html.erb +1 -1
- data/app/views/admin/payments/show.html.erb +2 -2
- data/app/views/admin/product_groups/edit.html.erb +7 -7
- data/app/views/admin/product_groups/index.html.erb +5 -3
- data/app/views/admin/product_groups/update.js.erb +4 -3
- data/app/views/admin/product_properties/_product_property_fields.html.erb +3 -3
- data/app/views/admin/product_properties/index.html.erb +10 -5
- data/app/views/admin/product_scopes/destroy.js.erb +1 -0
- data/app/views/admin/products/index.html.erb +32 -33
- data/app/views/admin/properties/_form.html.erb +2 -2
- data/app/views/admin/properties/index.html.erb +4 -4
- data/app/views/admin/prototypes/index.html.erb +4 -4
- data/app/views/admin/shared/_address_form.html.erb +1 -1
- data/app/views/admin/shared/_calculator_fields.html.erb +1 -1
- data/app/views/admin/shared/_destroy.js.erb +15 -2
- data/app/views/admin/shared/_order_tabs.html.erb +1 -1
- data/app/views/admin/shared/_report_criteria.html.erb +1 -1
- data/app/views/admin/shipments/_form.html.erb +6 -2
- data/app/views/admin/shipments/edit.html.erb +1 -1
- data/app/views/admin/shipments/index.html.erb +4 -2
- data/app/views/admin/shipping_methods/_form.html.erb +2 -0
- data/app/views/admin/shipping_methods/index.html.erb +3 -2
- data/app/views/admin/states/_state_list.html.erb +11 -5
- data/app/views/admin/tax_categories/index.html.erb +9 -4
- data/app/views/admin/tax_settings/show.html.erb +2 -2
- data/app/views/admin/taxonomies/_list.html.erb +4 -2
- data/app/views/admin/taxonomies/index.html.erb +2 -2
- data/app/views/admin/taxons/_form.html.erb +1 -1
- data/app/views/admin/trackers/index.html.erb +5 -5
- data/app/views/admin/users/_form.html.erb +3 -4
- data/app/views/admin/users/index.html.erb +7 -6
- data/app/views/admin/users/show.html.erb +3 -3
- data/app/views/admin/variants/index.html.erb +21 -6
- data/app/views/admin/zones/_form.html.erb +9 -9
- data/app/views/admin/zones/_member_type.html.erb +5 -5
- data/app/views/admin/zones/index.html.erb +7 -5
- data/app/views/checkout/_address.html.erb +2 -2
- data/app/views/checkout/_payment.html.erb +3 -6
- data/app/views/layouts/admin.html.erb +3 -9
- data/app/views/layouts/spree_application.html.erb +2 -1
- data/app/views/orders/_line_item.html.erb +1 -1
- data/app/views/orders/edit.html.erb +17 -16
- data/app/views/orders/show.html.erb +1 -1
- data/app/views/shared/_admin_head.html.erb +1 -1
- data/app/views/shared/_error_messages.html.erb +2 -2
- data/app/views/shared/_filters.html.erb +4 -4
- data/app/views/shared/_head.html.erb +2 -2
- data/app/views/shared/_nav_bar.html.erb +2 -2
- data/app/views/shared/_products.html.erb +4 -2
- data/app/views/shared/_taxonomies.html.erb +15 -8
- data/app/views/shipment_mailer/shipped_email.text.erb +2 -2
- data/config/cucumber.yml +10 -0
- data/config/initializers/form_builder.rb +1 -5
- data/config/initializers/workarounds_for_ruby19.rb +5 -5
- data/config/locales/en.yml +33 -6
- data/config/routes.rb +18 -13
- data/db/migrate/20090923100315_add_count_on_hand_to_variants_and_products.rb +5 -5
- data/db/migrate/20091213222815_creditcard_last_four_digits.rb +5 -5
- data/db/migrate/20100105132138_shipment_id_for_inventory_units.rb +2 -2
- data/db/migrate/20100209025806_create_payment_methods.rb +3 -3
- data/db/migrate/20100209144531_polymorphic_payments.rb +1 -1
- data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +2 -2
- data/db/migrate/20100224153127_deleted_at_for_payment_methods.rb +1 -1
- data/db/migrate/20100506185838_add_description_to_taxons.rb +1 -1
- data/db/migrate/20100816212146_shipping_method_id_for_orders.rb +1 -1
- data/db/migrate/20101026184808_migrate_checkout_to_orders.rb +2 -2
- data/db/migrate/20101223215658_add_position_to_variants.rb +9 -0
- data/db/migrate/20110110130847_add_next_state_to_state_events.rb +9 -0
- data/db/migrate/20110111122537_add_position_to_option_types.rb +9 -0
- data/db/migrate/20110314192118_remove_trailing_slashes_in_taxon_permalinks.rb +17 -0
- data/lib/custom_fixtures.rb +1 -1
- data/lib/{seo_assist.rb → middleware/seo_assist.rb} +14 -8
- data/lib/product_filters.rb +49 -43
- data/lib/redirect_legacy_product_url.rb +5 -5
- data/lib/scopes.rb +2 -2
- data/lib/scopes/dynamic.rb +9 -16
- data/lib/scopes/product.rb +33 -16
- data/lib/scopes/variant.rb +4 -3
- data/lib/spree/calculated_adjustments.rb +5 -2
- data/lib/spree/config.rb +2 -0
- data/lib/spree/current_order.rb +4 -4
- data/lib/spree/mail_settings.rb +3 -2
- data/lib/spree/search/base.rb +9 -10
- data/lib/spree_base.rb +22 -23
- data/lib/spree_core.rb +10 -69
- data/lib/spree_core/authorize_net_cim_hack.rb +1 -1
- data/lib/spree_core/delegate_belongs_to.rb +18 -24
- data/lib/spree_core/enumerable_constants.rb +38 -38
- data/lib/spree_core/find_by_param.rb +8 -6
- data/lib/spree_core/preferences/preference_definition.rb +7 -7
- data/lib/spree_core/railtie.rb +58 -0
- data/lib/spree_core/ssl_requirement.rb +4 -3
- data/lib/spree_core/testing_support/factories.rb +13 -0
- data/lib/spree_core/testing_support/factories/address_factory.rb +20 -0
- data/lib/spree_core/testing_support/factories/adjustment_factory.rb +6 -0
- data/lib/spree_core/testing_support/factories/calculator_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/configuraion_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/country_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/creditcard_factory.rb +11 -0
- data/lib/spree_core/testing_support/factories/inventory_unit_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/line_item_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/mail_method_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/options_factory.rb +10 -0
- data/lib/spree_core/testing_support/factories/order_factory.rb +18 -0
- data/lib/spree_core/testing_support/factories/payment_factory.rb +26 -0
- data/lib/spree_core/testing_support/factories/payment_method_factory.rb +17 -0
- data/lib/spree_core/testing_support/factories/product_factory.rb +16 -0
- data/lib/spree_core/testing_support/factories/product_group_factory.rb +3 -0
- data/lib/spree_core/testing_support/factories/product_option_type_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/product_property_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/product_scope_factory.rb +6 -0
- data/lib/spree_core/testing_support/factories/property_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/prototype_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/return_authorization_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/role_factory.rb +9 -0
- data/lib/spree_core/testing_support/factories/shipment_factory.rb +9 -0
- data/lib/spree_core/testing_support/factories/shipping_category_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/shipping_method_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/state_factory.rb +11 -0
- data/lib/spree_core/testing_support/factories/tax_category_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/tax_rate_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/taxon_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/taxonomy_factory.rb +3 -0
- data/lib/spree_core/testing_support/factories/tracker_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/user_factory.rb +15 -0
- data/lib/spree_core/testing_support/factories/variant_factory.rb +14 -0
- data/lib/spree_core/testing_support/factories/zone_factory.rb +18 -0
- data/lib/spree_core/theme_support/hook.rb +1 -1
- data/lib/spree_core/theme_support/more_patches.rb +20 -20
- data/lib/spree_core/version.rb +5 -0
- data/lib/tasks/common.rb +30 -0
- data/lib/tasks/install.rake +1 -1
- data/lib/tasks/rake_util.rb +19 -0
- data/lib/tasks/taxon.rake +14 -0
- data/public/images/reorder.jpg +0 -0
- data/public/javascripts/admin.js +0 -6
- data/public/javascripts/admin/unobtrusive_handlers.js +28 -0
- data/public/javascripts/checkout.js +3 -3
- data/public/stylesheets/admin/admin-forms.css +1 -6
- data/public/stylesheets/admin/admin.css +0 -28
- data/public/stylesheets/screen.css +0 -280
- metadata +81 -43
- data/app/controllers/countries_controller.rb +0 -11
- data/app/models/spree/alert.rb +0 -13
- data/app/models/state_monitor.rb +0 -25
- data/app/views/admin/shared/_alert.html.erb +0 -6
- data/app/views/countries/index.js.erb +0 -1
- data/app/views/shared/_doc_and_xmlns.html.erb +0 -2
- data/app/views/users/edit.html.erb +0 -9
- data/app/views/users/show.html.erb +0 -46
- data/lib/spree_core/validation_group.rb +0 -143
- data/public/stylesheets/scaffold.css +0 -54
@@ -5,7 +5,7 @@ module Spree::CalculatedAdjustments
|
|
5
5
|
accepts_nested_attributes_for :calculator
|
6
6
|
validates :calculator, :presence => true if options[:require]
|
7
7
|
|
8
|
-
|
8
|
+
class_attribute :calculators
|
9
9
|
self.calculators = Set.new
|
10
10
|
# @available_calculators = []
|
11
11
|
def register_calculator(calculator)
|
@@ -50,7 +50,10 @@ module Spree::CalculatedAdjustments
|
|
50
50
|
# By default the adjustment will not be considered mandatory
|
51
51
|
def create_adjustment(label, target, calculable, mandatory=false)
|
52
52
|
amount = self.calculator.compute(calculable)
|
53
|
-
target.adjustments.create(:amount => amount,
|
53
|
+
target.adjustments.create(:amount => amount, :source => calculable,
|
54
|
+
:originator => self,
|
55
|
+
:label => label,
|
56
|
+
:mandatory => mandatory)
|
54
57
|
end
|
55
58
|
|
56
59
|
# Updates the amount of the adjustment using our Calculator and calling the +compute+ method with the +calculable+
|
data/lib/spree/config.rb
CHANGED
@@ -19,6 +19,7 @@ module Spree
|
|
19
19
|
@configuration
|
20
20
|
end
|
21
21
|
|
22
|
+
# searcher_class allows spree extension writers to provide their own Search class
|
22
23
|
def searcher_class
|
23
24
|
@searcher_class ||= Spree::Search::Base
|
24
25
|
end
|
@@ -26,6 +27,7 @@ module Spree
|
|
26
27
|
def searcher_class=(sclass)
|
27
28
|
@searcher_class = sclass
|
28
29
|
end
|
30
|
+
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/spree/current_order.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
module CurrentOrder
|
3
3
|
|
4
|
-
# This should be overridden by an auth-related extension which would then have the
|
5
|
-
# current user before saving.
|
4
|
+
# This should be overridden by an auth-related extension which would then have the
|
5
|
+
# opportunity to associate the new order with the # current user before saving.
|
6
6
|
def before_save_new_order
|
7
7
|
end
|
8
8
|
|
9
|
-
# This should be overridden by an auth-related extension which would then have the
|
10
|
-
# after saving.
|
9
|
+
# This should be overridden by an auth-related extension which would then have the
|
10
|
+
# opporutnity to store tokens, etc. in the session # after saving.
|
11
11
|
def after_save_new_order
|
12
12
|
end
|
13
13
|
|
data/lib/spree/mail_settings.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
module MailSettings
|
3
3
|
|
4
|
-
# Override the Rails application mail settings based on preference.
|
4
|
+
# Override the Rails application mail settings based on preference.
|
5
|
+
# This makes it possible to configure the mail settings
|
5
6
|
# through an admin interface instead of requiring changes to the Rails envrionment file.
|
6
7
|
def self.init
|
7
8
|
return unless mail_method = MailMethod.current
|
@@ -29,4 +30,4 @@ module Spree
|
|
29
30
|
end
|
30
31
|
|
31
32
|
end
|
32
|
-
end
|
33
|
+
end
|
data/lib/spree/search/base.rb
CHANGED
@@ -10,15 +10,13 @@ module Spree::Search
|
|
10
10
|
def retrieve_products
|
11
11
|
base_scope = get_base_scope
|
12
12
|
@products_scope = @product_group.apply_on(base_scope)
|
13
|
-
|
14
13
|
curr_page = manage_pagination && keywords ? 1 : page
|
15
|
-
|
14
|
+
|
15
|
+
@products = @products_scope.paginate({
|
16
16
|
:include => [:images, :master],
|
17
17
|
:per_page => per_page,
|
18
18
|
:page => curr_page
|
19
19
|
})
|
20
|
-
|
21
|
-
return @products
|
22
20
|
end
|
23
21
|
|
24
22
|
def method_missing(name)
|
@@ -28,13 +26,14 @@ module Spree::Search
|
|
28
26
|
protected
|
29
27
|
def get_base_scope
|
30
28
|
base_scope = @cached_product_group ? @cached_product_group.products.active : Product.active
|
31
|
-
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
|
29
|
+
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
|
32
30
|
base_scope = get_products_conditions_for(base_scope, keywords) unless keywords.blank?
|
33
31
|
|
34
32
|
base_scope = base_scope.on_hand unless Spree::Config[:show_zero_stock_products]
|
33
|
+
base_scope = base_scope.group_by_products_id if @product_group.product_scopes.size > 1
|
35
34
|
base_scope
|
36
35
|
end
|
37
|
-
|
36
|
+
|
38
37
|
# method should return new scope based on base_scope
|
39
38
|
def get_products_conditions_for(base_scope, query)
|
40
39
|
base_scope.like_any([:name, :description], query.split)
|
@@ -46,20 +45,20 @@ module Spree::Search
|
|
46
45
|
|
47
46
|
per_page = params[:per_page].to_i
|
48
47
|
@properties[:per_page] = per_page > 0 ? per_page : Spree::Config[:products_per_page]
|
49
|
-
@properties[:page] = (params[:page].to_i <= 0) ? 1 : params[:page].to_i
|
50
|
-
|
48
|
+
@properties[:page] = (params[:page].to_i <= 0) ? 1 : params[:page].to_i
|
49
|
+
|
51
50
|
if !params[:order_by_price].blank?
|
52
51
|
@product_group = ProductGroup.new.from_route([params[:order_by_price]+"_by_master_price"])
|
53
52
|
elsif params[:product_group_name]
|
54
53
|
@cached_product_group = ProductGroup.find_by_permalink(params[:product_group_name])
|
55
54
|
@product_group = ProductGroup.new
|
56
55
|
elsif params[:product_group_query]
|
57
|
-
@product_group = ProductGroup.new.from_route(params[:product_group_query])
|
56
|
+
@product_group = ProductGroup.new.from_route(params[:product_group_query].split("/"))
|
58
57
|
else
|
59
58
|
@product_group = ProductGroup.new
|
60
59
|
end
|
61
60
|
@product_group = @product_group.from_search(params[:search]) if params[:search]
|
62
|
-
|
61
|
+
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
data/lib/spree_base.rb
CHANGED
@@ -3,13 +3,11 @@ module SpreeBase
|
|
3
3
|
def access_forbidden
|
4
4
|
render :text => 'Access Forbidden', :layout => true, :status => 401
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
# can be used in views as well as controllers.
|
8
8
|
# e.g. <% title = 'This is a custom title for this view' %>
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
9
|
+
attr_writer :title
|
10
|
+
|
13
11
|
def title
|
14
12
|
title_string = @title.blank? ? accurate_title : @title
|
15
13
|
if title_string.blank?
|
@@ -22,17 +20,18 @@ module SpreeBase
|
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
25
|
-
|
23
|
+
|
26
24
|
protected
|
27
|
-
|
25
|
+
|
28
26
|
def default_title
|
29
27
|
Spree::Config[:site_name]
|
30
28
|
end
|
31
|
-
|
29
|
+
|
30
|
+
# this is a hook for subclasses to provide title
|
32
31
|
def accurate_title
|
33
|
-
|
32
|
+
nil
|
34
33
|
end
|
35
|
-
|
34
|
+
|
36
35
|
# def reject_unknown_object
|
37
36
|
# # workaround to catch problems with loading errors for permalink ids (reconsider RC permalink hack elsewhere?)
|
38
37
|
# begin
|
@@ -51,35 +50,35 @@ module SpreeBase
|
|
51
50
|
# end
|
52
51
|
# true
|
53
52
|
# end
|
54
|
-
|
55
|
-
def render_404(exception=nil)
|
53
|
+
|
54
|
+
def render_404(exception = nil)
|
56
55
|
respond_to do |type|
|
57
|
-
type.html { render :status => :not_found, :file => "#{Rails.root}/public/404.html", :layout=>nil}
|
56
|
+
type.html { render :status => :not_found, :file => "#{Rails.root}/public/404.html", :layout => nil}
|
58
57
|
type.all { render :status => :not_found, :nothing => true }
|
59
58
|
end
|
60
59
|
end
|
61
|
-
|
60
|
+
|
62
61
|
private
|
63
|
-
|
62
|
+
|
64
63
|
def redirect_back_or_default(default)
|
65
64
|
redirect_to(session["user_return_to"] || default)
|
66
65
|
session["user_return_to"] = nil
|
67
66
|
end
|
68
|
-
|
67
|
+
|
69
68
|
def instantiate_controller_and_action_names
|
70
69
|
@current_action = action_name
|
71
70
|
@current_controller = controller_name
|
72
71
|
end
|
73
|
-
|
72
|
+
|
74
73
|
def get_taxonomies
|
75
74
|
@taxonomies ||= Taxonomy.includes(:root => :children)
|
76
75
|
@taxonomies.reject { |t| t.root.nil? }
|
77
76
|
end
|
78
|
-
|
77
|
+
|
79
78
|
def current_gateway
|
80
79
|
@current_gateway ||= Gateway.current
|
81
80
|
end
|
82
|
-
|
81
|
+
|
83
82
|
#RAILS 3 TODO
|
84
83
|
# # Load all models using STI to fix associations such as @order.credits giving no results and resulting in incorrect order totals
|
85
84
|
# def touch_sti_subclasses
|
@@ -87,14 +86,14 @@ module SpreeBase
|
|
87
86
|
# load(File.join(SPREE_ROOT,'config/initializers/touch.rb'))
|
88
87
|
# end
|
89
88
|
# end
|
90
|
-
|
89
|
+
|
91
90
|
def set_user_language
|
92
91
|
locale = session[:locale] || Spree::Config[:default_locale]
|
93
|
-
locale = I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
|
92
|
+
locale = I18n.default_locale unless locale && I18n.available_locales.include?(locale.to_sym)
|
94
93
|
I18n.locale = locale.to_sym
|
95
94
|
end
|
96
95
|
end
|
97
|
-
|
96
|
+
|
98
97
|
def self.included(receiver)
|
99
98
|
#receiver.extend ClassMethods
|
100
99
|
receiver.send :include, InstanceMethods
|
@@ -104,7 +103,7 @@ module SpreeBase
|
|
104
103
|
# #RAILS 3 TODO
|
105
104
|
# #before_filter :touch_sti_subclasses
|
106
105
|
receiver.send :before_filter, 'set_user_language'
|
107
|
-
|
106
|
+
|
108
107
|
receiver.send :helper_method, 'title'
|
109
108
|
receiver.send :helper_method, 'title='
|
110
109
|
receiver.send :helper_method, 'get_taxonomies'
|
data/lib/spree_core.rb
CHANGED
@@ -33,16 +33,18 @@ require 'paperclip'
|
|
33
33
|
require 'stringex'
|
34
34
|
require 'will_paginate'
|
35
35
|
#require 'less' #TODO RAILS3: consider making this optional
|
36
|
-
require '
|
36
|
+
require 'nested_set'
|
37
37
|
require 'acts_as_list'
|
38
38
|
require 'resource_controller'
|
39
|
-
require 'searchlogic'
|
40
39
|
require 'active_merchant'
|
40
|
+
require "meta_search"
|
41
41
|
|
42
42
|
require 'spree_core/ext/active_record'
|
43
|
+
|
43
44
|
require 'spree_core/delegate_belongs_to'
|
45
|
+
ActiveRecord::Base.send :include, DelegateBelongsTo
|
46
|
+
|
44
47
|
require 'spree_core/theme_support'
|
45
|
-
require 'spree_core/validation_group'
|
46
48
|
require 'spree_core/enumerable_constants'
|
47
49
|
require 'spree_core/find_by_param'
|
48
50
|
require 'spree_core/ssl_requirement'
|
@@ -57,7 +59,7 @@ require 'spree/config'
|
|
57
59
|
require 'spree/mail_settings'
|
58
60
|
require 'spree/mail_interceptor'
|
59
61
|
require 'redirect_legacy_product_url'
|
60
|
-
require 'seo_assist'
|
62
|
+
require 'middleware/seo_assist'
|
61
63
|
|
62
64
|
require 'spree_base' # added 11-3 JBD
|
63
65
|
|
@@ -65,78 +67,17 @@ silence_warnings do
|
|
65
67
|
require 'spree_core/authorize_net_cim_hack'
|
66
68
|
end
|
67
69
|
|
68
|
-
|
69
|
-
def self.version
|
70
|
-
"0.40.4"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
module SpreeCore
|
75
|
-
class Engine < Rails::Engine
|
76
|
-
|
77
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
78
|
-
# TODO - register state monitor observer?
|
79
|
-
|
80
|
-
def self.activate
|
81
|
-
|
82
|
-
Spree::ThemeSupport::HookListener.subclasses.each do |hook_class|
|
83
|
-
Spree::ThemeSupport::Hook.add_listener(hook_class)
|
84
|
-
end
|
85
|
-
|
86
|
-
#register all payment methods (unless we're in middle of rake task since migrations cannot be run for this first time without this check)
|
87
|
-
if File.basename( $0 ) != "rake"
|
88
|
-
[
|
89
|
-
Gateway::Bogus,
|
90
|
-
Gateway::AuthorizeNet,
|
91
|
-
Gateway::AuthorizeNetCim,
|
92
|
-
Gateway::Eway,
|
93
|
-
Gateway::Linkpoint,
|
94
|
-
Gateway::PayPal,
|
95
|
-
Gateway::SagePay,
|
96
|
-
Gateway::Beanstream,
|
97
|
-
PaymentMethod::Check
|
98
|
-
].each{|gw|
|
99
|
-
begin
|
100
|
-
gw.register
|
101
|
-
rescue Exception => e
|
102
|
-
$stderr.puts "Error registering gateway #{gw}: #{e}"
|
103
|
-
end
|
104
|
-
}
|
105
|
-
|
106
|
-
#register all calculators
|
107
|
-
[
|
108
|
-
Calculator::FlatPercentItemTotal,
|
109
|
-
Calculator::FlatRate,
|
110
|
-
Calculator::FlexiRate,
|
111
|
-
Calculator::PerItem,
|
112
|
-
Calculator::SalesTax,
|
113
|
-
Calculator::Vat,
|
114
|
-
Calculator::PriceBucket
|
115
|
-
].each{|c_model|
|
116
|
-
begin
|
117
|
-
c_model.register if c_model.table_exists?
|
118
|
-
rescue Exception => e
|
119
|
-
$stderr.puts "Error registering calculator #{c_model}"
|
120
|
-
end
|
121
|
-
}
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
config.to_prepare &method(:activate).to_proc
|
128
|
-
|
129
|
-
end
|
130
|
-
end
|
70
|
+
require 'spree_core/version'
|
131
71
|
|
132
|
-
|
72
|
+
require 'spree_core/railtie'
|
133
73
|
|
134
74
|
ActiveRecord::Base.class_eval do
|
75
|
+
include Spree::CalculatedAdjustments
|
135
76
|
include CollectiveIdea::Acts::NestedSet
|
136
77
|
end
|
137
78
|
|
138
79
|
if defined?(ActionView)
|
139
|
-
require '
|
80
|
+
require 'nested_set/helper'
|
140
81
|
ActionView::Base.class_eval do
|
141
82
|
include CollectiveIdea::Acts::NestedSet::Helper
|
142
83
|
end
|
@@ -27,7 +27,7 @@ module ActiveMerchant #:nodoc:
|
|
27
27
|
# 5. Click Submit
|
28
28
|
class AuthorizeNetCimGateway < Gateway
|
29
29
|
|
30
|
-
|
30
|
+
class_attribute :test_url, :live_url
|
31
31
|
|
32
32
|
self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
|
33
33
|
self.live_url = 'https://api.authorize.net/xml/v1/request.api'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# Creates methods on object which delegate to an association proxy.
|
3
3
|
# see delegate_belongs_to for two uses
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Todo - integrate with ActiveRecord::Dirty to make sure changes to delegate object are noticed
|
6
6
|
# Should do
|
7
7
|
# class User < ActiveRecord::Base; delegate_belongs_to :contact, :firstname; end
|
@@ -10,21 +10,22 @@
|
|
10
10
|
# u.changed? # => false
|
11
11
|
# u.firstname = 'Bobby'
|
12
12
|
# u.changed? # => true
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Right now the second call to changed? would return false
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# Todo - add has_one support. fairly straightforward addition
|
17
17
|
##
|
18
18
|
module DelegateBelongsTo
|
19
|
-
|
19
|
+
extend ActiveSupport::Concern
|
20
|
+
|
20
21
|
module ClassMethods
|
21
|
-
|
22
|
+
|
22
23
|
@@default_rejected_delegate_columns = ['created_at','created_on','updated_at','updated_on','lock_version','type','id','position','parent_id','lft','rgt']
|
23
24
|
mattr_accessor :default_rejected_delegate_columns
|
24
|
-
|
25
|
+
|
25
26
|
##
|
26
27
|
# Creates methods for accessing and setting attributes on an association. Uses same
|
27
|
-
# default list of attributes as delegates_to_association.
|
28
|
+
# default list of attributes as delegates_to_association.
|
28
29
|
# @todo Integrate this with ActiveRecord::Dirty, so if you set a property through one of these setters and then call save on this object, it will save the associated object automatically.
|
29
30
|
# delegate_belongs_to :contact
|
30
31
|
# delegate_belongs_to :contact, [:defaults] ## same as above, and useless
|
@@ -33,7 +34,7 @@ module DelegateBelongsTo
|
|
33
34
|
def delegate_belongs_to(association, *attrs)
|
34
35
|
opts = attrs.extract_options!
|
35
36
|
initialize_association :belongs_to, association, opts
|
36
|
-
attrs = get_association_column_names(association) if attrs.empty?
|
37
|
+
attrs = get_association_column_names(association) if attrs.empty?
|
37
38
|
attrs.concat get_association_column_names(association) if attrs.delete :defaults
|
38
39
|
attrs.each do |attr|
|
39
40
|
class_def attr do |*args|
|
@@ -48,48 +49,41 @@ module DelegateBelongsTo
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
51
|
-
|
52
|
+
|
52
53
|
protected
|
53
54
|
|
54
55
|
def get_association_column_names(association, without_default_rejected_delegate_columns=true)
|
55
56
|
begin
|
56
|
-
association_klass = reflect_on_association(association).klass
|
57
|
-
methods = association_klass.column_names
|
57
|
+
association_klass = reflect_on_association(association).klass
|
58
|
+
methods = association_klass.column_names
|
58
59
|
methods.reject!{|x|default_rejected_delegate_columns.include?(x.to_s)} if without_default_rejected_delegate_columns
|
59
60
|
return methods
|
60
61
|
rescue
|
61
62
|
return []
|
62
63
|
end
|
63
64
|
end
|
64
|
-
|
65
|
+
|
65
66
|
##
|
66
67
|
# initialize_association :belongs_to, :contact
|
67
68
|
def initialize_association(type, association, opts={})
|
68
69
|
raise 'Illegal or unimplemented association type.' unless [:belongs_to].include?(type.to_s.to_sym)
|
69
70
|
send type, association, opts if reflect_on_association(association).nil?
|
70
71
|
end
|
71
|
-
|
72
|
+
|
72
73
|
private
|
73
|
-
|
74
|
+
|
74
75
|
def class_def(name, method=nil, &blk)
|
75
76
|
class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
end
|
79
|
-
|
80
|
+
|
80
81
|
module InstanceMethods
|
81
|
-
protected
|
82
|
+
protected
|
82
83
|
def delegator_for(association)
|
83
84
|
send("#{association}=", self.class.reflect_on_association(association).klass.new) if send(association).nil?
|
84
85
|
send(association)
|
85
86
|
end
|
86
87
|
end
|
87
|
-
|
88
|
-
def self.included(receiver)
|
89
|
-
receiver.extend ClassMethods
|
90
|
-
receiver.send :include, InstanceMethods
|
91
|
-
end
|
92
88
|
|
93
89
|
end
|
94
|
-
|
95
|
-
ActiveRecord::Base.send :include, DelegateBelongsTo
|