spree_core 0.60.0.RC1 → 0.60.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.
Files changed (48) hide show
  1. data/app/controllers/admin/line_items_controller.rb +12 -13
  2. data/app/controllers/admin/orders_controller.rb +11 -3
  3. data/app/controllers/admin/payment_methods_controller.rb +3 -3
  4. data/app/controllers/admin/payments_controller.rb +12 -5
  5. data/app/controllers/admin/product_groups_controller.rb +1 -1
  6. data/app/controllers/admin/product_scopes_controller.rb +12 -8
  7. data/app/controllers/admin/products_controller.rb +7 -7
  8. data/app/controllers/admin/properties_controller.rb +3 -1
  9. data/app/controllers/admin/prototypes_controller.rb +4 -2
  10. data/app/controllers/admin/reports_controller.rb +5 -1
  11. data/app/controllers/admin/resource_controller.rb +40 -31
  12. data/app/controllers/admin/return_authorizations_controller.rb +1 -1
  13. data/app/controllers/admin/shipments_controller.rb +7 -8
  14. data/app/controllers/admin/states_controller.rb +3 -3
  15. data/app/controllers/admin/taxonomies_controller.rb +5 -2
  16. data/app/controllers/admin/taxons_controller.rb +39 -18
  17. data/app/controllers/admin/users_controller.rb +5 -5
  18. data/app/controllers/admin/variants_controller.rb +4 -4
  19. data/app/controllers/admin/zones_controller.rb +3 -2
  20. data/app/controllers/checkout_controller.rb +6 -5
  21. data/app/controllers/content_controller.rb +8 -2
  22. data/app/controllers/orders_controller.rb +8 -5
  23. data/app/controllers/products_controller.rb +9 -5
  24. data/app/controllers/spree/base_controller.rb +1 -0
  25. data/app/controllers/taxons_controller.rb +5 -1
  26. data/app/helpers/admin/taxons_helper.rb +14 -1
  27. data/app/helpers/spree/base_helper.rb +2 -1
  28. data/app/models/app_configuration.rb +1 -0
  29. data/app/models/creditcard.rb +1 -1
  30. data/app/views/admin/orders/history.html.erb +1 -1
  31. data/app/views/admin/reports/index.html.erb +3 -3
  32. data/app/views/admin/taxons/available.js.erb +2 -2
  33. data/app/views/admin/taxons/selected.html.erb +1 -0
  34. data/app/views/orders/show.html.erb +10 -12
  35. data/app/views/products/show.html.erb +1 -1
  36. data/app/views/taxons/show.html.erb +1 -1
  37. data/config/locales/en.yml +1 -3
  38. data/config/routes.rb +1 -0
  39. data/lib/product_filters.rb +2 -2
  40. data/lib/spree_base.rb +1 -0
  41. data/lib/spree_core.rb +6 -0
  42. data/lib/spree_core/ext/hash.rb +75 -0
  43. data/lib/spree_core/spree_custom_responder.rb +29 -0
  44. data/lib/spree_core/spree_respond_with.rb +57 -0
  45. data/lib/spree_core/version.rb +1 -1
  46. data/public/javascripts/taxonomy.js +8 -4
  47. data/public/stylesheets/admin/admin-reset.css +2 -0
  48. metadata +20 -22
@@ -55,7 +55,8 @@ module Spree::BaseHelper
55
55
  end
56
56
 
57
57
  def meta_data_tags
58
- return unless self.respond_to?(:object) && object
58
+ object = instance_variable_get('@'+controller_name.singularize)
59
+ return unless object
59
60
  "".tap do |tags|
60
61
  if object.respond_to?(:meta_keywords) and object.meta_keywords.present?
61
62
  tags << tag('meta', :name => 'keywords', :content => object.meta_keywords) + "\n"
@@ -34,6 +34,7 @@ class AppConfiguration < Configuration
34
34
  preference :cache_static_content, :boolean, :default => true
35
35
  preference :use_content_controller, :boolean, :default => true
36
36
  preference :allow_checkout_on_gateway_error, :boolean, :default => false
37
+ preference :select_taxons_from_tree, :boolean, :default => false # provide opportunity to select taxons from tree instead of search with autocomplete
37
38
 
38
39
  validates :name, :presence => true, :uniqueness => true
39
40
 
@@ -96,7 +96,7 @@ class Creditcard < ActiveRecord::Base
96
96
  gateway_error(response) unless response.success?
97
97
  end
98
98
  rescue ActiveMerchant::ConnectionError
99
- gateway_error t(:unable_to_connect_to_gateway)
99
+ gateway_error I18n.t(:unable_to_connect_to_gateway)
100
100
  end
