spree_core 0.50.4 → 0.60.0.RC1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/adjustments_controller.rb +8 -7
- data/app/controllers/admin/base_controller.rb +1 -33
- data/app/controllers/admin/configurations_controller.rb +0 -24
- data/app/controllers/admin/images_controller.rb +10 -25
- data/app/controllers/admin/line_items_controller.rb +41 -26
- data/app/controllers/admin/mail_methods_controller.rb +2 -7
- data/app/controllers/admin/option_types_controller.rb +17 -21
- data/app/controllers/admin/orders_controller.rb +70 -55
- data/app/controllers/admin/payment_methods_controller.rb +33 -22
- data/app/controllers/admin/payments_controller.rb +25 -27
- data/app/controllers/admin/product_groups_controller.rb +22 -20
- data/app/controllers/admin/product_properties_controller.rb +2 -6
- data/app/controllers/admin/product_scopes_controller.rb +24 -20
- data/app/controllers/admin/products_controller.rb +20 -26
- data/app/controllers/admin/properties_controller.rb +2 -20
- data/app/controllers/admin/prototypes_controller.rb +5 -33
- data/app/controllers/admin/resource_controller.rb +221 -0
- data/app/controllers/admin/return_authorizations_controller.rb +3 -9
- data/app/controllers/admin/shipments_controller.rb +68 -35
- data/app/controllers/admin/shipping_categories_controller.rb +1 -15
- data/app/controllers/admin/shipping_methods_controller.rb +6 -12
- data/app/controllers/admin/states_controller.rb +16 -21
- data/app/controllers/admin/tax_categories_controller.rb +1 -12
- data/app/controllers/admin/tax_rates_controller.rb +2 -12
- data/app/controllers/admin/taxonomies_controller.rb +11 -12
- data/app/controllers/admin/taxons_controller.rb +74 -53
- data/app/controllers/admin/trackers_controller.rb +1 -6
- data/app/controllers/admin/users_controller.rb +36 -35
- data/app/controllers/admin/variants_controller.rb +7 -22
- data/app/controllers/admin/zones_controller.rb +12 -25
- data/app/controllers/checkout_controller.rb +2 -6
- data/app/controllers/orders_controller.rb +0 -1
- data/app/controllers/products_controller.rb +12 -16
- data/app/controllers/taxons_controller.rb +8 -15
- data/app/helpers/admin/navigation_helper.rb +4 -0
- data/app/models/address.rb +1 -1
- data/app/models/app_configuration.rb +2 -3
- data/app/models/product.rb +1 -2
- data/app/models/product_group.rb +8 -8
- data/app/models/product_scope.rb +1 -1
- data/app/models/shipping_method.rb +6 -2
- data/app/models/tax_rate.rb +1 -1
- data/app/views/admin/general_settings/edit.html.erb +10 -15
- data/app/views/admin/general_settings/show.html.erb +5 -5
- data/app/views/admin/option_types/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/orders/_form.html.erb +0 -1
- data/app/views/admin/orders/edit.html.erb +2 -2
- data/app/views/admin/orders/index.html.erb +2 -2
- data/app/views/admin/payment_methods/edit.html.erb +1 -1
- data/app/views/admin/payments/new.html.erb +2 -2
- data/app/views/admin/payments/show.html.erb +3 -3
- data/app/views/admin/product_groups/index.html.erb +1 -1
- data/app/views/admin/product_scopes/create.js.erb +3 -3
- data/app/views/admin/product_scopes/destroy.js.erb +2 -2
- data/app/views/admin/products/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/properties/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/prototypes/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/shared/_product_tabs.html.erb +1 -1
- data/app/views/admin/shared/_tabs.html.erb +1 -1
- data/app/views/admin/shipments/edit.html.erb +3 -3
- data/app/views/admin/shipments/index.html.erb +1 -1
- data/app/views/admin/shipments/new.html.erb +1 -1
- data/app/views/admin/states/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/tax_categories/edit.html.erb +1 -1
- data/app/views/admin/taxonomies/{edit.html.erb → edit.erb} +0 -0
- data/app/views/admin/taxons/edit.html.erb +1 -1
- data/app/views/admin/variants/{new.html.erb → new.erb} +0 -0
- data/app/views/admin/zones/index.html.erb +2 -3
- data/app/views/checkout/_address.html.erb +2 -2
- data/app/views/layouts/admin.html.erb +0 -1
- data/app/views/products/_thumbnails.html.erb +2 -2
- data/app/views/shared/_admin_head.html.erb +5 -5
- data/app/views/shared/_order_details.html.erb +1 -1
- data/app/views/states/index.js.erb +1 -1
- data/config/initializers/spree.rb +2 -0
- data/config/locales/en.yml +12 -9
- data/config/routes.rb +2 -6
- data/lib/scopes/product.rb +5 -8
- data/lib/spree/preference_access.rb +2 -2
- data/lib/spree_base.rb +1 -1
- data/lib/spree_core.rb +1 -1
- data/lib/spree_core/action_callbacks.rb +26 -0
- data/lib/spree_core/version.rb +1 -1
- data/lib/tasks/taxon.rake +1 -1
- data/public/javascripts/admin.js +0 -6
- data/public/javascripts/admin/address_states.js +5 -5
- data/public/javascripts/application.js +2 -2
- data/public/stylesheets/admin/admin.css +0 -29
- data/public/stylesheets/screen.css +1 -0
- metadata +97 -79
- data/app/models/spree/alert.rb +0 -13
- data/app/views/account/login.html.erb +0 -4
- data/app/views/admin/configurations/new.html.erb +0 -13
- data/app/views/admin/payments/_card_form.html.erb +0 -49
- data/app/views/admin/shared/_alert.html.erb +0 -6
- data/lib/spree_core/find_by_param.rb +0 -119
@@ -1,31 +1,42 @@
|
|
1
|
-
class Admin::PaymentMethodsController < Admin::
|
2
|
-
|
1
|
+
class Admin::PaymentMethodsController < Admin::ResourceController
|
2
|
+
skip_before_filter :load_resource, :only => [:create]
|
3
3
|
before_filter :load_data
|
4
4
|
|
5
|
-
|
5
|
+
def create
|
6
|
+
@payment_method = params[:payment_method][:type].constantize.new(params[:payment_method])
|
7
|
+
@object = @payment_method
|
8
|
+
invoke_callbacks(:create, :before)
|
9
|
+
if @payment_method.save
|
10
|
+
invoke_callbacks(:create, :after)
|
11
|
+
flash[:notice] = I18n.t(:successfully_created, :resource => I18n.t(:payment_method))
|
12
|
+
respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
|
13
|
+
else
|
14
|
+
invoke_callbacks(:create, :fails)
|
15
|
+
render :new
|
16
|
+
end
|
17
|
+
end
|
6
18
|
|
7
|
-
update
|
8
|
-
|
19
|
+
def update
|
20
|
+
invoke_callbacks(:update, :before)
|
21
|
+
payment_method_type = params[:payment_method].delete(:type)
|
22
|
+
if @payment_method['type'].to_s != payment_method_type
|
23
|
+
@payment_method.update_attribute(:type, payment_method_type)
|
24
|
+
@payment_method = PaymentMethod.find(params[:id])
|
25
|
+
end
|
26
|
+
payment_method_params = params[@payment_method.class.name.underscore.gsub("/", "_")] || {}
|
27
|
+
if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
|
28
|
+
invoke_callbacks(:update, :after)
|
29
|
+
flash[:notice] = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method))
|
30
|
+
respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
|
31
|
+
else
|
32
|
+
invoke_callbacks(:update, :fails)
|
33
|
+
render :edit
|
34
|
+
end
|
35
|
+
end
|
9
36
|
|
10
37
|
private
|
11
|
-
def build_object
|
12
|
-
if params[:payment_method] && params[:payment_method][:type]
|
13
|
-
@object ||= params[:payment_method][:type].constantize.send parent? ? :build : :new, object_params
|
14
|
-
else
|
15
|
-
@object ||= end_of_association_chain.send parent? ? :build : :new, object_params
|
16
|
-
end
|
17
|
-
end
|
18
38
|
|
19
39
|
def load_data
|
20
|
-
@providers = Gateway.providers
|
21
|
-
end
|
22
|
-
|
23
|
-
def update_before
|
24
|
-
if params[:payment_method] && params[:payment_method][:type] && @object['type'].to_s != params[:payment_method][:type]
|
25
|
-
@object.update_attribute(:type, params[:payment_method][:type])
|
26
|
-
|
27
|
-
load_object
|
28
|
-
end
|
29
|
-
@object.update_attributes params[@object.class.name.underscore.gsub("/", "_")]
|
40
|
+
@providers = Gateway.providers.sort{|p1, p2| p1.name <=> p2.name }
|
30
41
|
end
|
31
42
|
end
|
@@ -1,12 +1,21 @@
|
|
1
1
|
class Admin::PaymentsController < Admin::BaseController
|
2
|
+
before_filter :load_order, :only => [:create, :new, :index, :fire]
|
3
|
+
before_filter :load_payment, :except => [:create, :new, :index]
|
2
4
|
before_filter :load_data
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
|
6
|
+
def index
|
7
|
+
@payments = @order.payments
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@payment = @order.payments.build
|
12
|
+
end
|
6
13
|
|
7
14
|
def create
|
8
|
-
|
9
|
-
|
15
|
+
@payment = @order.payments.build(object_params)
|
16
|
+
if @payment.payment_method.is_a?(Gateway) && @payment.payment_method.payment_profiles_supported? && params[:card].present? and params[:card] != 'new'
|
17
|
+
@payment.source = Creditcard.find_by_id(params[:card])
|
18
|
+
end
|
10
19
|
|
11
20
|
begin
|
12
21
|
unless @payment.save
|
@@ -16,8 +25,8 @@ class Admin::PaymentsController < Admin::BaseController
|
|
16
25
|
|
17
26
|
if @order.completed?
|
18
27
|
@payment.process!
|
19
|
-
|
20
|
-
redirect_to
|
28
|
+
flash[:notice] = I18n.t(:successfully_created, :resource => 'payment')
|
29
|
+
redirect_to admin_order_payments_path(@order)
|
21
30
|
else
|
22
31
|
#This is the first payment (admin created order)
|
23
32
|
until @order.completed?
|
@@ -29,13 +38,12 @@ class Admin::PaymentsController < Admin::BaseController
|
|
29
38
|
|
30
39
|
rescue Spree::GatewayError => e
|
31
40
|
flash[:error] = "#{e.message}"
|
32
|
-
redirect_to
|
41
|
+
redirect_to new_admin_payment_path(@order)
|
33
42
|
end
|
34
43
|
end
|
35
44
|
|
36
45
|
def fire
|
37
46
|
# TODO: consider finer-grained control for this type of action (right now anyone in admin role can perform)
|
38
|
-
load_object
|
39
47
|
return unless event = params[:e] and @payment.payment_source
|
40
48
|
if @payment.payment_source.send("#{event}", @payment)
|
41
49
|
flash.notice = t('payment_updated')
|
@@ -45,16 +53,11 @@ class Admin::PaymentsController < Admin::BaseController
|
|
45
53
|
rescue Spree::GatewayError => ge
|
46
54
|
flash[:error] = "#{ge.message}"
|
47
55
|
ensure
|
48
|
-
redirect_to
|
56
|
+
redirect_to admin_order_payments_path(@order)
|
49
57
|
end
|
50
58
|
|
51
59
|
private
|
52
60
|
|
53
|
-
def object
|
54
|
-
@object ||= Payment.find(param) unless param.nil?
|
55
|
-
@object
|
56
|
-
end
|
57
|
-
|
58
61
|
def object_params
|
59
62
|
if params[:payment] and params[:payment_source] and source_params = params.delete(:payment_source)[params[:payment][:payment_method_id]]
|
60
63
|
params[:payment][:source_attributes] = source_params
|
@@ -63,27 +66,22 @@ class Admin::PaymentsController < Admin::BaseController
|
|
63
66
|
end
|
64
67
|
|
65
68
|
def load_data
|
66
|
-
|
69
|
+
@amount = params[:amount] || load_order.total
|
67
70
|
@payment_methods = PaymentMethod.available(:back_end)
|
68
|
-
if
|
69
|
-
@payment_method =
|
71
|
+
if @payment and @payment.payment_method
|
72
|
+
@payment_method = @payment.payment_method
|
70
73
|
else
|
71
74
|
@payment_method = @payment_methods.first
|
72
75
|
end
|
73
76
|
@previous_cards = @order.creditcards.with_payment_profile
|
74
77
|
end
|
75
78
|
|
76
|
-
def
|
77
|
-
@
|
79
|
+
def load_order
|
80
|
+
@order ||= Order.find_by_number! params[:order_id]
|
78
81
|
end
|
79
82
|
|
80
|
-
def
|
81
|
-
@
|
82
|
-
@object.order = parent_object
|
83
|
-
if @object.payment_method.is_a?(Gateway) and @object.payment_method.payment_profiles_supported? and params[:card].present? and params[:card] != 'new'
|
84
|
-
@object.source = Creditcard.find_by_id(params[:card])
|
85
|
-
end
|
86
|
-
@object
|
83
|
+
def load_payment
|
84
|
+
@payment ||= Payment.find params[:id]
|
87
85
|
end
|
88
86
|
|
89
87
|
end
|
@@ -1,26 +1,35 @@
|
|
1
|
-
class Admin::ProductGroupsController < Admin::
|
2
|
-
|
3
|
-
|
4
|
-
create.response do |wants|
|
5
|
-
wants.html { redirect_to edit_object_path }
|
6
|
-
end
|
7
|
-
update.response do |wants|
|
8
|
-
wants.html { redirect_to edit_object_path }
|
9
|
-
wants.js { render :action => 'update', :layout => false}
|
10
|
-
end
|
11
|
-
|
1
|
+
class Admin::ProductGroupsController < Admin::ResourceController
|
2
|
+
before_filter :patch_params, :only => [:update]
|
3
|
+
|
12
4
|
def preview
|
13
5
|
@product_group = ProductGroup.new(params[:product_group])
|
14
6
|
@product_group.name = "for_preview"
|
15
7
|
render :partial => 'preview', :layout => false
|
16
8
|
end
|
17
9
|
|
10
|
+
protected
|
18
11
|
|
12
|
+
def find_resource
|
13
|
+
ProductGroup.find_by_permalink(params[:id])
|
14
|
+
end
|
15
|
+
|
16
|
+
def location_after_save
|
17
|
+
edit_admin_product_group_path(@product_group)
|
18
|
+
end
|
19
|
+
|
20
|
+
def collection
|
21
|
+
params[:search] ||= {}
|
22
|
+
params[:search][:meta_sort] ||= "name.asc"
|
23
|
+
@search = super.metasearch(params[:search])
|
24
|
+
@collection = @search.paginate( :per_page => Spree::Config[:per_page],
|
25
|
+
:page => params[:page])
|
26
|
+
end
|
27
|
+
|
19
28
|
private
|
20
29
|
|
21
30
|
# Consolidate argument arrays for nested product_scope attributes
|
22
31
|
# Necessary for product scopes with multiple arguments
|
23
|
-
def
|
32
|
+
def patch_params
|
24
33
|
if params["product_group"] and params["product_group"]["product_scopes_attributes"].is_a?(Array)
|
25
34
|
params["product_group"]["product_scopes_attributes"] = params["product_group"]["product_scopes_attributes"].group_by {|a| a["id"]}.map do |scope_id, attrs|
|
26
35
|
a = { "id" => scope_id, "arguments" => attrs.map{|a| a["arguments"] }.flatten }
|
@@ -30,15 +39,8 @@ class Admin::ProductGroupsController < Admin::BaseController
|
|
30
39
|
a
|
31
40
|
end
|
32
41
|
end
|
33
|
-
params["product_group"]
|
34
42
|
end
|
35
43
|
|
36
|
-
|
37
|
-
params[:search] ||= {}
|
38
|
-
params[:search][:meta_sort] ||= "name.desc"
|
39
|
-
@search = ProductGroup.metasearch(params[:search])
|
40
|
-
@collection = @search.paginate( :per_page => Spree::Config[:per_page],
|
41
|
-
:page => params[:page])
|
42
|
-
end
|
44
|
+
|
43
45
|
|
44
46
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
class Admin::ProductPropertiesController < Admin::
|
2
|
-
|
1
|
+
class Admin::ProductPropertiesController < Admin::ResourceController
|
2
|
+
belongs_to :product, :find_by => :permalink
|
3
3
|
before_filter :find_properties
|
4
4
|
|
5
|
-
# note: we're using attribute_fu to manage the product_properties so the products controller will be
|
6
|
-
# doing most of the work
|
7
|
-
belongs_to :product
|
8
|
-
|
9
5
|
private
|
10
6
|
|
11
7
|
def find_properties
|
@@ -1,27 +1,31 @@
|
|
1
1
|
class Admin::ProductScopesController < Admin::BaseController
|
2
2
|
helper 'admin/product_groups'
|
3
|
-
|
4
|
-
resource_controller
|
5
|
-
|
6
|
-
belongs_to :product_group
|
7
|
-
|
8
|
-
actions :create, :destroy
|
9
3
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
def create
|
5
|
+
@product_group = ProductGroup.find_by_permalink(params[:product_group_id])
|
6
|
+
@product_scope = @product_group.product_scopes.build(params[:product_scope])
|
7
|
+
if @product_scope.save
|
8
|
+
respond_to do |format|
|
9
|
+
format.html { redirect_to edit_admin_product_group_path(@product_group) }
|
10
|
+
format.js { render :layout => false }
|
11
|
+
end
|
12
|
+
else
|
13
|
+
render :new
|
14
|
+
end
|
19
15
|
end
|
20
16
|
|
21
|
-
|
17
|
+
def destroy
|
18
|
+
@product_scope = ProductScope.find(params[:id])
|
19
|
+
if @product_scope.destroy
|
20
|
+
@product_group = @product_scope.product_group
|
21
|
+
@product_group.update_memberships
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { redirect_to edit_admin_product_group_path(@product_group) }
|
24
|
+
format.js { render :layout => false }
|
25
|
+
end
|
26
|
+
else
|
27
|
+
redirect_to edit_admin_product_group_path(@product_scope.product_group)
|
28
|
+
end
|
29
|
+
end
|
22
30
|
|
23
|
-
def update_memberships
|
24
|
-
object.product_group.update_memberships
|
25
|
-
end
|
26
|
-
|
27
31
|
end
|
@@ -1,28 +1,13 @@
|
|
1
|
-
class Admin::ProductsController < Admin::
|
2
|
-
resource_controller
|
1
|
+
class Admin::ProductsController < Admin::ResourceController
|
3
2
|
before_filter :check_json_authenticity, :only => :index
|
4
3
|
before_filter :load_data, :except => :index
|
5
|
-
|
6
|
-
index.response do |wants|
|
7
|
-
wants.html { render :action => :index }
|
8
|
-
wants.json { render :json => json_data }
|
9
|
-
end
|
10
|
-
|
11
|
-
new_action.response do |wants|
|
12
|
-
wants.html {render :action => :new, :layout => !request.xhr?}
|
13
|
-
end
|
14
|
-
|
15
4
|
update.before :update_before
|
16
5
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
update.response do |wants|
|
23
|
-
# override the default redirect behavior of r_c
|
24
|
-
# need to reload Product in case name / permalink has changed
|
25
|
-
wants.html {redirect_to edit_admin_product_url(@product) }
|
6
|
+
def index
|
7
|
+
respond_to do |format|
|
8
|
+
format.html
|
9
|
+
format.json { render :json => json_data }
|
10
|
+
end
|
26
11
|
end
|
27
12
|
|
28
13
|
# override the destory method to set deleted_at value
|
@@ -49,7 +34,6 @@ class Admin::ProductsController < Admin::BaseController
|
|
49
34
|
end
|
50
35
|
|
51
36
|
def clone
|
52
|
-
load_object
|
53
37
|
@new = @product.duplicate
|
54
38
|
|
55
39
|
if @new.save
|
@@ -60,7 +44,17 @@ class Admin::ProductsController < Admin::BaseController
|
|
60
44
|
|
61
45
|
redirect_to edit_admin_product_url(@new)
|
62
46
|
end
|
63
|
-
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def find_resource
|
51
|
+
Product.find_by_permalink(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
def location_after_save
|
55
|
+
edit_admin_product_url(@product)
|
56
|
+
end
|
57
|
+
|
64
58
|
# Allow different formats of json data to suit different ajax calls
|
65
59
|
def json_data
|
66
60
|
json_format = params[:json_format] or 'default'
|
@@ -88,7 +82,7 @@ class Admin::ProductsController < Admin::BaseController
|
|
88
82
|
end
|
89
83
|
|
90
84
|
params[:search][:meta_sort] ||= "name.asc"
|
91
|
-
@search =
|
85
|
+
@search = super.metasearch(params[:search])
|
92
86
|
|
93
87
|
pagination_options = {:include => {:variants => [:images, :option_values]},
|
94
88
|
:per_page => Spree::Config[:admin_products_per_page],
|
@@ -98,10 +92,10 @@ class Admin::ProductsController < Admin::BaseController
|
|
98
92
|
else
|
99
93
|
includes = [{:variants => [:images, {:option_values => :option_type}]}, :master, :images]
|
100
94
|
|
101
|
-
@collection =
|
95
|
+
@collection = super.where(["name #{LIKE} ?", "%#{params[:q]}%"])
|
102
96
|
@collection = @collection.includes(includes).limit(params[:limit] || 10)
|
103
97
|
|
104
|
-
tmp =
|
98
|
+
tmp = super.where(["variants.sku #{LIKE} ?", "%#{params[:q]}%"])
|
105
99
|
tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
|
106
100
|
@collection.concat(tmp)
|
107
101
|
|
@@ -1,27 +1,9 @@
|
|
1
|
-
class Admin::PropertiesController < Admin::
|
2
|
-
resource_controller
|
3
|
-
|
4
|
-
before_filter :load_object, :only => :filtered
|
5
|
-
belongs_to :product
|
1
|
+
class Admin::PropertiesController < Admin::ResourceController
|
6
2
|
|
3
|
+
# Looks like this action is unused
|
7
4
|
def filtered
|
8
5
|
@properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
|
9
6
|
render :template => "admin/properties/filtered.html.erb", :layout => false
|
10
7
|
end
|
11
8
|
|
12
|
-
new_action.response do |wants|
|
13
|
-
wants.html {render :action => :new, :layout => !request.xhr? }
|
14
|
-
end
|
15
|
-
|
16
|
-
# redirect to index (instead of r_c default of show view)
|
17
|
-
update.response do |wants|
|
18
|
-
wants.html {redirect_to collection_url}
|
19
|
-
end
|
20
|
-
|
21
|
-
# redirect to index (instead of r_c default of show view)
|
22
|
-
create.response do |wants|
|
23
|
-
wants.html {redirect_to collection_url}
|
24
|
-
end
|
25
|
-
|
26
|
-
destroy.success.wants.js { render_js_for_destroy }
|
27
9
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
class Admin::PrototypesController < Admin::
|
2
|
-
resource_controller
|
1
|
+
class Admin::PrototypesController < Admin::ResourceController
|
3
2
|
after_filter :set_habtm_associations, :only => [:create, :update]
|
4
3
|
|
5
4
|
helper 'admin/product_properties'
|
@@ -12,41 +11,14 @@ class Admin::PrototypesController < Admin::BaseController
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def select
|
15
|
-
|
14
|
+
@prototype ||= Prototype.find(params[:id])
|
16
15
|
@prototype_properties = @prototype.properties
|
17
16
|
end
|
18
17
|
|
19
|
-
new_action.response do |wants|
|
20
|
-
wants.html {
|
21
|
-
render :action => :new, :layout => !request.xhr?
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
# redirect to index (instead of r_c default of show view)
|
26
|
-
update.response do |wants|
|
27
|
-
wants.html {redirect_to collection_url}
|
28
|
-
end
|
29
|
-
|
30
|
-
# redirect to index (instead of r_c default of show view)
|
31
|
-
create.response do |wants|
|
32
|
-
wants.html {redirect_to collection_url}
|
33
|
-
end
|
34
|
-
|
35
|
-
destroy.success.wants.js { render_js_for_destroy }
|
36
|
-
|
37
18
|
private
|
19
|
+
|
38
20
|
def set_habtm_associations
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def specified_rights(type)
|
44
|
-
rights = []
|
45
|
-
key = "#{type}_ids".to_sym
|
46
|
-
params[:permission][key] ||= []
|
47
|
-
params[:permission][key].each do |id|
|
48
|
-
rights << type.classify.constantize.find(id)
|
49
|
-
end
|
50
|
-
rights
|
21
|
+
@prototype.property_ids = params[:property][:id] if params[:property]
|
22
|
+
@prototype.option_type_ids = params[:option_type][:id] if params[:option_type]
|
51
23
|
end
|
52
24
|
end
|