spree_core 0.30.2 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/app/controllers/admin/base_controller.rb +0 -31
  2. data/app/controllers/admin/orders_controller.rb +10 -9
  3. data/app/controllers/admin/overview_controller.rb +1 -1
  4. data/app/controllers/admin/products_controller.rb +8 -8
  5. data/app/controllers/admin/properties_controller.rb +1 -1
  6. data/app/controllers/admin/shipments_controller.rb +6 -3
  7. data/app/controllers/admin/shipping_methods_controller.rb +1 -1
  8. data/app/controllers/admin/tax_rates_controller.rb +2 -2
  9. data/app/controllers/admin/taxons_controller.rb +1 -2
  10. data/app/controllers/admin/users_controller.rb +7 -8
  11. data/app/controllers/admin/variants_controller.rb +2 -2
  12. data/app/controllers/countries_controller.rb +1 -1
  13. data/app/controllers/locale_controller.rb +1 -1
  14. data/app/controllers/spree/base_controller.rb +1 -117
  15. data/app/controllers/states_controller.rb +1 -1
  16. data/app/helpers/spree/base_helper.rb +1 -7
  17. data/app/helpers/taxons_helper.rb +2 -2
  18. data/app/models/app_configuration.rb +0 -3
  19. data/app/models/calculator/flat_percent_item_total.rb +2 -1
  20. data/app/models/calculator/vat.rb +1 -1
  21. data/app/models/creditcard.rb +1 -1
  22. data/app/models/gateway/authorize_net.rb +13 -2
  23. data/app/models/gateway/authorize_net_cim.rb +11 -0
  24. data/app/models/gateway/beanstream.rb +30 -7
  25. data/app/models/inventory_unit.rb +21 -31
  26. data/app/models/line_item.rb +7 -8
  27. data/app/models/order.rb +4 -1
  28. data/app/models/product_group.rb +4 -8
  29. data/app/models/property.rb +1 -3
  30. data/app/models/return_authorization.rb +6 -1
  31. data/app/models/state_event.rb +3 -3
  32. data/app/models/state_monitor.rb +16 -16
  33. data/app/models/taxon.rb +6 -7
  34. data/app/models/user.rb +4 -0
  35. data/app/views/admin/general_settings/edit.html.erb +0 -8
  36. data/app/views/admin/general_settings/show.html.erb +5 -10
  37. data/app/views/admin/images/_form.html.erb +1 -1
  38. data/app/views/admin/images/index.html.erb +1 -1
  39. data/app/views/admin/option_types/new.html.erb +1 -1
  40. data/app/views/admin/orders/_add_product.html.erb +3 -3
  41. data/app/views/admin/orders/_form.html.erb +3 -0
  42. data/app/views/admin/orders/_user_form.html.erb +1 -1
  43. data/app/views/admin/orders/index.html.erb +2 -2
  44. data/app/views/admin/orders/show.html.erb +3 -8
  45. data/app/views/admin/orders/user.html.erb +1 -1
  46. data/app/views/admin/product_groups/index.html.erb +1 -1
  47. data/app/views/admin/product_groups/show.html.erb +1 -1
  48. data/app/views/admin/products/index.html.erb +1 -1
  49. data/app/views/admin/return_authorizations/_form.html.erb +3 -1
  50. data/app/views/admin/shared/_address_form.html.erb +1 -1
  51. data/app/views/admin/shared/_configuration_menu.html.erb +11 -11
  52. data/app/views/admin/shared/_order_tabs.html.erb +12 -12
  53. data/app/views/admin/shared/_product_tabs.html.erb +6 -6
  54. data/app/views/admin/states/_state_list.html.erb +2 -2
  55. data/app/views/admin/taxonomies/_js_head.html.erb +6 -8
  56. data/app/views/admin/taxonomies/edit.html.erb +11 -11
  57. data/app/views/admin/taxonomies/get_children.json.erb +5 -5
  58. data/app/views/admin/taxons/available.js.erb +10 -10
  59. data/app/views/admin/taxons/selected.html.erb +13 -13
  60. data/app/views/admin/variants/index.html.erb +1 -1
  61. data/app/views/checkout/_address.html.erb +2 -2
  62. data/app/views/layouts/admin.html.erb +1 -2
  63. data/app/views/layouts/spree_application.html.erb +1 -2
  64. data/app/views/shared/_admin_head.html.erb +3 -3
  65. data/app/views/shared/_doc_and_xmlns.html.erb +2 -0
  66. data/app/views/shared/_filters.html.erb +3 -28
  67. data/app/views/taxons/show.html.erb +7 -5
  68. data/config/initializers/spree.rb +1 -19
  69. data/config/locales/en.yml +0 -2
  70. data/config/routes.rb +3 -5
  71. data/db/migrate/20091007134354_change_taxons_to_nested_set.rb +2 -2
  72. data/lib/product_filters.rb +10 -11
  73. data/lib/scopes/product.rb +15 -0
  74. data/lib/spree/mail_settings.rb +2 -4
  75. data/lib/spree/preference_access.rb +3 -3
  76. data/lib/spree_base.rb +116 -0
  77. data/lib/spree_core.rb +3 -1
  78. data/lib/spree_core/preferences/model_hooks.rb +1 -1
  79. data/lib/tasks/install.rake +0 -1
  80. data/public/javascripts/admin.js +0 -6
  81. data/public/javascripts/admin/checkouts/edit.js +41 -40
  82. data/public/javascripts/admin/orders/edit_form.js +5 -4
  83. data/public/javascripts/jquery.cookie.js +96 -0
  84. data/public/javascripts/jquery.delayedobserver.js +35 -0
  85. data/public/javascripts/jsTree/jquery.jstree.js +3510 -0
  86. data/public/javascripts/jsTree/themes/apple/d.png +0 -0
  87. data/public/javascripts/jsTree/themes/apple/style.css +60 -34
  88. data/public/javascripts/jsTree/themes/apple/throbber.gif +0 -0
  89. data/public/javascripts/taxonomy.js +150 -149
  90. data/public/stylesheets/admin/admin.css +0 -34
  91. metadata +36 -43
  92. data/app/controllers/password_resets_controller.rb +0 -48
  93. data/app/helpers/users_helper.rb +0 -13
  94. data/app/models/spree/alert.rb +0 -13
  95. data/app/views/admin/shared/_alert.html.erb +0 -6
  96. data/app/views/shared/_login.html.erb +0 -21
  97. data/app/views/shared/_user_form.html.erb +0 -17
  98. data/lib/spree/i18n_utils.rb +0 -47
  99. data/public/javascripts/jquery.js +0 -19
  100. data/public/javascripts/jrails.autocomplete.js +0 -274
  101. data/public/javascripts/jrails.js +0 -1
  102. data/public/javascripts/jsTree/jquery.tree.js +0 -2058
  103. data/public/javascripts/jsTree/plugins/jquery.tree.contextmenu.js +0 -129
  104. data/public/javascripts/jsTree/themes/apple/icons.png +0 -0
