spree_core 1.0.7 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/admin/admin.js.erb +9 -18
- data/app/assets/javascripts/admin/calculator.js +7 -6
- data/app/assets/javascripts/admin/checkouts/edit.js +2 -2
- data/app/assets/javascripts/admin/image_settings.js +49 -0
- data/app/assets/javascripts/admin/orders/edit_form.js +14 -14
- data/app/assets/stylesheets/admin/admin.css.erb +36 -54
- data/app/assets/stylesheets/store/screen.css.scss +25 -12
- data/app/controllers/spree/admin/base_controller.rb +3 -3
- data/app/controllers/spree/admin/image_settings_controller.rb +71 -0
- data/app/controllers/spree/admin/images_controller.rb +22 -21
- data/app/controllers/spree/admin/mail_methods_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
- data/app/controllers/spree/admin/orders_controller.rb +13 -13
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -1
- data/app/controllers/spree/admin/payments_controller.rb +1 -1
- data/app/controllers/spree/admin/product_properties_controller.rb +3 -4
- data/app/controllers/spree/admin/products_controller.rb +49 -47
- data/app/controllers/spree/admin/properties_controller.rb +1 -1
- data/app/controllers/spree/admin/prototypes_controller.rb +12 -6
- data/app/controllers/spree/admin/reports_controller.rb +15 -16
- data/app/controllers/spree/admin/resource_controller.rb +1 -1
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/shipments_controller.rb +0 -3
- data/app/controllers/spree/admin/states_controller.rb +9 -9
- data/app/controllers/spree/admin/users_controller.rb +18 -42
- data/app/controllers/spree/admin/variants_controller.rb +22 -21
- data/app/controllers/spree/admin/zones_controller.rb +11 -11
- data/app/controllers/spree/content_controller.rb +1 -1
- data/app/controllers/spree/locale_controller.rb +2 -2
- data/app/controllers/spree/orders_controller.rb +4 -6
- data/app/controllers/spree/products_controller.rb +1 -1
- data/app/controllers/spree/states_controller.rb +4 -7
- data/app/helpers/spree/admin/base_helper.rb +4 -0
- data/app/helpers/spree/admin/navigation_helper.rb +4 -16
- data/app/helpers/spree/base_helper.rb +22 -3
- data/app/models/spree/activator.rb +4 -1
- data/app/models/spree/address.rb +45 -45
- data/app/models/spree/adjustment.rb +4 -4
- data/app/models/spree/app_configuration.rb +12 -0
- data/app/models/spree/calculator/default_tax.rb +1 -3
- data/app/models/spree/calculator/flat_percent_item_total.rb +0 -2
- data/app/models/spree/calculator/flat_rate.rb +0 -3
- data/app/models/spree/calculator/flexi_rate.rb +1 -3
- data/app/models/spree/calculator/per_item.rb +1 -6
- data/app/models/spree/calculator/price_sack.rb +0 -2
- data/app/models/spree/country.rb +1 -1
- data/app/models/spree/creditcard.rb +9 -10
- data/app/models/spree/gateway.rb +0 -2
- data/app/models/spree/image.rb +18 -2
- data/app/models/spree/inventory_unit.rb +4 -2
- data/app/models/spree/mail_method.rb +1 -6
- data/app/models/spree/option_type.rb +3 -1
- data/app/models/spree/order.rb +68 -62
- data/app/models/spree/payment.rb +1 -1
- data/app/models/spree/payment_method.rb +0 -6
- data/app/models/spree/product/scopes.rb +44 -44
- data/app/models/spree/product.rb +44 -26
- data/app/models/spree/product_property.rb +0 -2
- data/app/models/spree/property.rb +0 -16
- data/app/models/spree/prototype.rb +0 -1
- data/app/models/spree/return_authorization.rb +0 -2
- data/app/models/spree/shipment.rb +2 -3
- data/app/models/spree/shipping_category.rb +0 -2
- data/app/models/spree/shipping_method.rb +1 -2
- data/app/models/spree/shipping_rate.rb +9 -0
- data/app/models/spree/state.rb +10 -2
- data/app/models/spree/{state_event.rb → state_change.rb} +1 -4
- data/app/models/spree/tax_rate.rb +3 -3
- data/app/models/spree/taxon.rb +1 -6
- data/app/models/spree/taxonomy.rb +3 -6
- data/app/models/spree/user.rb +1 -0
- data/app/models/spree/variant.rb +3 -4
- data/app/models/spree/zone.rb +0 -10
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +1 -1
- data/app/views/spree/admin/configurations/index.html.erb +4 -0
- data/app/views/spree/admin/image_settings/edit.html.erb +91 -0
- data/app/views/spree/admin/image_settings/show.html.erb +11 -0
- data/app/views/spree/admin/images/index.html.erb +3 -3
- data/app/views/spree/admin/mail_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/mail_methods/index.html.erb +1 -1
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
- data/app/views/spree/admin/option_types/index.html.erb +1 -1
- data/app/views/spree/admin/option_types/new.js.erb +1 -1
- data/app/views/spree/admin/orders/_form.html.erb +3 -5
- data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
- data/app/views/spree/admin/orders/history.html.erb +2 -2
- data/app/views/spree/admin/orders/index.html.erb +19 -19
- data/app/views/spree/admin/payment_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/payment_methods/index.html.erb +1 -3
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +30 -27
- data/app/views/spree/admin/products/index.html.erb +9 -9
- data/app/views/spree/admin/products/new.html.erb +28 -4
- data/app/views/spree/admin/products/new.js.erb +1 -1
- data/app/views/spree/admin/properties/index.html.erb +1 -1
- data/app/views/spree/admin/properties/new.js.erb +1 -1
- data/app/views/spree/admin/prototypes/index.html.erb +1 -1
- data/app/views/spree/admin/prototypes/new.js.erb +1 -1
- data/app/views/spree/admin/prototypes/show.html.erb +42 -0
- data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_calculator_fields.html.erb +2 -2
- data/app/views/spree/admin/shared/_head.html.erb +3 -3
- data/app/views/spree/admin/shared/_order_details.html.erb +1 -1
- data/app/views/spree/admin/shared/_order_tabs.html.erb +6 -6
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +0 -1
- data/app/views/spree/admin/shared/_report_criteria.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +1 -1
- data/app/views/spree/admin/shared/_update_order_state.js +5 -4
- data/app/views/spree/admin/shipments/index.html.erb +1 -1
- data/app/views/spree/admin/shipping_categories/index.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/index.html.erb +1 -1
- data/app/views/spree/admin/states/_state_list.html.erb +1 -1
- data/app/views/spree/admin/states/new.js.erb +1 -1
- data/app/views/spree/admin/tax_categories/index.html.erb +2 -2
- data/app/views/spree/admin/tax_rates/index.html.erb +2 -2
- data/app/views/spree/admin/taxonomies/_list.html.erb +1 -1
- data/app/views/spree/admin/trackers/_form.html.erb +1 -1
- data/app/views/spree/admin/trackers/index.html.erb +1 -1
- data/app/views/spree/admin/users/_form.html.erb +1 -16
- data/app/views/spree/admin/users/index.html.erb +3 -4
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/app/views/spree/admin/variants/new.js.erb +1 -1
- data/app/views/spree/admin/zones/index.html.erb +1 -1
- data/app/views/spree/checkout/_address.html.erb +1 -1
- data/app/views/spree/checkout/edit.html.erb +1 -1
- data/app/views/spree/checkout/registration.html.erb +2 -2
- data/app/views/spree/order_mailer/confirm_email.text.erb +3 -3
- data/app/views/spree/orders/show.html.erb +2 -2
- data/app/views/spree/products/_cart_form.html.erb +1 -2
- data/app/views/spree/products/_image.html.erb +1 -1
- data/app/views/spree/products/show.html.erb +3 -3
- data/app/views/spree/shared/_filters.html.erb +26 -24
- data/app/views/spree/shared/_google_analytics.html.erb +26 -26
- data/app/views/spree/shared/_products.html.erb +2 -2
- data/app/views/spree/shared/_search.html.erb +1 -1
- data/app/views/spree/shared/_store_menu.html.erb +1 -1
- data/app/views/spree/states/index.js.erb +1 -1
- data/config/initializers/rails_3_1.rb +3 -3
- data/config/locales/en.yml +40 -35
- data/config/routes.rb +5 -13
- data/db/migrate/20101026184714_migrate_transactions_to_payment_state.rb +4 -4
- data/db/migrate/20111007143030_namespace_top_level_models.rb +0 -3
- data/db/migrate/20120203001428_rename_state_events_to_state_changes.rb +9 -0
- data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +35 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +48 -20
- data/lib/generators/spree/install/install_generator.rb +17 -1
- data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
- data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
- data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
- data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
- data/lib/generators/spree/sandbox/sandbox_generator.rb +9 -2
- data/lib/spree/core/calculated_adjustments.rb +29 -34
- data/lib/spree/core/controller_helpers.rb +36 -34
- data/lib/spree/core/custom_fixtures.rb +1 -1
- data/lib/spree/core/delegate_belongs_to.rb +22 -24
- data/lib/spree/core/engine.rb +3 -3
- data/lib/spree/core/environment_extension.rb +12 -15
- data/lib/spree/core/mail_settings.rb +1 -1
- data/lib/spree/core/permalinks.rb +24 -16
- data/lib/spree/core/preference_rescue.rb +1 -1
- data/lib/spree/core/respond_with.rb +13 -8
- data/lib/spree/core/responder.rb +1 -2
- data/lib/spree/core/search/base.rb +36 -19
- data/lib/spree/core/ssl_requirement.rb +18 -10
- data/lib/spree/core/testing_support/common_rake.rb +1 -1
- data/lib/spree/core/testing_support/factories/product_factory.rb +9 -9
- data/lib/spree/core/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/shipping_method_factory.rb +3 -3
- data/lib/spree/core/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/zone_factory.rb +4 -2
- data/lib/spree/core/validators/email.rb +23 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +2 -2
- data/lib/spree/product_filters.rb +10 -19
- data/lib/tasks/core.rake +1 -1
- data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css.erb +5 -5
- data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +1 -1
- metadata +68 -140
- data/app/assets/images/noimage/large.png +0 -0
- data/app/controllers/spree/admin/product_groups_controller.rb +0 -49
- data/app/controllers/spree/admin/product_scopes_controller.rb +0 -39
- data/app/helpers/spree/admin/product_groups_helper.rb +0 -14
- data/app/helpers/spree/admin/product_properties_helper.rb +0 -24
- data/app/models/spree/product_group.rb +0 -200
- data/app/models/spree/product_scope.rb +0 -79
- data/app/views/spree/admin/banners/_gateway.html.erb +0 -14
- data/app/views/spree/admin/product_groups/_preview.html.erb +0 -33
- data/app/views/spree/admin/product_groups/_product_scope.html.erb +0 -24
- data/app/views/spree/admin/product_groups/edit.html.erb +0 -59
- data/app/views/spree/admin/product_groups/index.html.erb +0 -37
- data/app/views/spree/admin/product_groups/new.html.erb +0 -12
- data/app/views/spree/admin/product_groups/show.html.erb +0 -32
- data/app/views/spree/admin/product_scopes/create.js.erb +0 -6
- data/app/views/spree/admin/product_scopes/destroy.js.erb +0 -3
- data/app/views/spree/admin/product_scopes/new.html.erb +0 -1
- data/app/views/spree/admin/shared/_group_from_products_form.html.erb +0 -12
- data/db/migrate/20091012120519_product_groups_and_scopes.rb +0 -18
- data/db/migrate/20100126103714_create_products_product_groups.rb +0 -8
- data/db/migrate/20100306153445_fix_by_popularity.rb +0 -9
- data/db/migrate/20120523061241_convert_sales_tax_to_default_tax.rb +0 -9
- data/lib/spree/core/testing_support/factories/product_group_factory.rb +0 -5
- data/lib/spree/core/testing_support/factories/product_scope_factory.rb +0 -7
- data/lib/spree/core/theme_support/hook_listener.rb +0 -145
- data/lib/spree/core/theme_support.rb +0 -1
- data/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css +0 -57
@@ -1,26 +1,54 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% case ENV['DB']
|
2
|
+
when 'sqlite' %>
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: "db/spree_development.sqlite3"
|
6
|
+
test:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: "db/spree_test.sqlite3"
|
9
|
+
production:
|
10
|
+
adapter: sqlite3
|
11
|
+
database: "db/spree_production.sqlite3"
|
12
|
+
<% when 'mysql' %>
|
13
|
+
development:
|
14
|
+
adapter: mysql2
|
15
|
+
database: spree_development
|
16
|
+
username:
|
17
|
+
encoding: utf8
|
18
|
+
test:
|
19
|
+
adapter: mysql2
|
20
|
+
database: spree_test
|
21
|
+
username:
|
22
|
+
encoding: utf8
|
23
|
+
production:
|
3
24
|
adapter: mysql2
|
25
|
+
database: spree_production
|
26
|
+
username:
|
4
27
|
encoding: utf8
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
28
|
+
<% when 'postgres' %>
|
29
|
+
development:
|
30
|
+
adapter: postgresql
|
31
|
+
database: spree_test
|
32
|
+
username: postgres
|
33
|
+
min_messages: warning
|
34
|
+
test:
|
35
|
+
adapter: postgresql
|
36
|
+
database: spree_test
|
37
|
+
username: postgres
|
38
|
+
min_messages: warning
|
39
|
+
production:
|
40
|
+
adapter: postgresql
|
41
|
+
database: spree_production
|
42
|
+
username: postgres
|
43
|
+
min_messages: warning
|
10
44
|
<% else %>
|
11
|
-
adapter: sqlite3
|
12
|
-
pool: 5
|
13
|
-
timeout: 5000
|
14
|
-
<% end %>
|
15
|
-
|
16
45
|
development:
|
17
|
-
|
18
|
-
database: db/
|
19
|
-
|
46
|
+
adapter: sqlite3
|
47
|
+
database: "db/spree_development.sqlite3"
|
20
48
|
test:
|
21
|
-
|
22
|
-
database: db/
|
23
|
-
|
49
|
+
adapter: sqlite3
|
50
|
+
database: "db/spree_test.sqlite3"
|
24
51
|
production:
|
25
|
-
|
26
|
-
database: db/
|
52
|
+
adapter: sqlite3
|
53
|
+
database: "db/spree_production.sqlite3"
|
54
|
+
<% end %>
|
@@ -114,6 +114,15 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
def create_database
|
118
|
+
say_status :creating, "database"
|
119
|
+
silence_stream(STDOUT) do
|
120
|
+
silence_stream(STDERR) do
|
121
|
+
silence_warnings { rake 'db:create' }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
117
126
|
def run_migrations
|
118
127
|
if @run_migrations
|
119
128
|
say_status :running, "migrations"
|
@@ -153,7 +162,14 @@ Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
153
162
|
|
154
163
|
def notify_about_routes
|
155
164
|
insert_into_file File.join('config', 'routes.rb'), :after => "Application.routes.draw do\n" do
|
156
|
-
|
165
|
+
%Q{
|
166
|
+
# This line mounts Spree's routes at the root of your application.
|
167
|
+
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
|
168
|
+
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
169
|
+
#
|
170
|
+
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
|
171
|
+
mount Spree::Core::Engine, :at => '/'
|
172
|
+
}
|
157
173
|
end
|
158
174
|
|
159
175
|
unless options[:quiet]
|
@@ -4,14 +4,21 @@ module Spree
|
|
4
4
|
class SandboxGenerator < Spree::DummyGenerator
|
5
5
|
desc "Creates blank Rails application, installs Spree and all sample data"
|
6
6
|
|
7
|
-
class_option :database, :default => ''
|
8
|
-
|
9
7
|
def self.source_paths
|
10
8
|
paths = self.superclass.source_paths
|
11
9
|
paths.unshift File.expand_path('../templates', __FILE__)
|
12
10
|
paths.flatten
|
13
11
|
end
|
14
12
|
|
13
|
+
def drop_database
|
14
|
+
say "dropping database"
|
15
|
+
inside dummy_path do
|
16
|
+
quietly do
|
17
|
+
rake 'db:drop -f sandbox/Rakefile'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
protected
|
16
23
|
def dummy_path
|
17
24
|
'sandbox'
|
@@ -5,51 +5,46 @@ module Spree
|
|
5
5
|
def calculated_adjustments
|
6
6
|
has_one :calculator, :as => :calculable, :dependent => :destroy
|
7
7
|
accepts_nested_attributes_for :calculator
|
8
|
-
attr_accessible :calculator_attributes
|
8
|
+
attr_accessible :calculator_type, :calculator_attributes
|
9
9
|
validates :calculator, :presence => true
|
10
10
|
|
11
11
|
def self.calculators
|
12
12
|
Rails.application.config.spree.calculators.send(self.to_s.tableize.gsub('/', '_').sub('spree_', ''))
|
13
13
|
end
|
14
|
-
|
15
|
-
include InstanceMethods
|
16
14
|
end
|
17
15
|
end
|
16
|
+
|
17
|
+
def calculator_type
|
18
|
+
calculator.class.to_s if calculator
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def calculator_type=(calculator_type)
|
25
|
-
clazz = calculator_type.constantize if calculator_type
|
26
|
-
self.calculator = clazz.new if clazz and not self.calculator.is_a? clazz
|
27
|
-
end
|
28
|
-
|
29
|
-
# Creates a new adjustment for the target object (which is any class that has_many :adjustments) and
|
30
|
-
# sets amount based on the calculator as applied to the calculable argument (Order, LineItems[], Shipment, etc.)
|
31
|
-
# By default the adjustment will not be considered mandatory
|
32
|
-
def create_adjustment(label, target, calculable, mandatory=false)
|
33
|
-
amount = compute_amount(calculable)
|
34
|
-
return if amount == 0 && !mandatory
|
35
|
-
target.adjustments.create({:amount => amount,
|
36
|
-
:source => calculable,
|
37
|
-
:originator => self,
|
38
|
-
:label => label,
|
39
|
-
:mandatory => mandatory}, :without_protection => true)
|
40
|
-
end
|
21
|
+
def calculator_type=(calculator_type)
|
22
|
+
clazz = calculator_type.constantize if calculator_type
|
23
|
+
self.calculator = clazz.new if clazz and not self.calculator.is_a? clazz
|
24
|
+
end
|
41
25
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
# Creates a new adjustment for the target object (which is any class that has_many :adjustments) and
|
27
|
+
# sets amount based on the calculator as applied to the calculable argument (Order, LineItems[], Shipment, etc.)
|
28
|
+
# By default the adjustment will not be considered mandatory
|
29
|
+
def create_adjustment(label, target, calculable, mandatory=false)
|
30
|
+
amount = compute_amount(calculable)
|
31
|
+
return if amount == 0 && !mandatory
|
32
|
+
target.adjustments.create({ :amount => amount,
|
33
|
+
:source => calculable,
|
34
|
+
:originator => self,
|
35
|
+
:label => label,
|
36
|
+
:mandatory => mandatory}, :without_protection => true)
|
37
|
+
end
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
# Updates the amount of the adjustment using our Calculator and calling the +compute+ method with the +calculable+
|
40
|
+
# referenced passed to the method.
|
41
|
+
def update_adjustment(adjustment, calculable)
|
42
|
+
adjustment.update_attribute_without_callbacks(:amount, compute_amount(calculable))
|
43
|
+
end
|
52
44
|
|
45
|
+
# Calculate the amount to be used when creating an adjustment
|
46
|
+
def compute_amount(calculable)
|
47
|
+
self.calculator.compute(calculable)
|
53
48
|
end
|
54
49
|
|
55
50
|
def self.included(receiver)
|
@@ -2,8 +2,7 @@ module Spree
|
|
2
2
|
module Core
|
3
3
|
module ControllerHelpers
|
4
4
|
def self.included(receiver)
|
5
|
-
receiver.send :
|
6
|
-
receiver.send :layout, '/spree/layouts/spree_application'
|
5
|
+
receiver.send :layout, :get_layout
|
7
6
|
receiver.send :helper, 'spree/hook'
|
8
7
|
receiver.send :before_filter, 'instantiate_controller_and_action_names'
|
9
8
|
receiver.send :before_filter, 'set_user_language'
|
@@ -12,35 +11,33 @@ module Spree
|
|
12
11
|
receiver.send :helper_method, 'title='
|
13
12
|
receiver.send :helper_method, 'accurate_title'
|
14
13
|
receiver.send :helper_method, 'get_taxonomies'
|
15
|
-
receiver.send :helper_method, 'current_gateway'
|
16
14
|
receiver.send :helper_method, 'current_order'
|
17
15
|
receiver.send :include, SslRequirement
|
18
16
|
receiver.send :include, Spree::Core::CurrentOrder
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def access_forbidden
|
20
|
+
render :text => 'Access Forbidden', :layout => true, :status => 401
|
21
|
+
end
|
22
|
+
|
23
|
+
# can be used in views as well as controllers.
|
24
|
+
# e.g. <% title = 'This is a custom title for this view' %>
|
25
|
+
attr_writer :title
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
title_string = @title.present? ? @title : accurate_title
|
32
|
-
if title_string.present?
|
33
|
-
if Spree::Config[:always_put_site_name_in_title]
|
34
|
-
[default_title, title_string].join(' - ')
|
35
|
-
else
|
36
|
-
title_string
|
37
|
-
end
|
27
|
+
def title
|
28
|
+
title_string = @title.present? ? @title : accurate_title
|
29
|
+
if title_string.present?
|
30
|
+
if Spree::Config[:always_put_site_name_in_title]
|
31
|
+
[default_title, title_string].join(' - ')
|
38
32
|
else
|
39
|
-
|
33
|
+
title_string
|
40
34
|
end
|
35
|
+
else
|
36
|
+
default_title
|
41
37
|
end
|
38
|
+
end
|
42
39
|
|
43
|
-
|
40
|
+
protected
|
44
41
|
|
45
42
|
def default_title
|
46
43
|
Spree::Config[:site_name]
|
@@ -53,7 +50,7 @@ module Spree
|
|
53
50
|
|
54
51
|
def render_404(exception = nil)
|
55
52
|
respond_to do |type|
|
56
|
-
type.html { render :status => :not_found, :file => "#{::Rails.root}/public/404
|
53
|
+
type.html { render :status => :not_found, :file => "#{::Rails.root}/public/404", :formats => [:html], :layout => nil}
|
57
54
|
type.all { render :status => :not_found, :nothing => true }
|
58
55
|
end
|
59
56
|
end
|
@@ -67,11 +64,10 @@ module Spree
|
|
67
64
|
# add additional keys as appropriate. Override this method if you need additional data when
|
68
65
|
# responding to a notification
|
69
66
|
def default_notification_payload
|
70
|
-
{
|
71
|
-
:order => current_order(true) }
|
67
|
+
{:user => (respond_to?(:current_user) && current_user), :order => current_order}
|
72
68
|
end
|
73
69
|
|
74
|
-
|
70
|
+
private
|
75
71
|
|
76
72
|
def redirect_back_or_default(default)
|
77
73
|
redirect_to(session["user_return_to"] || default)
|
@@ -87,11 +83,6 @@ module Spree
|
|
87
83
|
@taxonomies ||= Taxonomy.includes(:root => :children).joins(:root)
|
88
84
|
end
|
89
85
|
|
90
|
-
def current_gateway
|
91
|
-
ActiveSupport::Deprecation.warn "current_gateway is deprecated and will be removed in Spree > 1.0"
|
92
|
-
@current_gateway ||= Gateway.current
|
93
|
-
end
|
94
|
-
|
95
86
|
def associate_user
|
96
87
|
return unless current_user and current_order
|
97
88
|
current_order.associate_user!(current_user)
|
@@ -99,11 +90,22 @@ module Spree
|
|
99
90
|
end
|
100
91
|
|
101
92
|
def set_user_language
|
102
|
-
locale = session[:locale]
|
103
|
-
locale
|
104
|
-
|
93
|
+
locale = session[:locale]
|
94
|
+
locale ||= Spree::Config[:default_locale] unless Spree::Config[:default_locale].blank?
|
95
|
+
locale ||= Rails.application.config.i18n.default_locale
|
96
|
+
locale ||= I18n.default_locale unless I18n.available_locales.include?(locale.to_sym)
|
97
|
+
I18n.locale = locale.to_sym
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns which layout to render.
|
101
|
+
#
|
102
|
+
# You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
|
103
|
+
#
|
104
|
+
# Default layout is: +app/views/spree/layouts/spree_application+
|
105
|
+
#
|
106
|
+
def get_layout
|
107
|
+
layout ||= Spree::Config[:layout]
|
105
108
|
end
|
106
|
-
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
@@ -52,39 +52,37 @@ module DelegateBelongsTo
|
|
52
52
|
|
53
53
|
protected
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
def get_association_column_names(association, without_default_rejected_delegate_columns=true)
|
56
|
+
begin
|
57
|
+
association_klass = reflect_on_association(association).klass
|
58
|
+
methods = association_klass.column_names
|
59
|
+
methods.reject!{|x|default_rejected_delegate_columns.include?(x.to_s)} if without_default_rejected_delegate_columns
|
60
|
+
return methods
|
61
|
+
rescue
|
62
|
+
return []
|
63
|
+
end
|
63
64
|
end
|
64
|
-
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
##
|
67
|
+
# initialize_association :belongs_to, :contact
|
68
|
+
def initialize_association(type, association, opts={})
|
69
|
+
raise 'Illegal or unimplemented association type.' unless [:belongs_to].include?(type.to_s.to_sym)
|
70
|
+
send type, association, opts if reflect_on_association(association).nil?
|
71
|
+
end
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
def class_def(name, method=nil, &blk)
|
76
|
+
class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
|
77
|
+
end
|
78
78
|
|
79
79
|
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
send("#{association}=", self.class.reflect_on_association(association).klass.new) if send(association).nil?
|
85
|
-
send(association)
|
86
|
-
end
|
81
|
+
def delegator_for(association)
|
82
|
+
send("#{association}=", self.class.reflect_on_association(association).klass.new) if send(association).nil?
|
83
|
+
send(association)
|
87
84
|
end
|
85
|
+
protected :delegator_for
|
88
86
|
|
89
87
|
end
|
90
88
|
|
data/lib/spree/core/engine.rb
CHANGED
@@ -25,11 +25,11 @@ module Spree
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
-
# We need to reload the routes here due to how Spree sets them up
|
29
|
-
# The different facets of Spree
|
28
|
+
# We need to reload the routes here due to how Spree sets them up.
|
29
|
+
# The different facets of Spree (auth, promo, etc.) append/prepend routes to Core
|
30
30
|
# *after* Core has been loaded.
|
31
31
|
#
|
32
|
-
# So we wait until after initialization is complete to do one final reload
|
32
|
+
# So we wait until after initialization is complete to do one final reload.
|
33
33
|
# This then makes the appended/prepended routes available to the application.
|
34
34
|
config.after_initialize do
|
35
35
|
Rails.application.routes_reloader.reload!
|
@@ -3,26 +3,23 @@ module Spree
|
|
3
3
|
module EnvironmentExtension
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
|
6
|
+
def add_class(name)
|
7
|
+
self.instance_variable_set "@#{name}", Set.new
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
instance_variable_set( "@" + name, val)
|
12
|
-
}
|
9
|
+
create_method( "#{name}=".to_sym ) { |val|
|
10
|
+
instance_variable_set( "@" + name, val)
|
11
|
+
}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
}
|
13
|
+
create_method(name.to_sym) do
|
14
|
+
instance_variable_get( "@" + name )
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
def create_method( name, &block )
|
22
|
-
self.class.send( :define_method, name, &block )
|
23
|
-
end
|
18
|
+
private
|
24
19
|
|
25
|
-
|
20
|
+
def create_method(name, &block)
|
21
|
+
self.class.send(:define_method, name, &block)
|
22
|
+
end
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -6,6 +6,7 @@ module Spree
|
|
6
6
|
# This makes it possible to configure the mail settings
|
7
7
|
# through an admin interface instead of requiring changes to the Rails envrionment file.
|
8
8
|
def self.init
|
9
|
+
ActionMailer::Base.default_url_options[:host] = Spree::Config[:site_url]
|
9
10
|
return unless mail_method = Spree::MailMethod.current
|
10
11
|
if mail_method.prefers_enable_mail_delivery?
|
11
12
|
mail_server_settings = {
|
@@ -24,7 +25,6 @@ module Spree
|
|
24
25
|
|
25
26
|
ActionMailer::Base.smtp_settings = mail_server_settings
|
26
27
|
ActionMailer::Base.perform_deliveries = true
|
27
|
-
ActionMailer::Base.default_url_options[:host] = Spree::Config[:site_url]
|
28
28
|
else
|
29
29
|
#logger.warn "NOTICE: Mail not enabled"
|
30
30
|
ActionMailer::Base.perform_deliveries = false
|
@@ -11,10 +11,10 @@ module Spree
|
|
11
11
|
|
12
12
|
module ClassMethods
|
13
13
|
def make_permalink(options={})
|
14
|
-
options[:field] ||=
|
14
|
+
options[:field] ||= :permalink
|
15
15
|
self.permalink_options = options
|
16
16
|
|
17
|
-
|
17
|
+
validates permalink_options[:field], :uniqueness => true
|
18
18
|
|
19
19
|
if self.table_exists? && self.column_names.include?(permalink_options[:field].to_s)
|
20
20
|
before_validation(:on => :create) { save_permalink }
|
@@ -33,20 +33,29 @@ module Spree
|
|
33
33
|
permalink_options[:field]
|
34
34
|
end
|
35
35
|
|
36
|
+
def permalink_order
|
37
|
+
order = permalink_options[:order]
|
38
|
+
|
39
|
+
if order
|
40
|
+
"#{order} ASC,"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
36
44
|
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def save_permalink
|
47
|
+
permalink_value = self.to_param
|
48
|
+
field = self.class.permalink_field
|
49
|
+
order = self.class.permalink_order
|
50
|
+
# Do other links exist with this permalink?
|
51
|
+
other = self.class.first(
|
52
|
+
:conditions => "#{field} LIKE '#{permalink_value}%'",
|
53
|
+
:order => "#{order} LENGTH(#{field}) DESC, #{field} DESC"
|
54
|
+
)
|
55
|
+
if other
|
56
|
+
# Find existence of that permalink or the number of that permalink and add one.
|
57
|
+
if ( permalink_value == other.send(field) || /-(\d+)$/.match(other.send(field)) )
|
58
|
+
if $1
|
50
59
|
number = $1.to_i + 1
|
51
60
|
# Otherwise default to suffixing it with a 1.
|
52
61
|
else
|
@@ -55,9 +64,8 @@ module Spree
|
|
55
64
|
|
56
65
|
permalink_value += "-#{number.to_s}"
|
57
66
|
end
|
58
|
-
write_attribute(field, permalink_value)
|
59
67
|
end
|
60
|
-
|
68
|
+
write_attribute(field, permalink_value)
|
61
69
|
end
|
62
70
|
end
|
63
71
|
end
|
@@ -4,21 +4,26 @@ module ActionController
|
|
4
4
|
raise "In order to use respond_with, first you need to declare the formats your " <<
|
5
5
|
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
|
6
6
|
|
7
|
-
if
|
7
|
+
if collector = retrieve_collector_from_mimes(&block)
|
8
8
|
options = resources.size == 1 ? {} : resources.extract_options!
|
9
|
-
options.merge!(:default_response => response)
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
if defined_response = collector.response and Spree::BaseController.spree_responders.empty?
|
11
|
+
if action = options.delete(:action)
|
12
|
+
render :action => action
|
13
|
+
else
|
14
|
+
defined_response.call
|
15
|
+
end
|
16
|
+
else
|
17
|
+
# The action name is needed for processing
|
18
|
+
options.merge!(:action_name => action_name.to_sym)
|
19
|
+
# If responder is not specified then pass in Spree::Responder
|
20
|
+
(options.delete(:responder) || Spree::Responder).call(self, resources, options)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
|
-
|
22
27
|
module Spree
|
23
28
|
module Core
|
24
29
|
module RespondWith
|
data/lib/spree/core/responder.rb
CHANGED
@@ -9,8 +9,7 @@ module Spree
|
|
9
9
|
class_name = controller.class.name.to_sym
|
10
10
|
action_name = options.delete(:action_name)
|
11
11
|
|
12
|
-
if result = Spree::BaseController.spree_responders[class_name].try(:[],action_name).try(:[], self.format.to_sym)
|
13
|
-
|
12
|
+
if result = Spree::BaseController.spree_responders[class_name].try(:[], action_name).try(:[], self.format.to_sym)
|
14
13
|
self.on_success = handler(controller, result, :success)
|
15
14
|
self.on_failure = handler(controller, result, :failure)
|
16
15
|
end
|