101
101
 
102
102
  def capture(payment)
@@ -21,7 +21,7 @@
21
21
  <% end %>
22
22
  <% if @order.state_events.empty? %>
23
23
  <tr>
24
- <td colspan="3"><%= t("none_available") %></td>
24
+ <td colspan="5"><%= t("none_available") %></td>
25
25
  </tr>
26
26
  <% end %>
27
27
  </table>
@@ -7,11 +7,11 @@
7
7
  <th><%= t("description") %></th>
8
8
  </tr>
9
9
  </thead>
10
- <tbody>
10
+ <tbody>
11
11
  <% @reports.each do |key, value| %>
12
12
  <tr>
13
- <td><%= link_to t(value[:name].downcase.gsub(" ","_")), send("#{key}_admin_reports_url".to_sym) %></td>
14
- <td><%= t(value[:description].downcase.gsub(" ","_")) %></td>
13
+ <td><%= link_to value[:name], send("#{key}_admin_reports_url".to_sym) %></td>
14
+ <td><%= value[:description] %></td>
15
15
  </tr>
16
16
  <% end %>
17
17
  </tbody>
@@ -15,7 +15,7 @@
15
15
  </tr>
16
16
  </thead>
17
17
  <tbody>
18
- <% @available_taxons.each do |taxon| %>
18
+ <% @taxons.each do |taxon| %>
19
19
  <tr id="<%= dom_id(taxon, :sel) %>">
20
20
  <td><%= taxon.name %></td>
21
21
  <td><%= taxon_path taxon %></td>
@@ -26,7 +26,7 @@
26
26
  </td>
27
27
  </tr>
28
28
  <% end %>
29
- <% if @available_taxons.empty? %>
29
+ <% if @taxons.empty? %>
30
30
  <tr><td colspan="3"><%= t('no_match_found') %>.</td></tr>
31
31
  <% end %>
32
32
  </tbody>