@@ -32,7 +32,7 @@
32
32
  </tr>
33
33
  <% end %>
34
34
  <% unless @product.has_variants? %>
35
- <tr><td colspan="5"><%= t("none") %>.</td></tr>
35
+ <tr><td colspan="9"><%= t("none") %></td></tr>
36
36
  <% end %>
37
37
  </table>
38
38
 
@@ -61,7 +61,7 @@ div.inner input[type=text], div.inner select { width: 80%; }
61
61
  </p>
62
62
  <p id="bcountry" class="field">
63
63
  <%= bill_form.label :country_id, t(:country) %>
64
- <span id="bcountry"><%= bill_form.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'required'} %></span>
64
+ <span id="bcountry"><%= bill_form.collection_select :country_id, Country.all, :id, :name, {}, {:class => 'required'} %></span>
65
65
  <span class="req">*</span>
66
66
  </p>
67
67
  <p id="bphone" class="field">
@@ -140,7 +140,7 @@ div.inner input[type=text], div.inner select { width: 80%; }
140
140
  </p>
141
141
  <p id="scountry" class="field">
142
142
  <%= ship_form.label :country_id, t(:country) %>
143
- <span id="scountry"><%= ship_form.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'required'} %></span>
143
+ <span id="scountry"><%= ship_form.collection_select :country_id, Country.all, :id, :name, {}, {:class => 'required'} %></span>
144
144
  <span class="req">*</span>
145
145
  </p>
146
146
  <p id="sphone" class="field">
@@ -17,7 +17,7 @@
17
17
  <ul id="login-nav">
