spree_core 0.60.0.RC1 → 0.60.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/line_items_controller.rb +12 -13
- data/app/controllers/admin/orders_controller.rb +11 -3
- data/app/controllers/admin/payment_methods_controller.rb +3 -3
- data/app/controllers/admin/payments_controller.rb +12 -5
- data/app/controllers/admin/product_groups_controller.rb +1 -1
- data/app/controllers/admin/product_scopes_controller.rb +12 -8
- data/app/controllers/admin/products_controller.rb +7 -7
- data/app/controllers/admin/properties_controller.rb +3 -1
- data/app/controllers/admin/prototypes_controller.rb +4 -2
- data/app/controllers/admin/reports_controller.rb +5 -1
- data/app/controllers/admin/resource_controller.rb +40 -31
- data/app/controllers/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/admin/shipments_controller.rb +7 -8
- data/app/controllers/admin/states_controller.rb +3 -3
- data/app/controllers/admin/taxonomies_controller.rb +5 -2
- data/app/controllers/admin/taxons_controller.rb +39 -18
- data/app/controllers/admin/users_controller.rb +5 -5
- data/app/controllers/admin/variants_controller.rb +4 -4
- data/app/controllers/admin/zones_controller.rb +3 -2
- data/app/controllers/checkout_controller.rb +6 -5
- data/app/controllers/content_controller.rb +8 -2
- data/app/controllers/orders_controller.rb +8 -5
- data/app/controllers/products_controller.rb +9 -5
- data/app/controllers/spree/base_controller.rb +1 -0
- data/app/controllers/taxons_controller.rb +5 -1
- data/app/helpers/admin/taxons_helper.rb +14 -1
- data/app/helpers/spree/base_helper.rb +2 -1
- data/app/models/app_configuration.rb +1 -0
- data/app/models/creditcard.rb +1 -1
- data/app/views/admin/orders/history.html.erb +1 -1
- data/app/views/admin/reports/index.html.erb +3 -3
- data/app/views/admin/taxons/available.js.erb +2 -2
- data/app/views/admin/taxons/selected.html.erb +1 -0
- data/app/views/orders/show.html.erb +10 -12
- data/app/views/products/show.html.erb +1 -1
- data/app/views/taxons/show.html.erb +1 -1
- data/config/locales/en.yml +1 -3
- data/config/routes.rb +1 -0
- data/lib/product_filters.rb +2 -2
- data/lib/spree_base.rb +1 -0
- data/lib/spree_core.rb +6 -0
- data/lib/spree_core/ext/hash.rb +75 -0
- data/lib/spree_core/spree_custom_responder.rb +29 -0
- data/lib/spree_core/spree_respond_with.rb +57 -0
- data/lib/spree_core/version.rb +1 -1
- data/public/javascripts/taxonomy.js +8 -4
- data/public/stylesheets/admin/admin-reset.css +2 -0
- metadata +20 -22
@@ -3,47 +3,46 @@ class Admin::LineItemsController < Admin::BaseController
|
|
3
3
|
before_filter :load_order
|
4
4
|
before_filter :load_line_item, :only => [:destroy, :update]
|
5
5
|
|
6
|
+
respond_to :html
|
7
|
+
|
6
8
|
def create
|
7
9
|
variant = Variant.find(params[:line_item][:variant_id])
|
8
|
-
@order.add_variant(variant, params[:line_item][:quantity].to_i)
|
10
|
+
@line_item = @order.add_variant(variant, params[:line_item][:quantity].to_i)
|
9
11
|
|
10
12
|
if @order.save
|
11
|
-
|
12
|
-
format.html
|
13
|
-
render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false
|
14
|
-
end
|
13
|
+
respond_with(@line_item) do |format|
|
14
|
+
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false }
|
15
15
|
end
|
16
16
|
else
|
17
|
+
#TODO Handle failure gracefully, patches welcome.
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
21
|
def destroy
|
21
22
|
if @line_item.destroy
|
22
|
-
|
23
|
+
respond_with(@line_item) do |format|
|
23
24
|
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false }
|
24
25
|
end
|
25
26
|
else
|
26
|
-
|
27
|
-
format.html
|
28
|
-
render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false
|
29
|
-
end
|
27
|
+
respond_with(@line_item) do |format|
|
28
|
+
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false }
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
33
|
def new
|
35
|
-
|
34
|
+
respond_with do |format|
|
36
35
|
format.html { render :action => :new, :layout => false }
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
def update
|
41
40
|
if @line_item.update_attributes(params[:line_item])
|
42
|
-
|
41
|
+
respond_with(@line_item) do |format|
|
43
42
|
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false}
|
44
43
|
end
|
45
44
|
else
|
46
|
-
|
45
|
+
respond_with(@line_item) do |format|
|
47
46
|
format.html { render :partial => "admin/orders/form", :locals => {:order => @order.reload}, :layout => false}
|
48
47
|
end
|
49
48
|
end
|
@@ -4,6 +4,8 @@ class Admin::OrdersController < Admin::BaseController
|
|
4
4
|
before_filter :initialize_order_events
|
5
5
|
before_filter :load_order, :only => [:fire, :resend, :history, :user]
|
6
6
|
|
7
|
+
respond_to :html
|
8
|
+
|
7
9
|
def index
|
8
10
|
params[:search] ||= {}
|
9
11
|
params[:search][:completed_at_is_not_null] ||= '1' if Spree::Config[:show_only_complete_orders_by_default]
|
@@ -29,18 +31,23 @@ class Admin::OrdersController < Admin::BaseController
|
|
29
31
|
:include => [:user, :shipments, :payments],
|
30
32
|
:per_page => Spree::Config[:orders_per_page],
|
31
33
|
:page => params[:page])
|
34
|
+
|
35
|
+
respond_with(@orders)
|
32
36
|
end
|
33
37
|
|
34
38
|
def show
|
35
39
|
load_order
|
40
|
+
respond_with(@order)
|
36
41
|
end
|
37
42
|
|
38
43
|
def new
|
39
44
|
@order = Order.create
|
45
|
+
respond_with(@order)
|
40
46
|
end
|
41
47
|
|
42
48
|
def edit
|
43
49
|
load_order
|
50
|
+
respond_with(@order)
|
44
51
|
end
|
45
52
|
|
46
53
|
def update
|
@@ -70,7 +77,7 @@ class Admin::OrdersController < Admin::BaseController
|
|
70
77
|
@order.errors.add(:line_items, t('errors.messages.blank'))
|
71
78
|
end
|
72
79
|
|
73
|
-
|
80
|
+
respond_with(@order) do |format|
|
74
81
|
format.html do
|
75
82
|
if return_path
|
76
83
|
redirect_to return_path
|
@@ -94,13 +101,14 @@ class Admin::OrdersController < Admin::BaseController
|
|
94
101
|
rescue Spree::GatewayError => ge
|
95
102
|
flash[:error] = "#{ge.message}"
|
96
103
|
ensure
|
97
|
-
redirect_to :back
|
104
|
+
respond_with(@order) { |format| format.html { redirect_to :back } }
|
98
105
|
end
|
99
106
|
|
100
107
|
def resend
|
101
108
|
OrderMailer.confirm_email(@order, true).deliver
|
102
109
|
flash.notice = t('order_email_resent')
|
103
|
-
|
110
|
+
|
111
|
+
respond_with(@order) { |format| format.html { redirect_to :back } }
|
104
112
|
end
|
105
113
|
|
106
114
|
def user
|
@@ -12,7 +12,7 @@ class Admin::PaymentMethodsController < Admin::ResourceController
|
|
12
12
|
respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
|
13
13
|
else
|
14
14
|
invoke_callbacks(:create, :fails)
|
15
|
-
|
15
|
+
respond_with(@payment_method)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -24,13 +24,13 @@ class Admin::PaymentMethodsController < Admin::ResourceController
|
|
24
24
|
@payment_method = PaymentMethod.find(params[:id])
|
25
25
|
end
|
26
26
|
payment_method_params = params[@payment_method.class.name.underscore.gsub("/", "_")] || {}
|
27
|
-
if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
|
27
|
+
if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
|
28
28
|
invoke_callbacks(:update, :after)
|
29
29
|
flash[:notice] = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method))
|
30
30
|
respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
|
31
31
|
else
|
32
32
|
invoke_callbacks(:update, :fails)
|
33
|
-
|
33
|
+
respond_with(@payment_method)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -3,12 +3,17 @@ class Admin::PaymentsController < Admin::BaseController
|
|
3
3
|
before_filter :load_payment, :except => [:create, :new, :index]
|
4
4
|
before_filter :load_data
|
5
5
|
|
6
|
+
respond_to :html
|
7
|
+
|
6
8
|
def index
|
7
9
|
@payments = @order.payments
|
10
|
+
|
11
|
+
respond_with(@payments)
|
8
12
|
end
|
9
13
|
|
10
14
|
def new
|
11
15
|
@payment = @order.payments.build
|
16
|
+
respond_with(@payment)
|
12
17
|
end
|
13
18
|
|
14
19
|
def create
|
@@ -19,26 +24,28 @@ class Admin::PaymentsController < Admin::BaseController
|
|
19
24
|
|
20
25
|
begin
|
21
26
|
unless @payment.save
|
22
|
-
|
27
|
+
respond_with(@payment) { |format| format.html { redirect_to admin_order_payments_path(@order) } }
|
23
28
|
return
|
24
29
|
end
|
25
30
|
|
26
31
|
if @order.completed?
|
27
32
|
@payment.process!
|
28
33
|
flash[:notice] = I18n.t(:successfully_created, :resource => 'payment')
|
29
|
-
|
34
|
+
|
35
|
+
respond_with(@payment) { |format| format.html { redirect_to admin_order_payments_path(@order) } }
|
30
36
|
else
|
31
37
|
#This is the first payment (admin created order)
|
32
38
|
until @order.completed?
|
33
39
|
@order.next!
|
34
40
|
end
|
35
41
|
flash.notice = t('new_order_completed')
|
36
|
-
redirect_to admin_order_url(@order)
|
42
|
+
respond_with(@payment) { |format| format.html { redirect_to admin_order_url(@order) } }
|
37
43
|
end
|
38
44
|
|
39
45
|
rescue Spree::GatewayError => e
|
40
46
|
flash[:error] = "#{e.message}"
|
41
|
-
|
47
|
+
|
48
|
+
respond_with(@payment) { |format| format.html { redirect_to new_admin_payment_path(@order) } }
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
@@ -53,7 +60,7 @@ class Admin::PaymentsController < Admin::BaseController
|
|
53
60
|
rescue Spree::GatewayError => ge
|
54
61
|
flash[:error] = "#{ge.message}"
|
55
62
|
ensure
|
56
|
-
redirect_to admin_order_payments_path(@order)
|
63
|
+
respond_with(@payment) { |format| format.html { redirect_to admin_order_payments_path(@order) } }
|
57
64
|
end
|
58
65
|
|
59
66
|
private
|
@@ -4,7 +4,7 @@ class Admin::ProductGroupsController < Admin::ResourceController
|
|
4
4
|
def preview
|
5
5
|
@product_group = ProductGroup.new(params[:product_group])
|
6
6
|
@product_group.name = "for_preview"
|
7
|
-
render :partial => 'preview', :layout => false
|
7
|
+
respond_with(@product_group) { |format| format.html { render :partial => 'preview', :layout => false } }
|
8
8
|
end
|
9
9
|
|
10
10
|
protected
|
@@ -1,31 +1,35 @@
|
|
1
1
|
class Admin::ProductScopesController < Admin::BaseController
|
2
2
|
helper 'admin/product_groups'
|
3
|
-
|
3
|
+
|
4
|
+
respond_to :html, :js
|
5
|
+
|
4
6
|
def create
|
5
7
|
@product_group = ProductGroup.find_by_permalink(params[:product_group_id])
|
6
8
|
@product_scope = @product_group.product_scopes.build(params[:product_scope])
|
7
9
|
if @product_scope.save
|
8
|
-
|
10
|
+
respond_with(@product_scope) do |format|
|
9
11
|
format.html { redirect_to edit_admin_product_group_path(@product_group) }
|
10
12
|
format.js { render :layout => false }
|
11
13
|
end
|
12
14
|
else
|
13
|
-
|
15
|
+
respond_with(@product_scope)
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
18
|
+
|
17
19
|
def destroy
|
18
20
|
@product_scope = ProductScope.find(params[:id])
|
19
21
|
if @product_scope.destroy
|
20
22
|
@product_group = @product_scope.product_group
|
21
23
|
@product_group.update_memberships
|
22
|
-
|
24
|
+
respond_with(@product_scope) do |format|
|
23
25
|
format.html { redirect_to edit_admin_product_group_path(@product_group) }
|
24
26
|
format.js { render :layout => false }
|
25
27
|
end
|
26
28
|
else
|
27
|
-
|
29
|
+
respond_with(@product_scope) do |format|
|
30
|
+
format.html { redirect_to edit_admin_product_group_path(@product_scope.product_group) }
|
31
|
+
end
|
28
32
|
end
|
29
|
-
end
|
30
|
-
|
33
|
+
end
|
34
|
+
|
31
35
|
end
|
@@ -4,7 +4,7 @@ class Admin::ProductsController < Admin::ResourceController
|
|
4
4
|
update.before :update_before
|
5
5
|
|
6
6
|
def index
|
7
|
-
|
7
|
+
respond_with(@collection) do |format|
|
8
8
|
format.html
|
9
9
|
format.json { render :json => json_data }
|
10
10
|
end
|
@@ -27,7 +27,7 @@ class Admin::ProductsController < Admin::ResourceController
|
|
27
27
|
flash.notice = I18n.t("notice_messages.product_not_deleted")
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
respond_with(@product) do |format|
|
31
31
|
format.html { redirect_to collection_url }
|
32
32
|
format.js { render_js_for_destroy }
|
33
33
|
end
|
@@ -42,19 +42,19 @@ class Admin::ProductsController < Admin::ResourceController
|
|
42
42
|
flash.notice = I18n.t("notice_messages.product_not_cloned")
|
43
43
|
end
|
44
44
|
|
45
|
-
redirect_to edit_admin_product_url(@new)
|
45
|
+
respond_with(@new) { |format| format.html { redirect_to edit_admin_product_url(@new) } }
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
protected
|
49
|
-
|
49
|
+
|
50
50
|
def find_resource
|
51
51
|
Product.find_by_permalink(params[:id])
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def location_after_save
|
55
55
|
edit_admin_product_url(@product)
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Allow different formats of json data to suit different ajax calls
|
59
59
|
def json_data
|
60
60
|
json_format = params[:json_format] or 'default'
|
@@ -3,7 +3,9 @@ class Admin::PropertiesController < Admin::ResourceController
|
|
3
3
|
# Looks like this action is unused
|
4
4
|
def filtered
|
5
5
|
@properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
|
6
|
-
|
6
|
+
respond_with(@properties) do |format|
|
7
|
+
format.html { render :template => "admin/properties/filtered.html.erb", :layout => false }
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
11
|
end
|
@@ -5,14 +5,16 @@ class Admin::PrototypesController < Admin::ResourceController
|
|
5
5
|
|
6
6
|
def available
|
7
7
|
@prototypes = Prototype.order('name asc')
|
8
|
-
|
9
|
-
|
8
|
+
respond_with(@prototypes) do |format|
|
9
|
+
format.html { render :layout => !request.xhr? }
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def select
|
14
14
|
@prototype ||= Prototype.find(params[:id])
|
15
15
|
@prototype_properties = @prototype.properties
|
16
|
+
|
17
|
+
respond_with(@prototypes)
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
@@ -1,12 +1,14 @@
|
|
1
1
|
class Admin::ReportsController < Admin::BaseController
|
2
2
|
before_filter :load_data
|
3
|
+
respond_to :html
|
3
4
|
|
4
5
|
AVAILABLE_REPORTS = {
|
5
|
-
:sales_total => {:name =>
|
6
|
+
:sales_total => {:name => I18n.t(:sales_total), :description => I18n.t(:sales_total_description)}
|
6
7
|
}
|
7
8
|
|
8
9
|
def index
|
9
10
|
@reports = AVAILABLE_REPORTS
|
11
|
+
respond_with(@reports)
|
10
12
|
end
|
11
13
|
|
12
14
|
def sales_total
|
@@ -36,6 +38,8 @@ class Admin::ReportsController < Admin::BaseController
|
|
36
38
|
@item_total = @search.sum(:item_total)
|
37
39
|
@adjustment_total = @search.sum(:adjustment_total)
|
38
40
|
@sales_total = @search.sum(:total)
|
41
|
+
|
42
|
+
respond_with
|
39
43
|
end
|
40
44
|
|
41
45
|
private
|
@@ -4,15 +4,22 @@ class Admin::ResourceController < Admin::BaseController
|
|
4
4
|
before_filter :load_resource
|
5
5
|
|
6
6
|
respond_to :html
|
7
|
-
|
7
|
+
respond_to :js, :except => [:show, :index]
|
8
|
+
|
8
9
|
def new
|
9
|
-
|
10
|
+
respond_with(@object) do |format|
|
11
|
+
format.html { render :layout => !request.xhr? }
|
12
|
+
format.js { render :layout => false }
|
13
|
+
end
|
10
14
|
end
|
11
|
-
|
15
|
+
|
12
16
|
def edit
|
13
|
-
|
17
|
+
respond_with(@object) do |format|
|
18
|
+
format.html { render :layout => !request.xhr? }
|
19
|
+
format.js { render :layout => false }
|
20
|
+
end
|
14
21
|
end
|
15
|
-
|
22
|
+
|
16
23
|
def update
|
17
24
|
invoke_callbacks(:update, :before)
|
18
25
|
if @object.update_attributes(params[object_name])
|
@@ -20,13 +27,13 @@ class Admin::ResourceController < Admin::BaseController
|
|
20
27
|
resource_desc = I18n.t(object_name)
|
21
28
|
resource_desc += " \"#{@object.name}\"" if @object.respond_to?(:name)
|
22
29
|
flash[:notice] = I18n.t(:successfully_updated, :resource => resource_desc)
|
23
|
-
|
30
|
+
respond_with(@object) do |format|
|
24
31
|
format.html { redirect_to location_after_save }
|
25
|
-
format.js { render :layout => false }
|
32
|
+
format.js { render :layout => false }
|
26
33
|
end
|
27
34
|
else
|
28
35
|
invoke_callbacks(:update, :fails)
|
29
|
-
|
36
|
+
respond_with(@object)
|
30
37
|
end
|
31
38
|
end
|
32
39
|
|
@@ -37,16 +44,16 @@ class Admin::ResourceController < Admin::BaseController
|
|
37
44
|
resource_desc = I18n.t(object_name)
|
38
45
|
resource_desc += " \"#{@object.name}\"" if @object.respond_to?(:name)
|
39
46
|
flash[:notice] = I18n.t(:successfully_created, :resource => resource_desc)
|
40
|
-
|
47
|
+
respond_with(@object) do |format|
|
41
48
|
format.html { redirect_to location_after_save }
|
42
|
-
format.js { render :layout => false }
|
49
|
+
format.js { render :layout => false }
|
43
50
|
end
|
44
51
|
else
|
45
52
|
invoke_callbacks(:create, :fails)
|
46
|
-
|
53
|
+
respond_with(@object)
|
47
54
|
end
|
48
55
|
end
|
49
|
-
|
56
|
+
|
50
57
|
def destroy
|
51
58
|
invoke_callbacks(:destroy, :before)
|
52
59
|
if @object.destroy
|
@@ -54,39 +61,41 @@ class Admin::ResourceController < Admin::BaseController
|
|
54
61
|
resource_desc = I18n.t(object_name)
|
55
62
|
resource_desc += " \"#{@object.name}\"" if @object.respond_to?(:name)
|
56
63
|
flash[:notice] = I18n.t(:successfully_removed, :resource => resource_desc)
|
57
|
-
|
64
|
+
respond_with(@object) do |format|
|
58
65
|
format.html { redirect_to collection_url }
|
59
66
|
format.js { render :partial => "/admin/shared/destroy" }
|
60
67
|
end
|
61
68
|
else
|
62
69
|
invoke_callbacks(:destroy, :fails)
|
63
|
-
|
70
|
+
respond_with(@object) do |format|
|
71
|
+
format.html { redirect_to collection_url }
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
|
-
|
75
|
+
|
67
76
|
protected
|
68
77
|
|
69
78
|
class << self
|
70
79
|
attr_accessor :parent_data
|
71
80
|
attr_accessor :callbacks
|
72
|
-
|
81
|
+
|
73
82
|
def belongs_to(model_name, options = {})
|
74
83
|
@parent_data ||= {}
|
75
84
|
@parent_data[:model_name] = model_name
|
76
85
|
@parent_data[:model_class] = model_name.to_s.classify.constantize
|
77
86
|
@parent_data[:find_by] = options[:find_by] || :id
|
78
87
|
end
|
79
|
-
|
88
|
+
|
80
89
|
def create
|
81
90
|
@callbacks ||= {}
|
82
91
|
@callbacks[:create] ||= Spree::ActionCallbacks.new
|
83
92
|
end
|
84
|
-
|
93
|
+
|
85
94
|
def update
|
86
95
|
@callbacks ||= {}
|
87
96
|
@callbacks[:update] ||= Spree::ActionCallbacks.new
|
88
97
|
end
|
89
|
-
|
98
|
+
|
90
99
|
def destroy
|
91
100
|
@callbacks ||= {}
|
92
101
|
@callbacks[:destroy] ||= Spree::ActionCallbacks.new
|
@@ -96,11 +105,11 @@ class Admin::ResourceController < Admin::BaseController
|
|
96
105
|
def model_class
|
97
106
|
controller_name.classify.constantize
|
98
107
|
end
|
99
|
-
|
108
|
+
|
100
109
|
def object_name
|
101
110
|
controller_name.singularize
|
102
111
|
end
|
103
|
-
|
112
|
+
|
104
113
|
def load_resource
|
105
114
|
if member_action?
|
106
115
|
@object ||= load_resource_instance
|
@@ -110,7 +119,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
110
119
|
instance_variable_set("@#{controller_name}", @collection)
|
111
120
|
end
|
112
121
|
end
|
113
|
-
|
122
|
+
|
114
123
|
def load_resource_instance
|
115
124
|
if new_actions.include?(params[:action].to_sym)
|
116
125
|
build_resource
|
@@ -122,7 +131,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
122
131
|
def parent_data
|
123
132
|
self.class.parent_data
|
124
133
|
end
|
125
|
-
|
134
|
+
|
126
135
|
def parent
|
127
136
|
if parent_data.present?
|
128
137
|
@parent ||= parent_data[:model_class].where(parent_data[:find_by] => params["#{parent_data[:model_name]}_id"]).first
|
@@ -139,7 +148,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
139
148
|
model_class.find(params[:id])
|
140
149
|
end
|
141
150
|
end
|
142
|
-
|
151
|
+
|
143
152
|
def build_resource
|
144
153
|
if parent_data.present?
|
145
154
|
parent.send(controller_name).build(params[object_name])
|
@@ -147,17 +156,17 @@ class Admin::ResourceController < Admin::BaseController
|
|
147
156
|
model_class.new(params[object_name])
|
148
157
|
end
|
149
158
|
end
|
150
|
-
|
159
|
+
|
151
160
|
def collection
|
152
161
|
return parent.send(controller_name) if parent_data.present?
|
153
|
-
|
162
|
+
|
154
163
|
if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
|
155
164
|
model_class.accessible_by(current_ability)
|
156
165
|
else
|
157
166
|
model_class.scoped
|
158
167
|
end
|
159
168
|
end
|
160
|
-
|
169
|
+
|
161
170
|
def location_after_save
|
162
171
|
collection_url
|
163
172
|
end
|
@@ -181,7 +190,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
181
190
|
new_polymorphic_url([:admin, model_class], options)
|
182
191
|
end
|
183
192
|
end
|
184
|
-
|
193
|
+
|
185
194
|
def edit_object_url(object, options = {})
|
186
195
|
if parent_data.present?
|
187
196
|
send "edit_admin_#{parent_data[:model_name]}_#{object_name}_url", parent, object, options
|
@@ -189,7 +198,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
189
198
|
send "edit_admin_#{object_name}_url", object, options
|
190
199
|
end
|
191
200
|
end
|
192
|
-
|
201
|
+
|
193
202
|
def object_url(object = nil, options = {})
|
194
203
|
target = object ? object : @object
|
195
204
|
if parent_data.present?
|
@@ -198,7 +207,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
198
207
|
send "admin_#{object_name}_url", target, options
|
199
208
|
end
|
200
209
|
end
|
201
|
-
|
210
|
+
|
202
211
|
def collection_url(options = {})
|
203
212
|
if parent_data.present?
|
204
213
|
polymorphic_url([:admin, parent, model_class], options)
|
@@ -206,7 +215,7 @@ class Admin::ResourceController < Admin::BaseController
|
|
206
215
|
polymorphic_url([:admin, model_class], options)
|
207
216
|
end
|
208
217
|
end
|
209
|
-
|
218
|
+
|
210
219
|
def collection_actions
|
211
220
|
[:index]
|
212
221
|
end
|