@@ -15,6 +15,7 @@
15
15
  function search_for_taxons(){
16
16
  jQuery.ajax({
17
17
  data: {q: jQuery("#searchtext").val() },
18
+ dataType: 'script',
18
19
  success: function(request){
19
20
  jQuery('#search_hits').html(request);
20
21
  },
@@ -1,16 +1,14 @@
1
- <div id="order">
2
- <%= link_to t('back_to_store'), products_path %>
1
+ <h1><%= accurate_title %></h1>
3
2
 
3
+ <div id="order">
4
4
  <% if params.has_key? :checkout_complete %>
5
- <br/><br/>
6
- <h3><%= t('thank_you_for_your_order') %></h3>
7
- <% else %>
8
- | <%= link_to t('my_account'), account_path if current_user%>
5
+ <h3><%= t('thank_you_for_your_order') %></h3>
9
6
  <% end %>
10
- <br/><br/>
11
-
12
7
  <%= render :partial => 'shared/order_details', :locals => {:order => @order} %>
13
-
14
- <br/>
15
- <%= link_to t('back_to_store'), products_path %>
16
- </div>
8
+ <p>
9
+ <%= link_to t('back_to_store'), root_path %>
10
+ <% unless params.has_key? :checkout_complete %>
11
+ | <%= link_to t('my_account'), account_path if current_user%>
12
+ <% end %>
13
+ </p>
14
+ </div>
@@ -1,5 +1,5 @@
1
1
  <% @body_id = 'product-details' %>
2
- <h1><%= @product.name %></h1>
2
+ <h1><%= accurate_title %></h1>
3
3
 
4
4
  <div id="product-images">
5
5
  <%= hook :product_images do %>
@@ -1,4 +1,4 @@
1
- <h1><%= @taxon.name %></h1>
1
+ <h1><%= accurate_title %></h1>
2
2
 
3
3
  <% content_for :sidebar do %>
4
4
  <%= hook :taxon_sidebar_navigation do %>
@@ -822,9 +822,7 @@ en:
822
822
  roles: Roles
823
823
  sales_tax: "Sales Tax"
824
824
  sales_total: "Sales Total"
825
- sales_total_for_all_orders: "Sales total for all orders"
826
- sales_totals: "Sales Totals"
827
- sales_totals_description: "Sales Total For All Orders"
825
+ sales_total_description: "Sales Total For All Orders"
828
826
  save_and_continue: Save and Continue
829
827
  save_preferences: Save Preferences
830
828
  scope: Scope
@@ -101,6 +101,7 @@ Rails.application.routes.draw do
101
101
  end
102
102
  collection do
103
103
  post :available
104
+ post :batch_select
104
105
  get :selected
105
106
  end
106
107
  end
@@ -88,7 +88,7 @@ module ProductFilters
88
88
  }
89
89
 
90
90
  def ProductFilters.brand_filter
91
- brands = ProductProperty.find_all_by_property_id(@@brand_property).map(&:value).compact.uniq
91
+ brands = ProductProperty.where(:property_id => @@brand_property).map(&:value).compact.uniq
92
92
  conds = Hash[*brands.map {|b| [b, "product_properties.value = '#{b}'"]}.flatten]
93
93
  { :name => "Brands",
94
94
  :scope => :brand_any,
@@ -125,7 +125,7 @@ module ProductFilters
125
125
  if taxon.nil?
126
126
  taxon = Taxonomy.first.root
127
127
  end
128
- all_brands = ProductProperty.find_all_by_property_id(@@brand_property).map(&:value).uniq
128
+ all_brands = ProductProperty.where(:property_id => @@brand_property).map(&:value).uniq
129
129
  scope = ProductProperty.scoped(:conditions => ["property_id = ?", @@brand_property]).
130
130
  scoped(:joins => {:product => :taxons},
131
131
  :conditions => ["taxons.id in (?)", [taxon] + taxon.descendants])
@@ -106,6 +106,7 @@ module SpreeBase
106
106
 
107
107
  receiver.send :helper_method, 'title'
108
108
  receiver.send :helper_method, 'title='
109
+ receiver.send :helper_method, 'accurate_title'
109
110
  receiver.send :helper_method, 'get_taxonomies'
110
111
  receiver.send :helper_method, 'current_gateway'
111
112
  receiver.send :helper_method, 'current_order'
@@ -41,12 +41,18 @@ require "meta_search"
41
41
  require "find_by_param"
42
42
 
43
43
  require 'spree_core/ext/active_record'
44
+ require 'spree_core/ext/hash'
44
45
 
45
46
  require 'spree_core/delegate_belongs_to'
46
47
  ActiveRecord::Base.send :include, DelegateBelongsTo
47
48
 
48
49
  require 'spree_core/theme_support'
49
50
  require 'spree_core/enumerable_constants'
51
+
52
+ require 'spree_core/spree_custom_responder'
53
+ require 'spree_core/spree_respond_with'
54
+
55
+
50
56
  require 'spree_core/ssl_requirement'
51
57
  require 'spree_core/preferences/model_hooks'
52
58
  require 'spree_core/preferences/preference_definition'
@@ -0,0 +1,75 @@
1
+ #
2
+ # = Hash Recursive Merge
3
+ #
4
+ # Merges a Ruby Hash recursively, Also known as deep merge.
5
+ # Recursive version of Hash#merge and Hash#merge!.
6
+ #
7
+ # Category:: Ruby
8
+ # Package:: Hash
9
+ # Author:: Simone Carletti <weppos@weppos.net>
10
+ # Copyright:: 2007-2008 The Authors
11
+ # License:: MIT License
12
+ # Link:: http://www.simonecarletti.com/
13
+ # Source:: http://gist.github.com/gists/6391/
14
+ #
15
+ module HashRecursiveMerge
16
+
17
+ #
18
+ # Recursive version of Hash#merge!
19
+ #
20
+ # Adds the contents of +other_hash+ to +hsh+,
21
+ # merging entries in +hsh+ with duplicate keys with those from +other_hash+.
22
+ #
23
+ # Compared with Hash#merge!, this method supports nested hashes.
24
+ # When both +hsh+ and +other_hash+ contains an entry with the same key,
25
+ # it merges and returns the values from both arrays.
26
+ #
27
+ # h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
28
+ # h2 = {"b" => 254, "c" => 300, "c" => {"c1" => 16, "c3" => 94}}
29
+ # h1.rmerge!(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
30
+ #
31
+ # Simply using Hash#merge! would return
32
+ #
33
+ # h1.merge!(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
34
+ #
35
+ def rmerge!(other_hash)
36
+ merge!(other_hash) do |key, oldval, newval|
37
+ oldval.class == self.class ? oldval.rmerge!(newval) : newval
38
+ end
39
+ end
40
+
41
+ #
42
+ # Recursive version of Hash#merge
43
+ #
44
+ # Compared with Hash#merge!, this method supports nested hashes.
45
+ # When both +hsh+ and +other_hash+ contains an entry with the same key,
46
+ # it merges and returns the values from both arrays.
47
+ #
48
+ # Compared with Hash#merge, this method provides a different approch
49
+ # for merging nasted hashes.
50
+ # If the value of a given key is an Hash and both +other_hash+ abd +hsh
51
+ # includes the same key, the value is merged instead replaced with
52
+ # +other_hash+ value.
53
+ #
54
+ # h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
55
+ # h2 = {"b" => 254, "c" => 300, "c" => {"c1" => 16, "c3" => 94}}
56
+ # h1.rmerge(h2) #=> {"a" => 100, "b" => 254, "c" => {"c1" => 16, "c2" => 14, "c3" => 94}}
57
+ #
58
+ # Simply using Hash#merge would return
59
+ #
60
+ # h1.merge(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
61
+ #
62
+ def rmerge(other_hash)
63
+ r = {}
64
+ merge(other_hash) do |key, oldval, newval|
65
+ r[key] = oldval.class == self.class ? oldval.rmerge(newval) : newval
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+
72
+ class Hash
73
+ include HashRecursiveMerge
74
+ end
75
+
@@ -0,0 +1,29 @@
1
+ module Spree
2
+ class Responder < ::ActionController::Responder #:nodoc:
3
+
4
+ attr_accessor :on_success, :on_failure
5
+
6
+ def initialize(controller, resources, options={})
7
+ super
8
+
9
+ class_name = controller.class.name.to_sym
10
+ action_name = options.delete(:action_name)
11
+
12
+ if result = Spree::BaseController.spree_responders[class_name].try(:[],action_name).try(:[], self.format.to_sym)
13
+ self.on_success = (result.respond_to?(:call) ? result : result[:success])
14
+ self.on_failure = (result.respond_to?(:call) ? result : result[:failure])
15
+ end
16
+ end
17
+
18
+ def to_html
19
+ super and return if !(on_success || on_failure)
20
+ has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success)
21
+ end
22
+
23
+ def to_format
24
+ super and return if !(on_success || on_failure)
25
+ has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ module ActionController
2
+ class Base
3
+ def respond_with(*resources, &block)
4
+ raise "In order to use respond_with, first you need to declare the formats your " <<
5
+ "controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
6
+
7
+ if response = retrieve_response_from_mimes(&block)
8
+ options = resources.size == 1 ? {} : resources.extract_options!
9
+ options.merge!(:default_response => response)
10
+
11
+ # following statement is not present in rails code. The action name is needed for processing
12
+ options.merge!(:action_name => action_name.to_sym)
13
+
14
+ # if responder is not specified then pass in Spree::Responder
15
+ (options.delete(:responder) || Spree::Responder).call(self, resources, options)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+
22
+ module SpreeRespondWith
23
+ extend ActiveSupport::Concern
24
+
25
+ included do
26
+ cattr_accessor :spree_responders
27
+ self.spree_responders = {}
28
+ end
29
+
30
+ module ClassMethods
31
+ def respond_override(options={})
32
+
33
+ unless options.blank?
34
+ action_name = options.keys.first
35
+ action_value = options.values.first
36
+
37
+ if action_name.blank? || action_value.blank?
38
+ raise ArgumentError, "invalid values supplied #{options.inspect}"
39
+ end
40
+
41
+ format_name = action_value.keys.first
42
+ format_value = action_value.values.first
43
+
44
+ if format_name.blank? || format_value.blank?
45
+ raise ArgumentError, "invalid values supplied #{options.inspect}"
46
+ end
47
+
48
+ if format_value.is_a?(Proc)
49
+ options = {action_name.to_sym => {format_name.to_sym => {:success => format_value}}}
50
+ end
51
+
52
+ self.spree_responders.rmerge!(self.name.intern => options)
53
+ end
54
+ end
55
+ end
56
+
57
+ end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "0.60.0.RC1"
3
+ "0.60.0"
4
4
  end
5
5
  end
@@ -17,7 +17,8 @@ var handle_move = function(e, data) {
17
17
 
18
18
  jQuery.ajax({
19
19
  type: "POST",
20
- url: base_url + node.attr("id") + ".json",
20
+ dataType: "json",
21
+ url: base_url + node.attr("id"),
21
22
  data: ({_method: "put", "taxon[parent_id]": new_parent.attr("id"), "taxon[position]": position, authenticity_token: AUTH_TOKEN}),
22
23
  error: handle_ajax_error
23
24
  });
@@ -34,11 +35,12 @@ var handle_create = function(e, data) {
34
35
 
35
36
  jQuery.ajax({
36
37
  type: "POST",
38
+ dataType: "json",
37
39
  url: base_url,
38
40
  data: ({"taxon[name]": name, "taxon[parent_id]": new_parent.attr("id"), "taxon[position]": position, authenticity_token: AUTH_TOKEN}),
39
41
  error: handle_ajax_error,
40
- success: function(id,result) {
41
- node.attr('id', id);
42
+ success: function(data,result) {
43
+ node.attr('id', data.taxon.id);
42
44
  }
43
45
  });
44
46
 
@@ -51,7 +53,8 @@ var handle_rename = function(e, data) {
51
53
 
52
54
  jQuery.ajax({
53
55
  type: "POST",
54
- url: base_url + node.attr("id") + ".json",
56
+ dataType: "json",
57
+ url: base_url + node.attr("id"),
55
58
  data: ({_method: "put", "taxon[name]": name, authenticity_token: AUTH_TOKEN}),
56
59
  error: handle_ajax_error
57
60
  });
@@ -65,6 +68,7 @@ var handle_delete = function(e, data){
65
68
  if(r){
66
69
  jQuery.ajax({
67
70
  type: "POST",
71
+ dataType: "json",
68
72
  url: base_url + node.attr("id"),
69
73
  data: ({_method: "delete", authenticity_token: AUTH_TOKEN}),
70
74
  error: handle_ajax_error
@@ -65,3 +65,5 @@ table {
65
65
 
66
66
  a img { border: none }
67
67
 
68
+ #taxons-tree li { list-style-type: none; }
69
+
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11094359
5
- prerelease: 7
4
+ hash: 239
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 60
9
9
  - 0
10
- - RC
11
- - 1
12
- version: 0.60.0.RC1
10
+ version: 0.60.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Sean Schofield
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2011-05-03 00:00:00 -04:00
18
+ date: 2011-05-13 00:00:00 -04:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -186,12 +184,12 @@ dependencies:
186
184
  requirements:
187
185
  - - "="
188
186
  - !ruby/object:Gem::Version
189
- hash: 21
187
+ hash: 29
190
188
  segments:
191
189
  - 1
192
190
  - 0
193
- - 1
194
- version: 1.0.1
191
+ - 5
192
+ version: 1.0.5
195
193
  type: :runtime
196
194
  version_requirements: *id011
197
195
  - !ruby/object:Gem::Dependency
@@ -202,12 +200,12 @@ dependencies:
202
200
  requirements:
203
201
  - - "="
204
202
  - !ruby/object:Gem::Version
205
- hash: 39
203
+ hash: 47
206
204
  segments:
207
205
  - 1
208
- - 12
206
+ - 14
209
207
  - 0
210
- version: 1.12.0
208
+ version: 1.14.0
211
209
  type: :runtime
212
210
  version_requirements: *id012
213
211
  - !ruby/object:Gem::Dependency
@@ -218,12 +216,11 @@ dependencies:
218
216
  requirements:
219
217
  - - "="
220
218
  - !ruby/object:Gem::Version
221
- hash: 1923831917
219
+ hash: -1876988247
222
220
  segments:
223
221
  - 3
224
222
  - 0
225
- - pre
226
- - 2
223
+ - pre2
227
224
  version: 3.0.pre2
228
225
  type: :runtime
229
226
  version_requirements: *id013
@@ -676,10 +673,13 @@ files:
676
673
  - lib/spree_core/enumerable_constants.rb
677
674
  - lib/spree_core/ext/active_record.rb
678
675
  - lib/spree_core/ext/array.rb
676
+ - lib/spree_core/ext/hash.rb
679
677
  - lib/spree_core/ext/string.rb
680
678
  - lib/spree_core/preferences/model_hooks.rb
681
679
  - lib/spree_core/preferences/preference_definition.rb
682
680
  - lib/spree_core/railtie.rb
681
+ - lib/spree_core/spree_custom_responder.rb
682
+ - lib/spree_core/spree_respond_with.rb
683
683
  - lib/spree_core/ssl_requirement.rb
684
684
  - lib/spree_core/testing_support/factories/address_factory.rb
685
685
  - lib/spree_core/testing_support/factories/adjustment_factory.rb
@@ -1133,18 +1133,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
1133
1133
  required_rubygems_version: !ruby/object:Gem::Requirement
1134
1134
  none: false
1135
1135
  requirements:
1136
- - - ">"
1136
+ - - ">="
1137
1137
  - !ruby/object:Gem::Version
1138
- hash: 25
1138
+ hash: 3
1139
1139
  segments:
1140
- - 1
1141
- - 3
1142
- - 1
1143
- version: 1.3.1
1140
+ - 0
1141
+ version: "0"
1144
1142
  requirements:
1145
1143
  - none
1146
1144
  rubyforge_project: spree_core
1147
- rubygems_version: 1.4.2
1145
+ rubygems_version: 1.3.7
1148
1146
  signing_key:
1149
1147
  specification_version: 3
1150
1148
  summary: Core e-commerce functionality for the Spree project.