18
18
  <li><%= t('logged_in_as') %>: <%= current_user.email %></li>
19
19
  <li><%= link_to t('account'), edit_user_path(current_user) %></li>
20
- <li><%= link_to t('logout'), logout_path %></li>
20
+ <li><%= link_to t('logout'), destroy_user_session_path %></li>
21
21
  <li><%= link_to t('store'), products_path %></li>
22
22
  </ul>
23
23
  <% end %>
@@ -50,7 +50,6 @@
50
50
  <div class="flash notice"><%= self.notice %></div>
51
51
  <% end %>
52
52
 
53
- <%= render :partial => 'admin/shared/alert', :collection => session[:alerts] %>
54
53
 
55
54
  <%= yield %>
56
55
 
@@ -1,5 +1,4 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
1
+ <%= render :partial => 'shared/doc_and_xmlns'%>
3
2
  <head>
4
3
  <%= hook :inside_head do %>
5
4
  <%= render :partial => 'shared/head'%>
@@ -8,7 +8,7 @@
8
8
  :product_search_basic_json => admin_products_url(:format => 'json', :json_format => 'basic', :limit => 10),
9
9
  :user_search_basic_json => admin_users_url(:format => 'json', :json_format => 'basic', :limit => 10)
10
10
  }.to_json) %>;
11
-
11
+
12
12
  strings = <%= raw(
13
13
  [:no_results, :type_to_search, :searching].
14
14
  inject({}){|memo, item| {item => t(item) }}.to_json )
@@ -16,7 +16,7 @@
16
16
  <% end %>
17
17
 
18
18
  <%= stylesheet_link_tag 'admin/admin-reset', 'admin/grids', 'admin/admin-typography', 'admin/admin-forms', 'admin/admin-tables', 'admin/admin', 'admin/autocomplete', 'admin/token-input', :cache => 'admin-all' %>
19
- <%= javascript_include_tag 'jquery-1.4.2.min.js', 'jquery-ui', 'jrails', 'jquery.suggest', 'jrails.autocomplete', 'jquery.tokeninput.js', :cache => 'jquery-admin-plugins' %>
19
+ <%= javascript_include_tag 'jquery-1.4.2.min.js', 'rails', 'jquery-ui', 'jquery.suggest', 'jquery.tokeninput.js', 'jquery.delayedobserver.js', :cache => 'jquery-admin-plugins' %>
20
20
  <%= javascript_include_tag('jquery.template') unless controller.controller_name == "overview" %>
21
21
  <%= javascript_include_tag 'admin', 'nested-attribute', 'zone', 'calculator', 'gateway' %>
22
22
  <%= javascript_tag "$ = jQuery;" %>
@@ -26,7 +26,7 @@
26
26
 
27
27
  <%= stylesheet_link_tag '/javascripts/jquery.alerts/jquery.alerts.css' %>
28
28
  <%= stylesheet_link_tag '/javascripts/jquery.alerts/jquery.alerts.spree.css' %>
29
- <%#= stylesheet_link_tag 'jquery.autocomplete.css'
29
+ <%#= stylesheet_link_tag 'jquery.autocomplete.css'
30
30
  %>
31
31
 
32
32
  <%= javascript_tag "jQuery.alerts.dialogClass = 'spree';" %>
@@ -0,0 +1,2 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
@@ -1,27 +1,5 @@
1
- <% if @taxon.parent
2
- siblings = @taxon.parent.children
3
- else
4
- siblings = Taxonomy.all.map &:root
5
- end
6
- %>
7
-
8
- <div id="taxonomies" class="sidebar-item">
9
- <ul class="navigation-list">
10
- <% siblings.each do |s| %>
11
- <li<%= ' class="current"' if s == @taxon %>>
12
- <% if s.parent %>
13
- <%= link_to s.name, url_for(:taxon => s.id) %>
14
- <% else %>
15
- <%= link_to t("shop_by_taxonomy", :taxonomy => s.taxonomy.name.singularize), url_for(:taxon => s.id), :class => 'root' %>
16
- <% end %>
17
- </li>
18
- <% end %>
19
- </ul>
20
- </div>
21
-
22
- <%= form_for :search do |f| %>
1
+ <%= form_tag '', :method => :get do %>
23
2
  <% params[:search] ||= {} %>
