spree_core 1.1.6 → 1.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/{creditcards → credit_cards}/amex_cid.gif +0 -0
- data/app/assets/images/{creditcards/creditcard.gif → credit_cards/credit_card.gif} +0 -0
- data/app/assets/images/{creditcards → credit_cards}/discover_cid.gif +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/american_express.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/cirrus.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/delta.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/dinersclub.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/directdebit.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/discover.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/egold.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/maestro.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/master.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/paypal.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/solo.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/switch.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/visa.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/visaelectron.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/westernunion.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/wirecard.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/icons/worldpay.png +0 -0
- data/app/assets/images/{creditcards → credit_cards}/master_cid.jpg +0 -0
- data/app/assets/images/{creditcards → credit_cards}/visa_cid.gif +0 -0
- data/app/assets/javascripts/admin/admin.js.erb +12 -136
- data/app/assets/javascripts/admin/checkouts/edit.js +18 -35
- data/app/assets/javascripts/admin/gateway.js +2 -2
- data/app/assets/javascripts/admin/images/index.js.coffee +12 -0
- data/app/assets/javascripts/admin/images/new.js.coffee +4 -0
- data/app/assets/javascripts/admin/orders/edit.js +1 -1
- data/app/assets/javascripts/admin/orders/edit_form.js +0 -2
- data/app/assets/javascripts/admin/product_autocomplete.js.erb +116 -0
- data/app/assets/javascripts/store/cart.js.coffee +7 -0
- data/app/assets/javascripts/store/checkout.js.coffee +57 -0
- data/app/assets/javascripts/store/product.js.coffee +36 -0
- data/app/assets/stylesheets/admin/admin.css.erb +5 -0
- data/app/assets/stylesheets/admin/spree_core.css +1 -0
- data/app/assets/stylesheets/store/screen.css.scss +15 -1
- data/app/assets/stylesheets/store/variables.css.scss +29 -29
- data/app/controllers/spree/admin/banners_controller.rb +14 -0
- data/app/controllers/spree/admin/base_controller.rb +11 -0
- data/app/controllers/spree/admin/images_controller.rb +13 -5
- data/app/controllers/spree/admin/line_items_controller.rb +16 -25
- data/app/controllers/spree/admin/mail_methods_controller.rb +1 -8
- data/app/controllers/spree/admin/option_types_controller.rb +0 -25
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -3
- data/app/controllers/spree/admin/orders_controller.rb +23 -14
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -7
- data/app/controllers/spree/admin/payments_controller.rb +5 -5
- data/app/controllers/spree/admin/products_controller.rb +15 -5
- data/app/controllers/spree/admin/prototypes_controller.rb +2 -2
- data/app/controllers/spree/admin/reports_controller.rb +1 -7
- data/app/controllers/spree/admin/resource_controller.rb +130 -130
- data/app/controllers/spree/admin/search_controller.rb +47 -0
- data/app/controllers/spree/admin/taxons_controller.rb +0 -43
- data/app/controllers/spree/base_controller.rb +2 -1
- data/app/controllers/spree/checkout_controller.rb +29 -10
- data/app/controllers/spree/orders_controller.rb +7 -11
- data/app/controllers/spree/products_controller.rb +5 -1
- data/app/helpers/spree/account_helper.rb +4 -0
- data/app/helpers/spree/admin/base_helper.rb +2 -44
- data/app/helpers/spree/admin/navigation_helper.rb +1 -3
- data/app/helpers/spree/admin/orders_helper.rb +3 -2
- data/app/helpers/spree/admin/products_helper.rb +21 -0
- data/app/helpers/spree/base_helper.rb +14 -11
- data/app/helpers/spree/checkout_helper.rb +5 -1
- data/app/helpers/spree/orders_helper.rb +5 -0
- data/app/helpers/spree/products_helper.rb +4 -0
- data/app/helpers/spree/trackers_helper.rb +4 -0
- data/app/models/spree/ability.rb +70 -0
- data/app/models/spree/address.rb +4 -12
- data/app/models/spree/adjustment.rb +30 -8
- data/app/models/spree/app_configuration.rb +1 -1
- data/app/models/spree/calculator/price_sack.rb +3 -5
- data/app/models/spree/country.rb +1 -4
- data/app/models/spree/{creditcard.rb → credit_card.rb} +4 -4
- data/app/models/spree/gateway.rb +2 -2
- data/app/models/spree/gateway/bogus.rb +10 -10
- data/app/models/spree/gateway/bogus_simple.rb +4 -4
- data/app/models/spree/image.rb +3 -12
- data/app/models/spree/inventory_unit.rb +4 -6
- data/app/models/spree/{user.rb → legacy_user.rb} +7 -6
- data/app/models/spree/line_item.rb +4 -5
- data/app/models/spree/option_type.rb +4 -6
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order.rb +90 -132
- data/app/models/spree/order/checkout.rb +124 -0
- data/app/models/spree/payment.rb +6 -6
- data/app/models/spree/payment/processing.rb +34 -38
- data/app/models/spree/payment_method.rb +2 -2
- data/app/models/spree/preference.rb +2 -0
- data/app/models/spree/preferences/preferable_class_methods.rb +0 -2
- data/app/models/spree/preferences/store.rb +3 -21
- data/app/models/spree/product.rb +41 -43
- data/app/models/spree/product/scopes.rb +9 -25
- data/app/models/spree/product_option_type.rb +2 -2
- data/app/models/spree/product_property.rb +9 -4
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/prototype.rb +2 -2
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/shipment.rb +6 -5
- data/app/models/spree/shipping_method.rb +19 -13
- data/app/models/spree/state.rb +2 -5
- data/app/models/spree/state_change.rb +1 -1
- data/app/models/spree/tax_rate.rb +8 -1
- data/app/models/spree/taxon.rb +5 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/tokenized_permission.rb +6 -0
- data/app/models/spree/tracker.rb +1 -1
- data/app/models/spree/variant.rb +13 -40
- data/app/models/spree/zone.rb +15 -14
- data/app/models/spree/zone_member.rb +1 -1
- data/app/views/spree/admin/image_settings/edit.html.erb +2 -2
- data/app/views/spree/admin/images/_form.html.erb +8 -4
- data/app/views/spree/admin/images/index.html.erb +1 -1
- data/app/views/spree/admin/line_items/create.js.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/orders/_add_product.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/index.html.erb +4 -4
- data/app/views/spree/admin/orders/show.html.erb +1 -1
- data/app/views/spree/admin/payments/_form.html.erb +1 -1
- data/app/views/spree/admin/payments/new.html.erb +0 -4
- data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +1 -1
- data/app/views/spree/admin/payments/source_views/_gateway.html.erb +2 -2
- data/app/views/spree/admin/products/_form.html.erb +21 -5
- data/app/views/spree/admin/products/index.html.erb +2 -2
- data/app/views/spree/admin/properties/_form.html.erb +1 -1
- data/app/views/spree/admin/properties/index.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +33 -17
- data/app/views/spree/admin/return_authorizations/edit.html.erb +2 -2
- data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +12 -2
- data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -4
- data/app/views/spree/admin/shared/_product_tabs.html.erb +0 -6
- data/app/views/spree/admin/shared/_show_resource_links.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
- data/app/views/spree/admin/shipments/edit.html.erb +2 -2
- data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/states/_state_list.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/index.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/_taxon_table.html.erb +2 -2
- data/app/views/spree/admin/variants/_form.html.erb +13 -13
- data/app/views/spree/admin/variants/index.html.erb +1 -7
- data/app/views/spree/checkout/_address.html.erb +10 -4
- data/app/views/spree/checkout/edit.html.erb +0 -1
- data/app/views/spree/checkout/payment/_gateway.html.erb +5 -5
- data/app/views/spree/checkout/registration.html.erb +2 -2
- data/app/views/spree/content/cvv.html.erb +6 -6
- data/app/views/spree/layouts/spree_application.html.erb +4 -48
- data/app/views/spree/order_mailer/cancel_email.text.erb +5 -5
- data/app/views/spree/order_mailer/confirm_email.text.erb +6 -7
- data/app/views/spree/orders/_adjustments.html.erb +14 -0
- data/app/views/spree/orders/_form.html.erb +1 -0
- data/app/views/spree/orders/show.html.erb +3 -3
- data/app/views/spree/products/_thumbnails.html.erb +1 -1
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/shared/_footer.html.erb +6 -0
- data/app/views/spree/shared/_google_analytics.html.erb +15 -16
- data/app/views/spree/shared/_head.html.erb +3 -9
- data/app/views/spree/shared/_header.html.erb +5 -0
- data/app/views/spree/shared/_main_nav_bar.html.erb +6 -0
- data/app/views/spree/shared/_nav_bar.html.erb +7 -3
- data/app/views/spree/shared/_order_details.html.erb +14 -11
- data/app/views/spree/shared/_sidebar.html.erb +3 -0
- data/app/views/spree/shared/unauthorized.html.erb +0 -0
- data/app/views/spree/shipment_mailer/shipped_email.text.erb +7 -7
- data/app/views/spree/taxons/show.html.erb +1 -1
- data/config/initializers/check_for_orphaned_preferences.rb +1 -1
- data/config/initializers/spree.rb +0 -12
- data/config/initializers/user_class_extensions.rb +25 -0
- data/config/initializers/workarounds_for_ruby19.rb +72 -0
- data/config/locales/en.yml +11 -24
- data/config/routes.rb +7 -37
- data/db/migrate/20090823005402_spree_zero_nine_zero.rb +14 -12
- data/db/migrate/20091015153048_add_openid_field_to_users.rb +9 -7
- data/db/migrate/20100209144531_polymorphic_payments.rb +5 -5
- data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +4 -4
- data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +3 -1
- data/db/migrate/20100811163637_add_guest_flag.rb +3 -1
- data/db/migrate/20100901171814_change_guest_flag_to_anonymous.rb +3 -1
- data/db/migrate/20101026184959_generate_anonymous_users.rb +3 -3
- data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +3 -1
- data/db/migrate/20111007143030_namespace_top_level_models.rb +18 -1
- data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +6 -4
- data/db/migrate/20120509055454_create_tokenized_permissions_table.rb +16 -0
- data/db/migrate/20120530012000_rename_creditcards_to_credit_cards.rb +11 -0
- data/db/migrate/20120604203654_remove_credit_total_from_orders.rb +5 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +53 -0
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +28 -0
- data/lib/generators/spree/custom_user/templates/initializer.rb.tt +1 -0
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +3 -0
- data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +1 -0
- 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/install/templates/config/initializers/spree.rb +2 -0
- data/lib/spree/core.rb +15 -2
- data/lib/spree/core/controller_helpers.rb +123 -62
- data/lib/spree/core/current_order.rb +5 -0
- data/lib/spree/core/engine.rb +1 -1
- data/lib/spree/core/mail_settings.rb +1 -2
- data/lib/spree/core/permalinks.rb +1 -5
- data/lib/spree/core/preference_rescue.rb +8 -4
- data/lib/spree/core/relation_serialization.rb +9 -0
- data/lib/spree/core/respond_with.rb +1 -1
- data/lib/spree/core/s3_support.rb +25 -0
- data/lib/spree/core/search/base.rb +2 -5
- data/lib/spree/core/ssl_requirement.rb +2 -2
- data/lib/spree/core/store_helpers.rb +1 -2
- data/lib/spree/core/testing_support/controller_requests.rb +1 -0
- data/lib/spree/core/testing_support/env.rb +2 -0
- data/lib/spree/core/testing_support/factories/{creditcard_factory.rb → credit_card_factory.rb} +3 -3
- data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/product_factory.rb +4 -4
- data/lib/spree/core/testing_support/factories/user_factory.rb +3 -3
- data/lib/spree/core/testing_support/factories/zone_factory.rb +2 -3
- data/lib/spree/core/token_resource.rb +27 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/product_filters.rb +12 -13
- data/lib/tasks/core.rake +1 -1
- metadata +146 -154
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/javascripts/admin/images/index.js +0 -10
- data/app/assets/javascripts/admin/images/new.js +0 -5
- data/app/assets/javascripts/admin/products.js +0 -2
- data/app/assets/javascripts/store/cart.js +0 -11
- data/app/assets/javascripts/store/checkout.js +0 -78
- data/app/assets/javascripts/store/product.js +0 -49
- data/app/controllers/spree/admin/users_controller.rb +0 -68
- data/app/views/spree/admin/option_types/_available.html.erb +0 -28
- data/app/views/spree/admin/option_types/_selected.html.erb +0 -26
- data/app/views/spree/admin/option_types/available.js.erb +0 -2
- data/app/views/spree/admin/option_types/select.js.erb +0 -3
- data/app/views/spree/admin/option_types/selected.html.erb +0 -6
- data/app/views/spree/admin/orders/history.html.erb +0 -29
- data/app/views/spree/admin/products/_option_types.html.erb +0 -40
- data/app/views/spree/admin/shared/_additional_field.html.erb +0 -5
- data/app/views/spree/admin/shared/_routes.html.erb +0 -8
- data/app/views/spree/admin/shared/_translations.html.erb +0 -17
- data/app/views/spree/admin/taxons/available.js.erb +0 -26
- data/app/views/spree/admin/taxons/remove.html.erb +0 -1
- data/app/views/spree/admin/taxons/select.js.erb +0 -2
- data/app/views/spree/admin/taxons/selected.html.erb +0 -42
- data/app/views/spree/admin/users/_form.html.erb +0 -19
- data/app/views/spree/admin/users/edit.html.erb +0 -14
- data/app/views/spree/admin/users/index.html.erb +0 -48
- data/app/views/spree/admin/users/new.html.erb +0 -14
- data/app/views/spree/admin/users/show.html.erb +0 -21
- data/app/views/spree/shared/_store_menu.html.erb +0 -2
- data/config/initializers/rails_5868.rb +0 -8
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +0 -10
- data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +0 -11
- data/db/sample/users.rb +0 -61
- data/lib/generators/spree/sandbox/sandbox_generator.rb +0 -36
- data/lib/generators/spree/sandbox/templates/rails/routes.rb +0 -7
- data/lib/spree/core/ext/array.rb +0 -14
- data/lib/spree/core/ext/hash.rb +0 -75
- data/lib/spree/core/ext/string.rb +0 -10
- data/lib/tasks/install.rake +0 -18
@@ -41,9 +41,9 @@ module Spree
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def load_order
|
45
|
+
@order = Order.find_by_number!(params[:order_id], :include => :adjustments)
|
46
|
+
end
|
47
47
|
|
48
48
|
end
|
49
49
|
end
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
require 'spree/core/gateway_error'
|
5
5
|
before_filter :initialize_txn_partials
|
6
6
|
before_filter :initialize_order_events
|
7
|
-
before_filter :load_order, :only => [:show, :edit, :update, :fire, :resend
|
7
|
+
before_filter :load_order, :only => [:show, :edit, :update, :fire, :resend]
|
8
8
|
|
9
9
|
respond_to :html
|
10
10
|
|
@@ -14,6 +14,12 @@ module Spree
|
|
14
14
|
@show_only_completed = params[:q][:completed_at_not_null].present?
|
15
15
|
params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc'
|
16
16
|
|
17
|
+
# As date params are deleted if @show_only_completed, store
|
18
|
+
# the original date so we can restore them into the params
|
19
|
+
# after the search
|
20
|
+
created_at_gt = params[:q][:created_at_gt]
|
21
|
+
created_at_lt = params[:q][:created_at_lt]
|
22
|
+
|
17
23
|
if !params[:q][:created_at_gt].blank?
|
18
24
|
params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue ""
|
19
25
|
end
|
@@ -29,6 +35,11 @@ module Spree
|
|
29
35
|
|
30
36
|
@search = Order.ransack(params[:q])
|
31
37
|
@orders = @search.result.includes([:user, :shipments, :payments]).page(params[:page]).per(Spree::Config[:orders_per_page])
|
38
|
+
|
39
|
+
# Restore dates
|
40
|
+
params[:q][:created_at_gt] = created_at_gt
|
41
|
+
params[:q][:created_at_lt] = created_at_lt
|
42
|
+
|
32
43
|
respond_with(@orders)
|
33
44
|
end
|
34
45
|
|
@@ -71,7 +82,6 @@ module Spree
|
|
71
82
|
end
|
72
83
|
end
|
73
84
|
|
74
|
-
|
75
85
|
def fire
|
76
86
|
# TODO - possible security check here but right now any admin can before any transition (and the state machine
|
77
87
|
# itself will make sure transitions are not applied in the wrong state)
|
@@ -96,20 +106,19 @@ module Spree
|
|
96
106
|
|
97
107
|
private
|
98
108
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
109
|
+
def load_order
|
110
|
+
@order = Order.find_by_number!(params[:id], :include => :adjustments) if params[:id]
|
111
|
+
end
|
103
112
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
113
|
+
# Allows extensions to add new forms of payment to provide their own display of transactions
|
114
|
+
def initialize_txn_partials
|
115
|
+
@txn_partials = []
|
116
|
+
end
|
108
117
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
118
|
+
# Used for extensions which need to provide their own custom event links on the order details view.
|
119
|
+
def initialize_order_events
|
120
|
+
@order_events = %w{cancel resume}
|
121
|
+
end
|
113
122
|
|
114
123
|
end
|
115
124
|
end
|
@@ -27,13 +27,7 @@ module Spree
|
|
27
27
|
end
|
28
28
|
|
29
29
|
payment_method_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
30
|
-
|
31
|
-
attributes.each do |k,v|
|
32
|
-
if k.include?("password") && attributes[k].blank?
|
33
|
-
attributes.delete(k)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
if @payment_method.update_attributes(attributes)
|
30
|
+
if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
|
37
31
|
invoke_callbacks(:update, :after)
|
38
32
|
flash.notice = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method))
|
39
33
|
respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
def create
|
22
22
|
@payment = @order.payments.build(object_params)
|
23
23
|
if @payment.payment_method.is_a?(Spree::Gateway) && @payment.payment_method.payment_profiles_supported? && params[:card].present? and params[:card] != 'new'
|
24
|
-
@payment.source =
|
24
|
+
@payment.source = CreditCard.find_by_id(params[:card])
|
25
25
|
end
|
26
26
|
|
27
27
|
begin
|
@@ -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_order_payment_path(@order) } }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -83,15 +83,15 @@ module Spree
|
|
83
83
|
else
|
84
84
|
@payment_method = @payment_methods.first
|
85
85
|
end
|
86
|
-
@previous_cards = @order.
|
86
|
+
@previous_cards = @order.credit_cards.with_payment_profile
|
87
87
|
end
|
88
88
|
|
89
89
|
def load_order
|
90
|
-
@order
|
90
|
+
@order = Order.find_by_number!(params[:order_id])
|
91
91
|
end
|
92
92
|
|
93
93
|
def load_payment
|
94
|
-
@payment
|
94
|
+
@payment = Payment.find(params[:id])
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -19,9 +19,13 @@ module Spree
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# override the destory method to set deleted_at value
|
23
|
+
# instead of actually deleting the product.
|
22
24
|
def destroy
|
23
|
-
@product = Product.
|
24
|
-
@product.
|
25
|
+
@product = Product.find_by_permalink!(params[:id])
|
26
|
+
@product.update_column(:deleted_at, Time.now)
|
27
|
+
|
28
|
+
@product.variants_including_master.update_all(:deleted_at => Time.now)
|
25
29
|
|
26
30
|
flash.notice = I18n.t('notice_messages.product_deleted')
|
27
31
|
|
@@ -67,6 +71,8 @@ module Spree
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def load_data
|
74
|
+
@taxons = Taxon.order(:name)
|
75
|
+
@option_types = OptionType.order(:name)
|
70
76
|
@tax_categories = TaxCategory.order(:name)
|
71
77
|
@shipping_categories = ShippingCategory.order(:name)
|
72
78
|
end
|
@@ -86,9 +92,13 @@ module Spree
|
|
86
92
|
includes([:master, {:variants => [:images, :option_values]}]).
|
87
93
|
page(params[:page]).
|
88
94
|
per(Spree::Config[:admin_products_per_page])
|
89
|
-
|
90
|
-
|
91
|
-
|
95
|
+
|
96
|
+
if params[:q][:s].include?("master_price")
|
97
|
+
# By applying the group in the main query we get an undefined method gsub for Arel::Nodes::Descending
|
98
|
+
# It seems to only work when the price is actually being sorted in the query
|
99
|
+
# To be investigated later.
|
100
|
+
@collection = @collection.group("spree_variants.price")
|
101
|
+
end
|
92
102
|
else
|
93
103
|
includes = [{:variants => [:images, {:option_values => :option_type}]}, {:master => :images}]
|
94
104
|
|
@@ -29,8 +29,8 @@ module Spree
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def set_habtm_associations
|
32
|
-
@prototype.property_ids = params[:
|
33
|
-
@prototype.option_type_ids = params[:option_type]
|
32
|
+
@prototype.property_ids = params[:property][:id] if params[:property]
|
33
|
+
@prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class ReportsController < Spree::Admin::BaseController
|
4
|
-
before_filter :load_data
|
5
4
|
respond_to :html
|
6
5
|
|
7
6
|
AVAILABLE_REPORTS = {
|
8
|
-
:sales_total => {:name => I18n.t(:sales_total), :description => I18n.t(:sales_total_description)}
|
7
|
+
:sales_total => { :name => I18n.t(:sales_total), :description => I18n.t(:sales_total_description) }
|
9
8
|
}
|
10
9
|
|
11
10
|
def index
|
@@ -43,11 +42,6 @@ module Spree
|
|
43
42
|
respond_with
|
44
43
|
end
|
45
44
|
|
46
|
-
private
|
47
|
-
def load_data
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
45
|
end
|
52
46
|
end
|
53
47
|
end
|
@@ -2,7 +2,7 @@ require 'spree/core/action_callbacks'
|
|
2
2
|
|
3
3
|
class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
4
4
|
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
|
5
|
-
|
5
|
+
before_filter :load_resource
|
6
6
|
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
|
7
7
|
|
8
8
|
respond_to :html
|
@@ -12,14 +12,14 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
12
12
|
invoke_callbacks(:new_action, :before)
|
13
13
|
respond_with(@object) do |format|
|
14
14
|
format.html { render :layout => !request.xhr? }
|
15
|
-
format.js
|
15
|
+
format.js { render :layout => false }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def edit
|
20
20
|
respond_with(@object) do |format|
|
21
21
|
format.html { render :layout => !request.xhr? }
|
22
|
-
format.js
|
22
|
+
format.js { render :layout => false }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -72,169 +72,169 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
72
72
|
|
73
73
|
protected
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
def resource_not_found
|
76
|
+
flash[:error] = flash_message_for(model_class.new, :not_found)
|
77
|
+
redirect_to collection_url
|
78
|
+
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
class << self
|
81
|
+
attr_accessor :parent_data
|
82
|
+
attr_accessor :callbacks
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
def belongs_to(model_name, options = {})
|
85
|
+
@parent_data ||= {}
|
86
|
+
@parent_data[:model_name] = model_name
|
87
|
+
@parent_data[:model_class] = model_name.to_s.classify.constantize
|
88
|
+
@parent_data[:find_by] = options[:find_by] || :id
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
def new_action
|
92
|
+
@callbacks ||= {}
|
93
|
+
@callbacks[:new_action] ||= Spree::ActionCallbacks.new
|
94
|
+
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
def create
|
97
|
+
@callbacks ||= {}
|
98
|
+
@callbacks[:create] ||= Spree::ActionCallbacks.new
|
99
|
+
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
def update
|
102
|
+
@callbacks ||= {}
|
103
|
+
@callbacks[:update] ||= Spree::ActionCallbacks.new
|
104
|
+
end
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
def destroy
|
107
|
+
@callbacks ||= {}
|
108
|
+
@callbacks[:destroy] ||= Spree::ActionCallbacks.new
|
109
|
+
end
|
109
110
|
end
|
110
|
-
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
def model_class
|
113
|
+
"Spree::#{controller_name.classify}".constantize
|
114
|
+
end
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
def model_name
|
117
|
+
parent_data[:model_name].gsub('spree/', '')
|
118
|
+
end
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
def object_name
|
121
|
+
controller_name.singularize
|
122
|
+
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
124
|
+
def load_resource
|
125
|
+
if member_action?
|
126
|
+
@object ||= load_resource_instance
|
127
|
+
instance_variable_set("@#{object_name}", @object)
|
128
|
+
else
|
129
|
+
@collection ||= collection
|
130
|
+
instance_variable_set("@#{controller_name}", @collection)
|
131
|
+
end
|
131
132
|
end
|
132
|
-
end
|
133
133
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
def load_resource_instance
|
135
|
+
if new_actions.include?(params[:action].to_sym)
|
136
|
+
build_resource
|
137
|
+
elsif params[:id]
|
138
|
+
find_resource
|
139
|
+
end
|
139
140
|
end
|
140
|
-
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
def parent_data
|
143
|
+
self.class.parent_data
|
144
|
+
end
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
def parent
|
147
|
+
if parent_data.present?
|
148
|
+
@parent ||= parent_data[:model_class].where(parent_data[:find_by] => params["#{model_name}_id"]).first
|
149
|
+
instance_variable_set("@#{model_name}", @parent)
|
150
|
+
else
|
151
|
+
nil
|
152
|
+
end
|
152
153
|
end
|
153
|
-
end
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
def find_resource
|
156
|
+
if parent_data.present?
|
157
|
+
parent.send(controller_name).find(params[:id])
|
158
|
+
else
|
159
|
+
model_class.find(params[:id])
|
160
|
+
end
|
160
161
|
end
|
161
|
-
end
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
def build_resource
|
164
|
+
if parent_data.present?
|
165
|
+
parent.send(controller_name).build(params[object_name])
|
166
|
+
else
|
167
|
+
model_class.new(params[object_name])
|
168
|
+
end
|
168
169
|
end
|
169
|
-
end
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
171
|
+
def collection
|
172
|
+
return parent.send(controller_name) if parent_data.present?
|
173
|
+
if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
|
174
|
+
model_class.accessible_by(current_ability)
|
175
|
+
else
|
176
|
+
model_class.scoped
|
177
|
+
end
|
177
178
|
end
|
178
|
-
end
|
179
179
|
|
180
|
-
|
181
|
-
|
182
|
-
|
180
|
+
def location_after_save
|
181
|
+
collection_url
|
182
|
+
end
|
183
183
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
184
|
+
def invoke_callbacks(action, callback_type)
|
185
|
+
callbacks = self.class.callbacks || {}
|
186
|
+
return if callbacks[action].nil?
|
187
|
+
case callback_type.to_sym
|
188
|
+
when :before then callbacks[action].before_methods.each {|method| send method }
|
189
|
+
when :after then callbacks[action].after_methods.each {|method| send method }
|
190
|
+
when :fails then callbacks[action].fails_methods.each {|method| send method }
|
191
|
+
end
|
191
192
|
end
|
192
|
-
end
|
193
193
|
|
194
|
-
|
194
|
+
# URL helpers
|
195
195
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
196
|
+
def new_object_url(options = {})
|
197
|
+
if parent_data.present?
|
198
|
+
spree.new_polymorphic_url([:admin, parent, model_class], options)
|
199
|
+
else
|
200
|
+
spree.new_polymorphic_url([:admin, model_class], options)
|
201
|
+
end
|
201
202
|
end
|
202
|
-
end
|
203
203
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
204
|
+
def edit_object_url(object, options = {})
|
205
|
+
if parent_data.present?
|
206
|
+
spree.send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
|
207
|
+
else
|
208
|
+
spree.send "edit_admin_#{object_name}_url", object, options
|
209
|
+
end
|
209
210
|
end
|
210
|
-
end
|
211
211
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
212
|
+
def object_url(object = nil, options = {})
|
213
|
+
target = object ? object : @object
|
214
|
+
if parent_data.present?
|
215
|
+
spree.send "admin_#{model_name}_#{object_name}_url", parent, target, options
|
216
|
+
else
|
217
|
+
spree.send "admin_#{object_name}_url", target, options
|
218
|
+
end
|
218
219
|
end
|
219
|
-
end
|
220
220
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
221
|
+
def collection_url(options = {})
|
222
|
+
if parent_data.present?
|
223
|
+
spree.polymorphic_url([:admin, parent, model_class], options)
|
224
|
+
else
|
225
|
+
spree.polymorphic_url([:admin, model_class], options)
|
226
|
+
end
|
226
227
|
end
|
227
|
-
end
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
|
229
|
+
def collection_actions
|
230
|
+
[:index]
|
231
|
+
end
|
232
232
|
|
233
|
-
|
234
|
-
|
235
|
-
|
233
|
+
def member_action?
|
234
|
+
!collection_actions.include? params[:action].to_sym
|
235
|
+
end
|
236
236
|
|
237
|
-
|
238
|
-
|
239
|
-
|
237
|
+
def new_actions
|
238
|
+
[:new, :create]
|
239
|
+
end
|
240
240
|
end
|