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
@@ -46,7 +46,7 @@ module Spree
|
|
46
46
|
|
47
47
|
rescue Spree::Core::GatewayError => e
|
48
48
|
flash[:error] = "#{e.message}"
|
49
|
-
respond_with(@payment) { |format| format.html { redirect_to
|
49
|
+
respond_with(@payment) { |format| format.html { redirect_to new_admin_payment_path(@order) } }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -5,6 +5,7 @@ module Spree
|
|
5
5
|
|
6
6
|
before_filter :check_json_authenticity, :only => :index
|
7
7
|
before_filter :load_data, :except => :index
|
8
|
+
create.before :create_before
|
8
9
|
update.before :update_before
|
9
10
|
|
10
11
|
def show
|
@@ -48,67 +49,68 @@ module Spree
|
|
48
49
|
|
49
50
|
protected
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def find_resource
|
53
|
+
Product.find_by_permalink!(params[:id])
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
def location_after_save
|
57
|
+
edit_admin_product_url(@product)
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
# Allow different formats of json data to suit different ajax calls
|
61
|
+
def json_data
|
62
|
+
json_format = params[:json_format] or 'default'
|
63
|
+
case json_format
|
64
|
+
when 'basic'
|
65
|
+
collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json
|
66
|
+
else
|
67
|
+
collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},
|
68
|
+
:images => {:only => [:id], :methods => :mini_url}}},
|
69
|
+
:images => {:only => [:id], :methods => :mini_url}, :master => {}})
|
70
|
+
end
|
69
71
|
end
|
70
|
-
end
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
def load_data
|
74
|
+
@tax_categories = TaxCategory.order(:name)
|
75
|
+
@shipping_categories = ShippingCategory.order(:name)
|
76
|
+
end
|
76
77
|
|
77
|
-
|
78
|
-
|
78
|
+
def collection
|
79
|
+
return @collection if @collection.present?
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
if params[:search][:deleted_at_is_null].nil?
|
84
|
-
params[:search][:deleted_at_is_null] = "1"
|
85
|
-
end
|
81
|
+
unless request.xhr?
|
82
|
+
params[:q] ||= {}
|
83
|
+
params[:q][:deleted_at_null] ||= "1"
|
86
84
|
|
87
|
-
|
88
|
-
@search = super.metasearch(params[:search])
|
85
|
+
params[:q][:s] ||= "name asc"
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
@search = super.search(params[:q])
|
88
|
+
@collection = @search.result.group_by_products_id.includes([:master, {:variants => [:images, :option_values]}]).page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
89
|
+
else
|
90
|
+
includes = [{:variants => [:images, {:option_values => :option_type}]}, {:master => :images}]
|
93
91
|
|
94
|
-
|
95
|
-
|
92
|
+
@collection = super.where(["name #{LIKE} ?", "%#{params[:q]}%"])
|
93
|
+
@collection = @collection.includes(includes).limit(params[:limit] || 10)
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
tmp = super.where(["#{Variant.table_name}.sku #{LIKE} ?", "%#{params[:q]}%"])
|
96
|
+
tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
|
97
|
+
@collection.concat(tmp)
|
100
98
|
|
101
|
-
|
102
|
-
|
99
|
+
@collection
|
100
|
+
end
|
103
101
|
|
104
|
-
|
102
|
+
end
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
104
|
+
def create_before
|
105
|
+
return if params[:product][:prototype_id].blank?
|
106
|
+
@prototype = Spree::Prototype.find(params[:product][:prototype_id])
|
107
|
+
end
|
111
108
|
|
109
|
+
def update_before
|
110
|
+
# note: we only reset the product properties if we're receiving a post from the form on that tab
|
111
|
+
return unless params[:clear_product_properties]
|
112
|
+
params[:product] ||= {}
|
113
|
+
end
|
112
114
|
end
|
113
115
|
end
|
114
116
|
end
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
def filtered
|
7
7
|
@properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
|
8
8
|
respond_with(@properties) do |format|
|
9
|
-
format.html { render :template => "spree/admin/properties/filtered
|
9
|
+
format.html { render :template => "spree/admin/properties/filtered", :formats => [:html], :handlers => [:erb], :layout => false }
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -3,7 +3,13 @@ module Spree
|
|
3
3
|
class PrototypesController < ResourceController
|
4
4
|
after_filter :set_habtm_associations, :only => [:create, :update]
|
5
5
|
|
6
|
-
|
6
|
+
def show
|
7
|
+
if request.xhr?
|
8
|
+
render :layout => false
|
9
|
+
else
|
10
|
+
redirect_to admin_prototypes_path
|
11
|
+
end
|
12
|
+
end
|
7
13
|
|
8
14
|
def available
|
9
15
|
@prototypes = Prototype.order('name asc')
|
@@ -21,11 +27,11 @@ module Spree
|
|
21
27
|
end
|
22
28
|
|
23
29
|
private
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
|
31
|
+
def set_habtm_associations
|
32
|
+
@prototype.property_ids = params[:property][:id] if params[:property]
|
33
|
+
@prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -14,32 +14,31 @@ module Spree
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def sales_total
|
17
|
-
params[:
|
17
|
+
params[:q] = {} unless params[:q]
|
18
18
|
|
19
|
-
if params[:
|
20
|
-
params[:
|
19
|
+
if params[:q][:created_at_gt].blank?
|
20
|
+
params[:q][:created_at_gt] = Time.zone.now.beginning_of_month
|
21
21
|
else
|
22
|
-
params[:
|
22
|
+
params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue Time.zone.now.beginning_of_month
|
23
23
|
end
|
24
24
|
|
25
|
-
if params[:
|
26
|
-
params[:
|
27
|
-
Time.zone.parse(params[:search][:created_at_less_than]).end_of_day rescue ""
|
25
|
+
if params[:q] && !params[:q][:created_at_lt].blank?
|
26
|
+
params[:q][:created_at_lt] = Time.zone.parse(params[:q][:created_at_lt]).end_of_day rescue ""
|
28
27
|
end
|
29
28
|
|
30
|
-
if params[:
|
31
|
-
params[:
|
29
|
+
if params[:q].delete(:completed_at_not_null) == "1"
|
30
|
+
params[:q][:completed_at_not_null] = true
|
32
31
|
else
|
33
|
-
params[:
|
32
|
+
params[:q][:completed_at_not_null] = false
|
34
33
|
end
|
35
34
|
|
36
|
-
params[:
|
35
|
+
params[:q][:meta_sort] ||= "created_at.desc"
|
37
36
|
|
38
|
-
@search = Order.
|
39
|
-
@orders = @search
|
40
|
-
@item_total = @
|
41
|
-
@adjustment_total = @
|
42
|
-
@sales_total = @
|
37
|
+
@search = Order.complete.search(params[:q])
|
38
|
+
@orders = @search.result
|
39
|
+
@item_total = @orders.sum(:item_total)
|
40
|
+
@adjustment_total = @orders.sum(:adjustment_total)
|
41
|
+
@sales_total = @orders.sum(:total)
|
43
42
|
|
44
43
|
respond_with
|
45
44
|
end
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
|
15
15
|
protected
|
16
16
|
def associate_inventory_units
|
17
|
-
params[:return_quantity].each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }
|
17
|
+
(params[:return_quantity] || []).each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -14,9 +14,6 @@ module Spree
|
|
14
14
|
|
15
15
|
def new
|
16
16
|
build_shipment
|
17
|
-
@shipment.address ||= @order.ship_address
|
18
|
-
@shipment.address ||= Address.new(:country_id => Spree::Config[:default_country_id])
|
19
|
-
@shipment.shipping_method = @order.shipping_method
|
20
17
|
respond_with(@shipment)
|
21
18
|
end
|
22
19
|
|
@@ -13,17 +13,17 @@ module Spree
|
|
13
13
|
|
14
14
|
protected
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def location_after_save
|
17
|
+
admin_country_states_url(@country)
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
def collection
|
21
|
+
super.order(:name)
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def load_data
|
25
|
+
@countries = Country.order(:name)
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -4,11 +4,6 @@ module Spree
|
|
4
4
|
|
5
5
|
# http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
|
6
6
|
before_filter :check_json_authenticity, :only => :index
|
7
|
-
before_filter :load_roles, :only => [:edit, :new, :update, :create]
|
8
|
-
|
9
|
-
create.after :save_user_roles
|
10
|
-
update.before :save_user_roles
|
11
|
-
update.after :sign_in_if_change_own_password
|
12
7
|
|
13
8
|
def index
|
14
9
|
respond_with(@collection) do |format|
|
@@ -25,35 +20,25 @@ module Spree
|
|
25
20
|
end
|
26
21
|
|
27
22
|
protected
|
28
|
-
def collection
|
29
|
-
return @collection if @collection.present?
|
30
|
-
unless request.xhr?
|
31
|
-
@search = Spree::User.registered.metasearch(params[:search])
|
32
|
-
@collection = @search.relation.page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
33
|
-
else
|
34
|
-
#disabling proper nested include here due to rails 3.1 bug
|
35
|
-
#@collection = User.includes(:bill_address => [:state, :country], :ship_address => [:state, :country]).
|
36
|
-
@collection = Spree::User.includes(:bill_address, :ship_address).
|
37
|
-
where("spree_users.email #{LIKE} :search
|
38
|
-
OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
|
39
|
-
OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
|
40
|
-
OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)
|
41
|
-
OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)",
|
42
|
-
{ :search => "#{params[:q].strip}%" }).
|
43
|
-
limit(params[:limit] || 100)
|
44
|
-
end
|
45
|
-
end
|
46
23
|
|
47
|
-
def
|
48
|
-
return
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
24
|
+
def collection
|
25
|
+
return @collection if @collection.present?
|
26
|
+
unless request.xhr?
|
27
|
+
@search = Spree::User.registered.search(params[:q])
|
28
|
+
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
29
|
+
else
|
30
|
+
#disabling proper nested include here due to rails 3.1 bug
|
31
|
+
#@collection = User.includes(:bill_address => [:state, :country], :ship_address => [:state, :country]).
|
32
|
+
@collection = Spree::User.includes(:bill_address, :ship_address).
|
33
|
+
where("spree_users.email #{LIKE} :search
|
34
|
+
OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
|
35
|
+
OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.bill_address_id)
|
36
|
+
OR (spree_addresses.firstname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)
|
37
|
+
OR (spree_addresses.lastname #{LIKE} :search AND spree_addresses.id = spree_users.ship_address_id)",
|
38
|
+
{ :search => "#{params[:q].strip}%" }).
|
39
|
+
limit(params[:limit] || 100)
|
40
|
+
end
|
41
|
+
end
|
57
42
|
|
58
43
|
private
|
59
44
|
|
@@ -78,15 +63,6 @@ module Spree
|
|
78
63
|
end
|
79
64
|
end
|
80
65
|
|
81
|
-
def load_roles
|
82
|
-
@roles = Role.all
|
83
|
-
end
|
84
|
-
|
85
|
-
def sign_in_if_change_own_password
|
86
|
-
if current_user == @user && @user.password.present?
|
87
|
-
sign_in(@user, :event => :authentication, :bypass => true)
|
88
|
-
end
|
89
|
-
end
|
90
66
|
end
|
91
67
|
end
|
92
68
|
end
|
@@ -42,34 +42,35 @@ module Spree
|
|
42
42
|
end
|
43
43
|
|
44
44
|
protected
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
|
46
|
+
def create_before
|
47
|
+
option_values = params[:new_variant]
|
48
|
+
option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
|
49
|
+
@object.save
|
50
|
+
end
|
50
51
|
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def new_before
|
54
|
+
@object.attributes = @object.product.master.attributes.except('id', 'created_at', 'deleted_at',
|
55
|
+
'sku', 'is_master', 'count_on_hand')
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
def collection
|
59
|
+
@deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
if @deleted.blank?
|
62
|
+
@collection ||= super
|
63
|
+
else
|
64
|
+
@collection ||= Variant.where(:product_id => parent.id).deleted
|
65
|
+
end
|
66
|
+
@collection
|
64
67
|
end
|
65
|
-
@collection
|
66
|
-
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
def json_data
|
70
|
+
( parent.variants.presence || [parent.master] ).map do |v|
|
71
|
+
{ :label => v.options_text.presence || v.name, :id => v.id }
|
72
|
+
end
|
71
73
|
end
|
72
|
-
end
|
73
74
|
|
74
75
|
end
|
75
76
|
end
|
@@ -10,18 +10,18 @@ module Spree
|
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def collection
|
14
|
+
params[:q] ||= {}
|
15
|
+
params[:q][:meta_sort] ||= "ascend_by_name"
|
16
|
+
@search = super.search(params[:q])
|
17
|
+
@zones = @search.result.page(params[:page]).per(Spree::Config[:orders_per_page])
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def load_data
|
21
|
+
@countries = Country.order(:name)
|
22
|
+
@states = State.order(:name)
|
23
|
+
@zones = Zone.order(:name)
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -4,8 +4,8 @@ module Spree
|
|
4
4
|
if request.referer && request.referer.starts_with?('http://' + request.host)
|
5
5
|
session['user_return_to'] = request.referer
|
6
6
|
end
|
7
|
-
if params[:locale] && I18n.available_locales.
|
8
|
-
session[:locale] = I18n.locale = params[:locale]
|
7
|
+
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
|
8
|
+
session[:locale] = I18n.locale = params[:locale].to_sym
|
9
9
|
flash.notice = t(:locale_changed)
|
10
10
|
else
|
11
11
|
flash[:error] = t(:locale_not_changed)
|
@@ -13,7 +13,7 @@ module Spree
|
|
13
13
|
def update
|
14
14
|
@order = current_order
|
15
15
|
if @order.update_attributes(params[:order])
|
16
|
-
@order.line_items = @order.line_items.select {
|
16
|
+
@order.line_items = @order.line_items.select {|li| li.quantity > 0 }
|
17
17
|
fire_event('spree.order.contents_changed')
|
18
18
|
respond_with(@order) { |format| format.html { redirect_to cart_path } }
|
19
19
|
else
|
@@ -63,10 +63,8 @@ module Spree
|
|
63
63
|
redirect_to spree.cart_path
|
64
64
|
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@order && @order.completed? ? "#{Order.model_name.human} #{@order.number}" : t(:shopping_cart)
|
70
|
-
end
|
66
|
+
def accurate_titles
|
67
|
+
@order && @order.completed? ? "#{Order.model_name.human} #{@order.number}" : t(:shopping_cart)
|
68
|
+
end
|
71
69
|
end
|
72
70
|
end
|
@@ -13,7 +13,7 @@ module Spree
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def show
|
16
|
-
@product = Product.
|
16
|
+
@product = Product.find_by_permalink!(params[:id])
|
17
17
|
return unless @product
|
18
18
|
|
19
19
|
@variants = Variant.active.includes([:option_values, :images]).where(:product_id => @product.id)
|
@@ -2,15 +2,12 @@ module Spree
|
|
2
2
|
class StatesController < BaseController
|
3
3
|
ssl_allowed :index
|
4
4
|
|
5
|
+
respond_to :js
|
6
|
+
|
5
7
|
def index
|
6
|
-
# table of {country.id => [ state.id , state.name ]}, arrays sorted by name
|
7
|
-
# blank is added elsewhere, if needed
|
8
8
|
# we return ALL known information, since billing country isn't restricted
|
9
|
-
#
|
10
|
-
@state_info =
|
11
|
-
Spree::State.order('name ASC').each { |state|
|
12
|
-
@state_info[state.country_id.to_s].push [state.id, state.name]
|
13
|
-
}
|
9
|
+
# by shipping country
|
10
|
+
respond_with @state_info = Spree::State.states_group_by_country_id.to_json
|
14
11
|
end
|
15
12
|
end
|
16
13
|
end
|
@@ -198,6 +198,10 @@ module Spree
|
|
198
198
|
f.hidden_field(:_destroy) + link_to_with_icon(:delete, name, '#', :class => 'remove_fields')
|
199
199
|
end
|
200
200
|
|
201
|
+
def spree_dom_id(record)
|
202
|
+
dom_id(record, 'spree')
|
203
|
+
end
|
204
|
+
|
201
205
|
private
|
202
206
|
def attribute_name_for(field_name)
|
203
207
|
field_name.gsub(' ', '_').downcase
|
@@ -63,7 +63,7 @@ module Spree
|
|
63
63
|
options.reverse_merge! :caption => t(:are_you_sure)
|
64
64
|
options.reverse_merge! :title => t(:confirm_delete)
|
65
65
|
options.reverse_merge! :dataType => 'script'
|
66
|
-
options.reverse_merge! :success => "function(r){ $('##{
|
66
|
+
options.reverse_merge! :success => "function(r){ $('##{spree_dom_id resource}').fadeOut('hide'); }"
|
67
67
|
options.reverse_merge! :error => "function(jqXHR, textStatus, errorThrown){ show_flash_error(jqXHR.responseText); }"
|
68
68
|
options.reverse_merge! :name => icon('delete') + ' ' + t(:delete)
|
69
69
|
|
@@ -109,15 +109,15 @@ module Spree
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def button(text, icon_name = nil, button_type = 'submit', options={})
|
112
|
-
|
112
|
+
button_tag(content_tag('span', icon(icon_name) + ' ' + text), options.merge(:type => button_type))
|
113
113
|
end
|
114
114
|
|
115
115
|
def button_link_to(text, url, html_options = {})
|
116
116
|
if (html_options[:method] &&
|
117
117
|
html_options[:method].to_s.downcase != 'get' &&
|
118
118
|
!html_options[:remote])
|
119
|
-
form_tag(url, :method => html_options
|
120
|
-
button(text, html_options
|
119
|
+
form_tag(url, :method => html_options.delete(:method)) do
|
120
|
+
button(text, html_options.delete(:icon), nil, html_options)
|
121
121
|
end
|
122
122
|
else
|
123
123
|
if html_options['data-update'].nil? && html_options[:remote]
|
@@ -133,18 +133,6 @@ module Spree
|
|
133
133
|
link_to_function(text_for_button_link(text, html_options), function, html_options_for_button_link(html_options))
|
134
134
|
end
|
135
135
|
|
136
|
-
# RAILS 3 TODO - no longer needed
|
137
|
-
# def button_link_to_remote(text, url, html_options = {})
|
138
|
-
# html_options.reverse_merge! :remote => true
|
139
|
-
# link_to(text_for_button_link(text, html_options), url, html_options_for_button_link(html_options))
|
140
|
-
# end
|
141
|
-
#
|
142
|
-
# def link_to_remote(name, options = {}, html_options = {})
|
143
|
-
# options[:before] ||= "jQuery(this).parent().hide(); jQuery('#busy_indicator').show();"
|
144
|
-
# options[:complete] ||= "jQuery('#busy_indicator').hide()"
|
145
|
-
# link_to_function(name, remote_function(options), html_options || options.delete(:html))
|
146
|
-
# end
|
147
|
-
|
148
136
|
def text_for_button_link(text, html_options)
|
149
137
|
s = ''
|
150
138
|
if html_options[:icon]
|