24
- <input type="hidden" name="taxon" value="<%= @taxon.id %>"/>
25
3
  <input type="hidden" name="per_page" value="<%= params[:per_page] %>"/>
26
4
 
27
5
  <% filters = @taxon ? @taxon.applicable_filters : [ProductFilters.all_taxons] %>
@@ -34,19 +12,16 @@
34
12
  <% labels.each do |nm,val| %>
35
13
  <% label = "#{filter[:name]}_#{nm}".gsub(/\s+/,'_') %>
36
14
  <li class="nowrap">
37
- <%# had problems with the following, so am hard-coding it %>
38
- <%# f.check_box "taxons_id_equals_any[]", {}, taxon.id %>
39
15
  <input type="checkbox"
40
16
  id="<%= label %>"
41
17
  name="search[<%= filter[:scope].to_s %>][]"
42
18
  value="<%= val %>"
43
- <%= params[:search][filter[:scope]] && params[:search][filter[:scope]].include?(val.to_s) ? "checked" : "" %>
44
- onclick="this.form.submit();"
45
- />
19
+ <%= params[:search][filter[:scope]] && params[:search][filter[:scope]].include?(val.to_s) ? "checked" : "" %> />
46
20
  <label class="nowrap" for="<%= label %>"> <%= nm %> </label>
47
21
  </li>
48
22
  <% end %>
49
23
  </ul>
50
24
  </div>
51
25
  <% end %>
26
+ <%= submit_tag t(:search), :name => nil %>
52
27
  <% end %>
@@ -1,5 +1,12 @@
1
1
  <h1><%= @taxon.name %></h1>
2
2
 
3
+ <% content_for :sidebar do %>
4
+ <%= hook :taxon_sidebar_navigation do %>
5
+ <%= render :partial => "shared/taxonomies" %>
6
+ <%= render(:partial => "shared/filters") if @taxon.children.empty? %>
7
+ <% end %>
8
+ <% end %>
9
+
3
10
  <% if @taxon.children.empty? || !params[:keywords].blank? %>
4
11
  <%= hook :taxon_products do %>
5
12
  <%= render :partial => "shared/products", :locals => {:products => @products, :taxon => @taxon } %>
@@ -10,8 +17,3 @@
10
17
  <% end %>
11
18
  <% end %>
12
19
 
13
- <% content_for :sidebar do %>
14
- <%= hook :taxon_sidebar_navigation do %>
15
- <%= render :partial => "shared/taxonomies" %>
16
- <% end %>
17
- <% end %>
@@ -22,24 +22,6 @@ end
22
22
  # include Spree::Support::CoreExtensions::Array
23
23
  #end
24
24
 
25
- #RAILS3 TODO
26
- # class ActiveRecord::Base
27
- # # Ryan Bates - http://railscasts.com/episodes/112
28
- # scope :conditions, lambda { |*args| where(args)}
29
- #
30
- # # general merging of conditions, names following the searchlogic pattern
31
- # # conditions_all is a more descriptively named enhancement of the above
32
- # scope :conditions_all, lambda { |*args| where([args].flatten)}
33
- #
34
- # # forming the disjunction of a list of conditions (as strings)
35
- # scope :conditions_any, lambda { |*args|
36
- # args = [args].flatten
37
- # raise "non-strings in conditions_any" unless args.all? {|s| s.is_a? String}
38
- # { where(args.map {|c| "(#{c})"}.join(" OR ")) }
39
- # }
40
- # end
41
-
42
-
43
25
  String.class_eval do
44
26
  include SpreeCore::Ext::String
45
- end
27
+ end
@@ -880,8 +880,6 @@ en:
880
880
  ssl_will_be_used_in_production_mode: "SSL will be used in production mode"
881
881
  ssl_will_not_be_used_in_development_and_test_modes: "SSL will not be used in development and test mode if necessary."
882
882
  ssl_will_not_be_used_in_production_mode: "SSL will not be used in production mode"
883
- spree_alert_checking: "Check for Spree security and release alerts"
884
- spree_alert_not_checking: "Not checking for Spree security and release alerts"
885
883
  start: Start
886
884
  start_date: Valid from
887
885
  state: State
data/config/routes.rb CHANGED
@@ -149,11 +149,7 @@ Rails.application.routes.draw do
149
149
  end
150
150
  end
