spree_core 0.30.2 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/admin/base_controller.rb +0 -31
- data/app/controllers/admin/orders_controller.rb +10 -9
- data/app/controllers/admin/overview_controller.rb +1 -1
- data/app/controllers/admin/products_controller.rb +8 -8
- data/app/controllers/admin/properties_controller.rb +1 -1
- data/app/controllers/admin/shipments_controller.rb +6 -3
- data/app/controllers/admin/shipping_methods_controller.rb +1 -1
- data/app/controllers/admin/tax_rates_controller.rb +2 -2
- data/app/controllers/admin/taxons_controller.rb +1 -2
- data/app/controllers/admin/users_controller.rb +7 -8
- data/app/controllers/admin/variants_controller.rb +2 -2
- data/app/controllers/countries_controller.rb +1 -1
- data/app/controllers/locale_controller.rb +1 -1
- data/app/controllers/spree/base_controller.rb +1 -117
- data/app/controllers/states_controller.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -7
- data/app/helpers/taxons_helper.rb +2 -2
- data/app/models/app_configuration.rb +0 -3
- data/app/models/calculator/flat_percent_item_total.rb +2 -1
- data/app/models/calculator/vat.rb +1 -1
- data/app/models/creditcard.rb +1 -1
- data/app/models/gateway/authorize_net.rb +13 -2
- data/app/models/gateway/authorize_net_cim.rb +11 -0
- data/app/models/gateway/beanstream.rb +30 -7
- data/app/models/inventory_unit.rb +21 -31
- data/app/models/line_item.rb +7 -8
- data/app/models/order.rb +4 -1
- data/app/models/product_group.rb +4 -8
- data/app/models/property.rb +1 -3
- data/app/models/return_authorization.rb +6 -1
- data/app/models/state_event.rb +3 -3
- data/app/models/state_monitor.rb +16 -16
- data/app/models/taxon.rb +6 -7
- data/app/models/user.rb +4 -0
- data/app/views/admin/general_settings/edit.html.erb +0 -8
- data/app/views/admin/general_settings/show.html.erb +5 -10
- data/app/views/admin/images/_form.html.erb +1 -1
- data/app/views/admin/images/index.html.erb +1 -1
- data/app/views/admin/option_types/new.html.erb +1 -1
- data/app/views/admin/orders/_add_product.html.erb +3 -3
- data/app/views/admin/orders/_form.html.erb +3 -0
- data/app/views/admin/orders/_user_form.html.erb +1 -1
- data/app/views/admin/orders/index.html.erb +2 -2
- data/app/views/admin/orders/show.html.erb +3 -8
- data/app/views/admin/orders/user.html.erb +1 -1
- data/app/views/admin/product_groups/index.html.erb +1 -1
- data/app/views/admin/product_groups/show.html.erb +1 -1
- data/app/views/admin/products/index.html.erb +1 -1
- data/app/views/admin/return_authorizations/_form.html.erb +3 -1
- data/app/views/admin/shared/_address_form.html.erb +1 -1
- data/app/views/admin/shared/_configuration_menu.html.erb +11 -11
- data/app/views/admin/shared/_order_tabs.html.erb +12 -12
- data/app/views/admin/shared/_product_tabs.html.erb +6 -6
- data/app/views/admin/states/_state_list.html.erb +2 -2
- data/app/views/admin/taxonomies/_js_head.html.erb +6 -8
- data/app/views/admin/taxonomies/edit.html.erb +11 -11
- data/app/views/admin/taxonomies/get_children.json.erb +5 -5
- data/app/views/admin/taxons/available.js.erb +10 -10
- data/app/views/admin/taxons/selected.html.erb +13 -13
- data/app/views/admin/variants/index.html.erb +1 -1
- data/app/views/checkout/_address.html.erb +2 -2
- data/app/views/layouts/admin.html.erb +1 -2
- data/app/views/layouts/spree_application.html.erb +1 -2
- data/app/views/shared/_admin_head.html.erb +3 -3
- data/app/views/shared/_doc_and_xmlns.html.erb +2 -0
- data/app/views/shared/_filters.html.erb +3 -28
- data/app/views/taxons/show.html.erb +7 -5
- data/config/initializers/spree.rb +1 -19
- data/config/locales/en.yml +0 -2
- data/config/routes.rb +3 -5
- data/db/migrate/20091007134354_change_taxons_to_nested_set.rb +2 -2
- data/lib/product_filters.rb +10 -11
- data/lib/scopes/product.rb +15 -0
- data/lib/spree/mail_settings.rb +2 -4
- data/lib/spree/preference_access.rb +3 -3
- data/lib/spree_base.rb +116 -0
- data/lib/spree_core.rb +3 -1
- data/lib/spree_core/preferences/model_hooks.rb +1 -1
- data/lib/tasks/install.rake +0 -1
- data/public/javascripts/admin.js +0 -6
- data/public/javascripts/admin/checkouts/edit.js +41 -40
- data/public/javascripts/admin/orders/edit_form.js +5 -4
- data/public/javascripts/jquery.cookie.js +96 -0
- data/public/javascripts/jquery.delayedobserver.js +35 -0
- data/public/javascripts/jsTree/jquery.jstree.js +3510 -0
- data/public/javascripts/jsTree/themes/apple/d.png +0 -0
- data/public/javascripts/jsTree/themes/apple/style.css +60 -34
- data/public/javascripts/jsTree/themes/apple/throbber.gif +0 -0
- data/public/javascripts/taxonomy.js +150 -149
- data/public/stylesheets/admin/admin.css +0 -34
- metadata +36 -43
- data/app/controllers/password_resets_controller.rb +0 -48
- data/app/helpers/users_helper.rb +0 -13
- data/app/models/spree/alert.rb +0 -13
- data/app/views/admin/shared/_alert.html.erb +0 -6
- data/app/views/shared/_login.html.erb +0 -21
- data/app/views/shared/_user_form.html.erb +0 -17
- data/lib/spree/i18n_utils.rb +0 -47
- data/public/javascripts/jquery.js +0 -19
- data/public/javascripts/jrails.autocomplete.js +0 -274
- data/public/javascripts/jrails.js +0 -1
- data/public/javascripts/jsTree/jquery.tree.js +0 -2058
- data/public/javascripts/jsTree/plugins/jquery.tree.contextmenu.js +0 -129
- data/public/javascripts/jsTree/themes/apple/icons.png +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
class Admin::BaseController < Spree::BaseController
|
|
2
2
|
ssl_required
|
|
3
3
|
|
|
4
|
-
before_filter :check_alerts if Rails.env.production?
|
|
5
|
-
|
|
6
4
|
helper :search
|
|
7
5
|
helper 'admin/navigation'
|
|
8
6
|
layout 'admin'
|
|
@@ -10,35 +8,6 @@ class Admin::BaseController < Spree::BaseController
|
|
|
10
8
|
before_filter :parse_date_params
|
|
11
9
|
|
|
12
10
|
protected
|
|
13
|
-
def check_alerts
|
|
14
|
-
return unless current_user and should_check_alerts?
|
|
15
|
-
|
|
16
|
-
unless session.has_key? :alerts
|
|
17
|
-
begin
|
|
18
|
-
session[:alerts] = Spree::Alert.current(request.host)
|
|
19
|
-
filter_dismissed_alerts
|
|
20
|
-
Spree::Config.set :last_check_for_spree_alerts => DateTime.now.to_s
|
|
21
|
-
rescue
|
|
22
|
-
session[:alerts] = nil
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def should_check_alerts?
|
|
28
|
-
return false if not Spree::Config[:check_for_spree_alerts]
|
|
29
|
-
|
|
30
|
-
last_check = Spree::Config[:last_check_for_spree_alerts]
|
|
31
|
-
return true if last_check.blank?
|
|
32
|
-
|
|
33
|
-
DateTime.parse(last_check) < 12.hours.ago
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def filter_dismissed_alerts
|
|
37
|
-
return unless session[:alerts]
|
|
38
|
-
dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
|
|
39
|
-
session[:alerts].reject! { |a| dismissed.include? a.id.to_s }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
11
|
def render_js_for_destroy
|
|
43
12
|
render :partial => "/admin/shared/destroy"
|
|
44
13
|
flash.notice = nil
|
|
@@ -12,7 +12,7 @@ class Admin::OrdersController < Admin::BaseController
|
|
|
12
12
|
if !@order.line_items.empty?
|
|
13
13
|
unless @order.complete?
|
|
14
14
|
|
|
15
|
-
if params[:order].key?(:
|
|
15
|
+
if params[:order].key?(:email)
|
|
16
16
|
@order.shipping_method = @order.available_shipping_methods(:front_end).first
|
|
17
17
|
@order.create_shipment!
|
|
18
18
|
redirect_to edit_admin_order_shipment_path(@order, @order.shipment)
|
|
@@ -37,10 +37,11 @@ class Admin::OrdersController < Admin::BaseController
|
|
|
37
37
|
# TODO - possible security check here but right now any admin can before any transition (and the state machine
|
|
38
38
|
# itself will make sure transitions are not applied in the wrong state)
|
|
39
39
|
event = params[:e]
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if @order.send("#{event}")
|
|
41
|
+
flash.notice = t('order_updated')
|
|
42
|
+
else
|
|
43
|
+
flash[:error] = t('cannot_perform_operation')
|
|
42
44
|
end
|
|
43
|
-
flash.notice = t('order_updated')
|
|
44
45
|
rescue Spree::GatewayError => ge
|
|
45
46
|
flash[:error] = "#{ge.message}"
|
|
46
47
|
ensure
|
|
@@ -76,15 +77,15 @@ class Admin::OrdersController < Admin::BaseController
|
|
|
76
77
|
params[:search][:completed_at_not_null] = "1"
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
if !params[:search][:
|
|
80
|
-
params[:search][:
|
|
80
|
+
if !params[:search][:completed_at_greater_than].blank?
|
|
81
|
+
params[:search][:completed_at_greater_than] = Time.zone.parse(params[:search][:completed_at_greater_than]).beginning_of_day rescue ""
|
|
81
82
|
end
|
|
82
83
|
|
|
83
|
-
if !params[:search][:
|
|
84
|
-
params[:search][:
|
|
84
|
+
if !params[:search][:completed_at_less_than].blank?
|
|
85
|
+
params[:search][:completed_at_less_than] = Time.zone.parse(params[:search][:completed_at_less_than]).end_of_day rescue ""
|
|
85
86
|
end
|
|
86
87
|
|
|
87
|
-
params[:search][:order] ||= "
|
|
88
|
+
params[:search][:order] ||= "descend_by_completed_at"
|
|
88
89
|
@search = Order.searchlogic(params[:search])
|
|
89
90
|
|
|
90
91
|
# QUERY - get per_page from form ever??? maybe push into model
|
|
@@ -4,7 +4,7 @@ class Admin::OverviewController < Admin::BaseController
|
|
|
4
4
|
#todo, add rss feed of information that is happening
|
|
5
5
|
|
|
6
6
|
def index
|
|
7
|
-
@users = User.
|
|
7
|
+
@users = User.all
|
|
8
8
|
#@users = User.find_with_deleted(:all, :order => 'updated_at desc')
|
|
9
9
|
# going to list today's orders, yesterday's orders, older orders
|
|
10
10
|
# have a filter / search at the top
|
|
@@ -73,32 +73,32 @@ class Admin::ProductsController < Admin::BaseController
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def load_data
|
|
76
|
-
@tax_categories = TaxCategory.
|
|
77
|
-
@shipping_categories = ShippingCategory.
|
|
76
|
+
@tax_categories = TaxCategory.order(:name)
|
|
77
|
+
@shipping_categories = ShippingCategory.order(:name)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def collection
|
|
81
81
|
return @collection if @collection.present?
|
|
82
|
-
|
|
82
|
+
scopes = ['group_by_products_id']
|
|
83
83
|
|
|
84
84
|
unless request.xhr?
|
|
85
85
|
# Note: the SL scopes are on/off switches, so we need to select "not_deleted" explicitly if the switch is off
|
|
86
86
|
# QUERY - better as named scope or as SL scope?
|
|
87
87
|
if params[:search].nil? || params[:search][:deleted_at_not_null].blank?
|
|
88
|
-
|
|
88
|
+
scopes << 'not_deleted'
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
@search =
|
|
91
|
+
@search = end_of_association_chain.searchlogic(params[:search] ? params[:search].except(:deleted_at_not_null) : nil)
|
|
92
92
|
@search.order ||= "ascend_by_name"
|
|
93
93
|
|
|
94
|
-
@collection = @search.do_search.paginate(:include => {:variants => [:images, :option_values]},
|
|
94
|
+
@collection = @search.do_search.instance_eval(scopes.join(".")).paginate(:include => {:variants => [:images, :option_values]},
|
|
95
95
|
:per_page => Spree::Config[:admin_products_per_page],
|
|
96
96
|
:page => params[:page])
|
|
97
97
|
else
|
|
98
98
|
includes = [{:variants => [:images, {:option_values => :option_type}]}, :master, :images]
|
|
99
99
|
|
|
100
|
-
@collection =
|
|
101
|
-
@collection.concat
|
|
100
|
+
@collection = end_of_association_chain.where(["name LIKE ?", "%#{params[:q]}%"]).includes(includes).limit(params[:limit] || 10)
|
|
101
|
+
@collection.concat end_of_association_chain.where(["variants.sku LIKE ?", "%#{params[:q]}%"]).includes(:variants_including_master).limit(params[:limit] || 10)
|
|
102
102
|
|
|
103
103
|
@collection.uniq
|
|
104
104
|
end
|
|
@@ -5,7 +5,7 @@ class Admin::PropertiesController < Admin::BaseController
|
|
|
5
5
|
belongs_to :product
|
|
6
6
|
|
|
7
7
|
def filtered
|
|
8
|
-
@properties = Property.
|
|
8
|
+
@properties = Property.where('lower(name) LIKE ?', "%#{params[:q].downcase}%").order(:name)
|
|
9
9
|
render :template => "admin/properties/filtered.html.erb", :layout => false
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -26,8 +26,11 @@ class Admin::ShipmentsController < Admin::BaseController
|
|
|
26
26
|
destroy.success.wants.js { render_js_for_destroy }
|
|
27
27
|
|
|
28
28
|
def fire
|
|
29
|
-
@shipment.send("#{params[:e]}
|
|
30
|
-
|
|
29
|
+
if @shipment.send("#{params[:e]}")
|
|
30
|
+
flash.notice = t('shipment_updated')
|
|
31
|
+
else
|
|
32
|
+
flash[:error] = t('cannot_perform_operation')
|
|
33
|
+
end
|
|
31
34
|
redirect_to :back
|
|
32
35
|
end
|
|
33
36
|
|
|
@@ -48,7 +51,7 @@ class Admin::ShipmentsController < Admin::BaseController
|
|
|
48
51
|
@shipping_methods = ShippingMethod.all_available(@order, :back_end)
|
|
49
52
|
|
|
50
53
|
@states = State.find_all_by_country_id(@selected_country_id, :order => 'name')
|
|
51
|
-
@countries =
|
|
54
|
+
@countries = Country.all
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
def edit_before # copy into instance variable before editing
|
|
@@ -14,7 +14,7 @@ class Admin::ShippingMethodsController < Admin::BaseController
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def load_data
|
|
17
|
-
@available_zones = Zone.
|
|
17
|
+
@available_zones = Zone.order(:name)
|
|
18
18
|
@calculators = ShippingMethod.calculators
|
|
19
19
|
@calculators.sort_by(&:name)
|
|
20
20
|
end
|
|
@@ -17,8 +17,8 @@ class Admin::TaxRatesController < Admin::BaseController
|
|
|
17
17
|
@object
|
|
18
18
|
end
|
|
19
19
|
def load_data
|
|
20
|
-
@available_zones = Zone.
|
|
21
|
-
@available_categories = TaxCategory.
|
|
20
|
+
@available_zones = Zone.order(:name)
|
|
21
|
+
@available_categories = TaxCategory.order(:name)
|
|
22
22
|
@calculators = TaxRate.calculators
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -24,11 +24,10 @@ class Admin::TaxonsController < Admin::BaseController
|
|
|
24
24
|
if params[:q].blank?
|
|
25
25
|
@available_taxons = []
|
|
26
26
|
else
|
|
27
|
-
@available_taxons = Taxon.
|
|
27
|
+
@available_taxons = Taxon.where('lower(name) LIKE ?', "%#{params[:q].downcase}%")
|
|
28
28
|
end
|
|
29
29
|
@available_taxons.delete_if { |taxon| @product.taxons.include?(taxon) }
|
|
30
30
|
respond_to do |format|
|
|
31
|
-
format.html
|
|
32
31
|
format.js {render :layout => false}
|
|
33
32
|
end
|
|
34
33
|
|
|
@@ -40,14 +40,13 @@ class Admin::UsersController < Admin::BaseController
|
|
|
40
40
|
|
|
41
41
|
#scope = scope.conditions "lower(email) = ?", @filter.email.downcase unless @filter.email.blank?
|
|
42
42
|
else
|
|
43
|
-
@collection = User.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
OR ship_addresses_users.lastname like :search", {:search => "#{params[:q].strip}%"}], :limit => (params[:limit] || 100))
|
|
43
|
+
@collection = User.includes(:bill_address => [:state, :country],
|
|
44
|
+
:ship_address => [:state, :country]).where("users.email like :search
|
|
45
|
+
OR addresses.firstname like :search
|
|
46
|
+
OR addresses.lastname like :search
|
|
47
|
+
OR ship_addresses_users.firstname like :search
|
|
48
|
+
OR ship_addresses_users.lastname like :search",
|
|
49
|
+
{:search => "#{params[:q].strip}%"}).limit(params[:limit] || 100)
|
|
51
50
|
end
|
|
52
51
|
end
|
|
53
52
|
|
|
@@ -47,9 +47,9 @@ class Admin::VariantsController < Admin::BaseController
|
|
|
47
47
|
@deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
|
|
48
48
|
|
|
49
49
|
if @deleted.blank?
|
|
50
|
-
@collection ||= end_of_association_chain.active.
|
|
50
|
+
@collection ||= end_of_association_chain.active.all
|
|
51
51
|
else
|
|
52
|
-
@collection ||= end_of_association_chain.deleted.
|
|
52
|
+
@collection ||= end_of_association_chain.deleted.all
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -4,7 +4,7 @@ class CountriesController < Spree::BaseController
|
|
|
4
4
|
index.response do |wants|
|
|
5
5
|
wants.html
|
|
6
6
|
wants.js do
|
|
7
|
-
@countries = Country.
|
|
7
|
+
@countries = Country.where('lower(name) LIKE ?', "%#{params[:q].downcase}%")
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class LocaleController < Spree::BaseController
|
|
2
2
|
def set
|
|
3
3
|
if request.referer && request.referer.starts_with?("http://" + request.host)
|
|
4
|
-
session[
|
|
4
|
+
session["user_return_to"] = request.referer
|
|
5
5
|
end
|
|
6
6
|
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
|
|
7
7
|
session[:locale] = I18n.locale = params[:locale].to_sym
|
|
@@ -1,119 +1,3 @@
|
|
|
1
1
|
class Spree::BaseController < ActionController::Base
|
|
2
|
-
|
|
3
|
-
helper :hook
|
|
4
|
-
before_filter :instantiate_controller_and_action_names
|
|
5
|
-
#RAILS 3 TODO
|
|
6
|
-
#before_filter :touch_sti_subclasses
|
|
7
|
-
before_filter :set_user_language
|
|
8
|
-
helper_method :title, :title=, :get_taxonomies, :current_gateway
|
|
9
|
-
|
|
10
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
|
11
|
-
|
|
12
|
-
include SslRequirement
|
|
13
|
-
include Spree::CurrentOrder
|
|
14
|
-
|
|
15
|
-
def access_forbidden
|
|
16
|
-
render :text => 'Access Forbidden', :layout => true, :status => 401
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# can be used in views as well as controllers.
|
|
20
|
-
# e.g. <% title = 'This is a custom title for this view' %>
|
|
21
|
-
def title=(title)
|
|
22
|
-
@title = title
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def title
|
|
26
|
-
title_string = @title.blank? ? accurate_title : @title
|
|
27
|
-
if title_string.blank?
|
|
28
|
-
default_title
|
|
29
|
-
else
|
|
30
|
-
if Spree::Config[:always_put_site_name_in_title]
|
|
31
|
-
[default_title, title_string].join(' - ')
|
|
32
|
-
else
|
|
33
|
-
title_string
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
protected
|
|
39
|
-
|
|
40
|
-
helper_method :current_order
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def default_title
|
|
44
|
-
Spree::Config[:site_name]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def accurate_title
|
|
48
|
-
return nil
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# def reject_unknown_object
|
|
52
|
-
# # workaround to catch problems with loading errors for permalink ids (reconsider RC permalink hack elsewhere?)
|
|
53
|
-
# begin
|
|
54
|
-
# load_object
|
|
55
|
-
# rescue Exception => e
|
|
56
|
-
# @object = nil
|
|
57
|
-
# end
|
|
58
|
-
# the_object = instance_variable_get "@#{object_name}"
|
|
59
|
-
# the_object = nil if (the_object.respond_to?(:deleted?) && the_object.deleted?)
|
|
60
|
-
# unless params[:id].blank? || the_object
|
|
61
|
-
# if self.respond_to? :object_missing
|
|
62
|
-
# self.object_missing(params[:id])
|
|
63
|
-
# else
|
|
64
|
-
# render_404(Exception.new("missing object in #{self.class.to_s}"))
|
|
65
|
-
# end
|
|
66
|
-
# end
|
|
67
|
-
# true
|
|
68
|
-
# end
|
|
69
|
-
|
|
70
|
-
def render_404(exception=nil)
|
|
71
|
-
respond_to do |type|
|
|
72
|
-
type.html { render :status => :not_found, :file => "#{Rails.root}/public/404.html", :layout=>nil}
|
|
73
|
-
type.all { render :status => :not_found, :nothing => true }
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def redirect_back_or_default(default)
|
|
80
|
-
redirect_to(session[:return_to] || default)
|
|
81
|
-
session[:return_to] = nil
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def instantiate_controller_and_action_names
|
|
85
|
-
@current_action = action_name
|
|
86
|
-
@current_controller = controller_name
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def get_taxonomies
|
|
90
|
-
@taxonomies ||= Taxonomy.find(:all, :include => {:root => :children})
|
|
91
|
-
@taxonomies.reject { |t| t.root.nil? }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def current_gateway
|
|
95
|
-
@current_gateway ||= Gateway.current
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
#RAILS 3 TODO
|
|
99
|
-
# # Load all models using STI to fix associations such as @order.credits giving no results and resulting in incorrect order totals
|
|
100
|
-
# def touch_sti_subclasses
|
|
101
|
-
# if Rails.env == 'development'
|
|
102
|
-
# load(File.join(SPREE_ROOT,'config/initializers/touch.rb'))
|
|
103
|
-
# end
|
|
104
|
-
# end
|
|
105
|
-
|
|
106
|
-
def set_user_language
|
|
107
|
-
locale = session[:locale] || Spree::Config[:default_locale]
|
|
108
|
-
locale = I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
|
|
109
|
-
I18n.locale = locale.to_sym
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
helper_method :available_countries
|
|
113
|
-
|
|
114
|
-
def available_countries
|
|
115
|
-
return Country.all unless zone = Zone.find_by_name(Spree::Config[:checkout_zone])
|
|
116
|
-
zone.country_list
|
|
117
|
-
end
|
|
118
|
-
|
|
2
|
+
include SpreeBase
|
|
119
3
|
end
|
|
@@ -8,7 +8,7 @@ class StatesController < Spree::BaseController
|
|
|
8
8
|
# we return ALL known information, since billing country isn't restricted
|
|
9
9
|
# by shipping country
|
|
10
10
|
@state_info = Hash.new {|h, k| h[k] = []}
|
|
11
|
-
State.
|
|
11
|
+
State.order("name ASC").each{|state|
|
|
12
12
|
@state_info[state.country_id.to_s].push [state.id, state.name]
|
|
13
13
|
}
|
|
14
14
|
end
|
|
@@ -68,13 +68,7 @@ module Spree::BaseHelper
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def stylesheet_tags(paths=stylesheet_paths)
|
|
71
|
-
|
|
72
|
-
if !paths.blank?
|
|
73
|
-
paths.each do |path|
|
|
74
|
-
output << stylesheet_link_tag(path)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
return output
|
|
71
|
+
paths.blank? ? '' : stylesheet_link_tag(paths, :cache => true)
|
|
78
72
|
end
|
|
79
73
|
|
|
80
74
|
def stylesheet_paths
|
|
@@ -19,11 +19,11 @@ module TaxonsHelper
|
|
|
19
19
|
# that we can use configurations as well as make it easier for end users to override this determination. One idea is
|
|
20
20
|
# to show the most popular products for a particular taxon (that is an exercise left to the developer.)
|
|
21
21
|
def taxon_preview(taxon, max=5)
|
|
22
|
-
products = taxon.products.active.
|
|
22
|
+
products = taxon.products.active.limit(max)
|
|
23
23
|
if (products.size < max) && Spree::Config[:show_descendents]
|
|
24
24
|
taxon.descendants.each do |taxon|
|
|
25
25
|
to_get = max - products.length
|
|
26
|
-
products += taxon.products.active.
|
|
26
|
+
products += taxon.products.active.limit(to_get)
|
|
27
27
|
break if products.size >= max
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -35,9 +35,6 @@ class AppConfiguration < Configuration
|
|
|
35
35
|
preference :cache_static_content, :boolean, :default => true
|
|
36
36
|
preference :use_content_controller, :boolean, :default => true
|
|
37
37
|
preference :allow_checkout_on_gateway_error, :boolean, :default => false
|
|
38
|
-
preference :check_for_spree_alerts, :boolean, :default => true
|
|
39
|
-
preference :dismissed_spree_alerts, :string, :default => ''
|
|
40
|
-
preference :last_check_for_spree_alerts, :string, :default => nil
|
|
41
38
|
|
|
42
39
|
validates :name, :presence => true, :uniqueness => true
|
|
43
40
|
|
|
@@ -13,6 +13,7 @@ class Calculator::FlatPercentItemTotal < Calculator
|
|
|
13
13
|
def compute(object)
|
|
14
14
|
return unless object.present? and object.line_items.present?
|
|
15
15
|
item_total = object.line_items.map(&:amount).sum
|
|
16
|
-
item_total * self.preferred_flat_percent / 100.0
|
|
16
|
+
value = item_total * self.preferred_flat_percent / 100.0
|
|
17
|
+
(value * 100).round.to_f / 100
|
|
17
18
|
end
|
|
18
19
|
end
|