151
151
 
152
- resource :general_settings do
153
- collection do
154
- post :dismiss_alert
155
- end
156
- end
152
+ resource :general_settings
157
153
 
158
154
  resources :taxonomies do
159
155
  member do
@@ -185,6 +181,8 @@ Rails.application.routes.draw do
185
181
  resources :mail_methods
186
182
  end
187
183
 
184
+ match '/admin' => 'admin/orders#index', :as => :admin
185
+
188
186
  match '/content/cvv' => 'content#cvv'
189
187
 
190
188
  #RAILS3 TODO - we should disable this by default
@@ -18,14 +18,14 @@ class ChangeTaxonsToNestedSet < ActiveRecord::Migration
18
18
  # set left
19
19
  node[left_column_name] = indices[scope.call(node)] += 1
20
20
  # find
21
- find(:all, :conditions => ["#{quoted_parent_column_name} = ?", node], :order => "position ASC").each{|n| set_left_and_rights.call(n) }
21
+ where("#{quoted_parent_column_name} = ?", node).order("position ASC").each{ |n| set_left_and_rights.call(n) }
22
22
  # set right
23
23
  node[right_column_name] = indices[scope.call(node)] += 1
24
24
  node.save!
25
25
  end
26
26
 
27
27
  # Find root node(s)
28
- find(:all, :conditions => "#{quoted_parent_column_name} IS NULL", :order => "position ASC").each do |root_node|
28
+ where("#{quoted_parent_column_name} IS NULL").order("position ASC").each do |root_node|
29
29
  # setup index for this scope
30
30
  indices[scope.call(root_node)] ||= 0
31
31
  set_left_and_rights.call(root_node)
@@ -45,7 +45,7 @@ module ProductFilters
45
45
  Product.scope :price_range_any,
46
46
  lambda {|opts|
47
47
  conds = opts.map {|o| ProductFilters.price_filter[:conds][o]}.reject {|c| c.nil?}
48
- Product.scoped(:joins => :master).conditions_any(conds).scope :find
48
+ Product.scoped(:joins => :master).conditions_any(conds)
49
49
  }
50
50
 
51
51
  def ProductFilters.price_filter
@@ -79,17 +79,16 @@ module ProductFilters
79
79
  Product.scope :brand_any,
80
80
  lambda {|opts|
81
81
  conds = opts.map {|o| ProductFilters.brand_filter[:conds][o]}.reject {|c| c.nil?}
82
- Product.with_property(@@brand_property, "p_brand").conditions_any(conds).scope(:find)
82
+ Product.with_property("brand").conditions_any(conds)
83
83
  }
84
84
 
85
85
  def ProductFilters.brand_filter
86
86
  brands = ProductProperty.find_all_by_property_id(@@brand_property).map(&:value).uniq
87
- conds = Hash[*brands.map {|b| [b, "p_brand.value = '#{b}'"]}.flatten]
88
- conds["No brand"] = "p_brand.value is NULL"
89
- { :name => "All Brands",
87
+ conds = Hash[*brands.map {|b| [b, "product_properties.value = '#{b}'"]}.flatten]
88
+ { :name => "Brands",
90
89
  :scope => :brand_any,
91
90
  :conds => conds,
92
- :labels => (brands.sort + ["No brand"]).map {|k| [k,k]}
91
+ :labels => (brands.sort).map {|k| [k,k]}
93
92
  }
94
93
  end
95
94
  end
@@ -97,7 +96,7 @@ module ProductFilters
97
96
  # Example: a parametrized filter
98
97
  # The filter above may show brands which aren't applicable to the current taxon,
99
98
  # so this one only shows the brands that are relevant to a particular taxon and
100
- # its descendents.
99
+ # its descendants.
101
100
  #
102
101
  # We don't have to give a new scope since the conditions here are a subset of the
103
102
  # more general filter, so decoding will still work - as long as the filters on a
@@ -115,7 +114,7 @@ module ProductFilters
115
114
  # the product properties model.
116
115
 
117
116
  if Property.table_exists? && @@brand_property
118
- Product.scope :selective_brand_any, lambda {|opts| Product.brand_any(opts).scope(:find) }
117
+ Product.scope :selective_brand_any, lambda {|opts| Product.brand_any(opts) }
119
118
 
120
119
  def ProductFilters.selective_brand_filter(taxon = nil)
121
120
  if taxon.nil?
@@ -124,7 +123,7 @@ module ProductFilters
124
123
  all_brands = ProductProperty.find_all_by_property_id(@@brand_property).map(&:value).uniq
125
124
  scope = ProductProperty.scoped(:conditions => ["property_id = ?", @@brand_property]).
126
125
  scoped(:joins => {:product => :taxons},
127
- :conditions => ["taxons.id in (?)", [taxon] + taxon.descendents])
126
+ :conditions => ["taxons.id in (?)", [taxon] + taxon.descendants])
128
127
  brands = scope.map {|p| p.value}
129
128
 
130
129
  { :name => "Applicable Brands",
@@ -159,12 +158,12 @@ module ProductFilters
159
158
 
160
159
  # Filtering by the list of all taxons
161
160
  #
162
- # Similar idea as above, but we don't want the descendents' products, hence
161
+ # Similar idea as above, but we don't want the descendants' products, hence
163
162
  # it uses one of the auto-generated scopes from SearchLogic.
164
163
  #
165
164
  # idea: expand the format to allow nesting of labels?
166
165
  def ProductFilters.all_taxons
167
- taxons = Taxonomy.all.map {|t| [t.root] + t.root.descendents }.flatten
166
+ taxons = Taxonomy.all.map {|t| [t.root] + t.root.descendants }.flatten
168
167
  { :name => "All taxons",
169
168
  :scope => :taxons_id_equals_any,
170
169
  :labels => taxons.sort_by(&:name).map {|t| [t.name, t.id]},
@@ -44,6 +44,21 @@ module Scopes::Product
44
44
  :with_ids => :product_picker_field
45
45
  }
46
46
 
47
+ # Ryan Bates - http://railscasts.com/episodes/112
48
+ # general merging of conditions, names following the searchlogic pattern
49
+ ::Product.scope :conditions, lambda { |*args| {:conditions => args}}
50
+ # conditions_all is a more descriptively named enhancement of the above
51
+ ::Product.scope :conditions_all, lambda { |*args| {:conditions => [args].flatten}}
52
+
53
+ # forming the disjunction of a list of conditions (as strings)
54
+ ::Product.scope :conditions_any, lambda { |*args|
55
+ args = [args].flatten
56
+ raise "non-strings in conditions_any" unless args.all? {|s| s.is_a? String}
57
+ {:conditions => args.map {|c| "(#{c})"}.join(" OR ")}
58
+ }
59
+
60
+
61
+
47
62
  #RAILS3 TODO - scopes are duplicated here and in model/product.rb - can we DRY it up?
48
63
  # default product scope only lists available and non-deleted products
49
64
  # ::Product.scope :not_deleted, lambda { where("products.deleted_at is null") }
@@ -18,12 +18,10 @@ module Spree
18
18
  mail_server_settings[:password] = mail_method.preferred_smtp_password
19
19
  end
20
20
 
21
+ mail_server_settings[:enable_starttls_auto] = (mail_method.preferred_secure_connection_type == 'TLS')
22
+
21
23
  ActionMailer::Base.smtp_settings = mail_server_settings
22
24
  ActionMailer::Base.perform_deliveries = true
23
-
24
- if mail_method.preferred_secure_connection_type == 'TLS'
25
- mail_server_settings[:enable_starttls_auto] = true
26
- end
27
25
  else
28
26
  #logger.warn "NOTICE: Mail not enabled"
29
27
  ActionMailer::Base.perform_deliveries = false
@@ -6,7 +6,7 @@ module Spree::PreferenceAccess
6
6
  key = key.to_s if key.is_a?(Symbol)
7
7
  return nil unless config = self.instance
8
8
  # preferences will be cached under the name of the class including this module (ex. Spree::Config)
9
- prefs = Rails.cache.fetch(self.to_s) { config.preferences }
9
+ prefs = Rails.cache.fetch("configuration_#{config.id}".to_sym) { config.preferences }
10
10
  return prefs if key.nil?
11
11
  prefs[key]
12
12
  end
@@ -18,10 +18,10 @@ module Spree::PreferenceAccess
18
18
  config.set_preference(key, value)
19
19
  end
20
20
  config.save
21
- Rails.cache.delete(self.to_s) { config.preferences }
21
+ Rails.cache.delete("configuration_#{config.id}".to_sym)
22
22
  end
23
23
 
24
24
  alias_method :[], :get
25
25
  end
26
26
  end
27
- end
27
+ end
data/lib/spree_base.rb ADDED
@@ -0,0 +1,116 @@
1
+ module SpreeBase
2
+ module InstanceMethods
3
+ def access_forbidden
4
+ render :text => 'Access Forbidden', :layout => true, :status => 401
5
+ end
6
+
7
+ # can be used in views as well as controllers.
8
+ # e.g. <% title = 'This is a custom title for this view' %>
9
+ def title=(title)
10
+ @title = title
11
+ end
12
+
13
+ def title
14
+ title_string = @title.blank? ? accurate_title : @title
15
+ if title_string.blank?
16
+ default_title
17
+ else
18
+ if Spree::Config[:always_put_site_name_in_title]
19
+ [default_title, title_string].join(' - ')
20
+ else
21
+ title_string
22
+ end
23
+ end
24
+ end
25
+
26
+ protected
27
+
28
+ def default_title
29
+ Spree::Config[:site_name]
30
+ end
31
+
32
+ def accurate_title
33
+ return nil
34
+ end
35
+
36
+ # def reject_unknown_object
37
+ # # workaround to catch problems with loading errors for permalink ids (reconsider RC permalink hack elsewhere?)
38
+ # begin
39
+ # load_object
40
+ # rescue Exception => e
41
+ # @object = nil
42
+ # end
43
+ # the_object = instance_variable_get "@#{object_name}"
44
+ # the_object = nil if (the_object.respond_to?(:deleted?) && the_object.deleted?)
45
+ # unless params[:id].blank? || the_object
46
+ # if self.respond_to? :object_missing
47
+ # self.object_missing(params[:id])
48
+ # else
49
+ # render_404(Exception.new("missing object in #{self.class.to_s}"))
50
+ # end
51
+ # end
52
+ # true
53
+ # end
54
+
55
+ def render_404(exception=nil)
56
+ respond_to do |type|
57
+ type.html { render :status => :not_found, :file => "#{Rails.root}/public/404.html", :layout=>nil}
58
+ type.all { render :status => :not_found, :nothing => true }
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def redirect_back_or_default(default)
65
+ redirect_to(session["user_return_to"] || default)
66
+ session["user_return_to"] = nil
67
+ end
68
+
69
+ def instantiate_controller_and_action_names
70
+ @current_action = action_name
71
+ @current_controller = controller_name
72
+ end
73
+
74
+ def get_taxonomies
75
+ @taxonomies ||= Taxonomy.includes(:root => :children)
76
+ @taxonomies.reject { |t| t.root.nil? }
77
+ end
78
+
79
+ def current_gateway
80
+ @current_gateway ||= Gateway.current
81
+ end
82
+
83
+ #RAILS 3 TODO
84
+ # # Load all models using STI to fix associations such as @order.credits giving no results and resulting in incorrect order totals
85
+ # def touch_sti_subclasses
86
+ # if Rails.env == 'development'
87
+ # load(File.join(SPREE_ROOT,'config/initializers/touch.rb'))
88
+ # end
89
+ # end
90
+
91
+ def set_user_language
92
+ locale = session[:locale] || Spree::Config[:default_locale]
93
+ locale = I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
94
+ I18n.locale = locale.to_sym
95
+ end
96
+ end
97
+
98
+ def self.included(receiver)
99
+ #receiver.extend ClassMethods
100
+ receiver.send :include, InstanceMethods
101
+ receiver.send :layout, 'spree_application'
102
+ receiver.send :helper, 'hook'
103
+ receiver.send :before_filter, 'instantiate_controller_and_action_names'
104
+ # #RAILS 3 TODO
105
+ # #before_filter :touch_sti_subclasses
106
+ receiver.send :before_filter, 'set_user_language'
107
+
108
+ receiver.send :helper_method, 'title'
109
+ receiver.send :helper_method, 'title='
110
+ receiver.send :helper_method, 'get_taxonomies'
111
+ receiver.send :helper_method, 'current_gateway'
112
+ receiver.send :helper_method, 'current_order'
113
+ receiver.send :include, SslRequirement
114
+ receiver.send :include, Spree::CurrentOrder
115
+ end
116
+ end