spree_backend 3.0.0.rc1 → 3.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/admin/general_settings_controller.rb +3 -3
  3. data/app/controllers/spree/admin/resource_controller.rb +121 -118
  4. data/app/controllers/spree/admin/roles_controller.rb +6 -0
  5. data/app/controllers/spree/admin/search_controller.rb +9 -9
  6. data/app/controllers/spree/admin/users_controller.rb +4 -0
  7. data/app/helpers/spree/admin/base_helper.rb +5 -0
  8. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  9. data/app/models/spree/admin/resource.rb +33 -0
  10. data/app/views/kaminari/_paginator.html.erb +7 -7
  11. data/app/views/spree/admin/adjustments/_adjustment.html.erb +2 -2
  12. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +10 -8
  13. data/app/views/spree/admin/adjustments/edit.html.erb +1 -1
  14. data/app/views/spree/admin/adjustments/index.html.erb +6 -6
  15. data/app/views/spree/admin/adjustments/new.html.erb +1 -1
  16. data/app/views/spree/admin/countries/index.html.erb +4 -4
  17. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +1 -1
  18. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +2 -2
  19. data/app/views/spree/admin/customer_returns/edit.html.erb +3 -3
  20. data/app/views/spree/admin/customer_returns/index.html.erb +5 -5
  21. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  22. data/app/views/spree/admin/general_settings/edit.html.erb +9 -9
  23. data/app/views/spree/admin/images/edit.html.erb +1 -1
  24. data/app/views/spree/admin/images/index.html.erb +7 -5
  25. data/app/views/spree/admin/images/new.html.erb +1 -1
  26. data/app/views/spree/admin/option_types/index.html.erb +2 -2
  27. data/app/views/spree/admin/orders/_form.html.erb +4 -4
  28. data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
  29. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +2 -2
  30. data/app/views/spree/admin/orders/customer_details/_form.html.erb +31 -21
  31. data/app/views/spree/admin/orders/customer_details/edit.html.erb +13 -11
  32. data/app/views/spree/admin/orders/edit.html.erb +2 -2
  33. data/app/views/spree/admin/orders/index.html.erb +5 -5
  34. data/app/views/spree/admin/payment_methods/index.html.erb +6 -6
  35. data/app/views/spree/admin/payments/_list.html.erb +2 -2
  36. data/app/views/spree/admin/payments/index.html.erb +1 -1
  37. data/app/views/spree/admin/payments/new.html.erb +1 -1
  38. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +2 -2
  39. data/app/views/spree/admin/product_properties/index.html.erb +6 -6
  40. data/app/views/spree/admin/products/_autocomplete.js.erb +1 -1
  41. data/app/views/spree/admin/products/_form.html.erb +36 -12
  42. data/app/views/spree/admin/products/index.html.erb +2 -2
  43. data/app/views/spree/admin/products/new.html.erb +1 -1
  44. data/app/views/spree/admin/products/stock.html.erb +10 -8
  45. data/app/views/spree/admin/promotion_categories/index.html.erb +2 -2
  46. data/app/views/spree/admin/promotions/index.html.erb +2 -2
  47. data/app/views/spree/admin/promotions/rules/_first_order.html.erb +0 -0
  48. data/app/views/spree/admin/properties/index.html.erb +2 -2
  49. data/app/views/spree/admin/prototypes/_form.html.erb +0 -5
  50. data/app/views/spree/admin/prototypes/index.html.erb +2 -2
  51. data/app/views/spree/admin/refund_reasons/index.html.erb +3 -2
  52. data/app/views/spree/admin/refunds/edit.html.erb +1 -1
  53. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  54. data/app/views/spree/admin/reimbursement_types/index.html.erb +2 -3
  55. data/app/views/spree/admin/return_authorization_reasons/index.html.erb +3 -2
  56. data/app/views/spree/admin/return_authorizations/edit.html.erb +1 -1
  57. data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
  58. data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
  59. data/app/views/spree/admin/roles/_form.html.erb +8 -0
  60. data/app/views/spree/admin/roles/edit.html.erb +10 -0
  61. data/app/views/spree/admin/roles/index.html.erb +34 -0
  62. data/app/views/spree/admin/roles/new.html.erb +10 -0
  63. data/app/views/spree/admin/shared/_address.html.erb +38 -0
  64. data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
  65. data/app/views/spree/admin/shared/_head.html.erb +2 -2
  66. data/app/views/spree/admin/shared/_index_table_options.html.erb +2 -2
  67. data/app/views/spree/admin/shared/_order_tabs.html.erb +6 -6
  68. data/app/views/spree/admin/shared/_product_tabs.html.erb +3 -3
  69. data/app/views/spree/admin/shared/_refunds.html.erb +1 -1
  70. data/app/views/spree/admin/shared/named_types/_index.html.erb +3 -3
  71. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +17 -16
  72. data/app/views/spree/admin/shipping_categories/index.html.erb +6 -6
  73. data/app/views/spree/admin/shipping_methods/index.html.erb +6 -6
  74. data/app/views/spree/admin/state_changes/index.html.erb +1 -1
  75. data/app/views/spree/admin/states/_state_list.html.erb +2 -2
  76. data/app/views/spree/admin/states/index.html.erb +2 -2
  77. data/app/views/spree/admin/stock_locations/_form.html.erb +2 -3
  78. data/app/views/spree/admin/stock_locations/index.html.erb +6 -7
  79. data/app/views/spree/admin/stock_movements/index.html.erb +1 -1
  80. data/app/views/spree/admin/stock_transfers/index.html.erb +5 -5
  81. data/app/views/spree/admin/stock_transfers/show.html.erb +2 -2
  82. data/app/views/spree/admin/tax_categories/index.html.erb +7 -7
  83. data/app/views/spree/admin/tax_rates/index.html.erb +6 -6
  84. data/app/views/spree/admin/taxonomies/index.html.erb +2 -2
  85. data/app/views/spree/admin/taxons/edit.html.erb +2 -2
  86. data/app/views/spree/admin/trackers/index.html.erb +5 -5
  87. data/app/views/spree/admin/users/_sidebar.html.erb +4 -4
  88. data/app/views/spree/admin/users/addresses.html.erb +2 -2
  89. data/app/views/spree/admin/users/edit.html.erb +2 -2
  90. data/app/views/spree/admin/users/index.html.erb +1 -1
  91. data/app/views/spree/admin/users/items.html.erb +1 -1
  92. data/app/views/spree/admin/users/new.html.erb +1 -1
  93. data/app/views/spree/admin/users/orders.html.erb +1 -1
  94. data/app/views/spree/admin/variants/index.html.erb +17 -13
  95. data/app/views/spree/admin/zones/index.html.erb +5 -5
  96. data/config/routes.rb +1 -0
  97. metadata +14 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92b7d72a3f5c456c8cb327b2f3f6c804198cf654
4
- data.tar.gz: d6387bce54baf4307ece321f040be10cefe0d8cb
3
+ metadata.gz: 5f5db59f9bb47a1c51a531a664dfef2aa549dee7
4
+ data.tar.gz: 426c2b2ff66046c8fe9bcb9f9f72f174a7c26a1e
5
5
  SHA512:
6
- metadata.gz: e56440fb7535e7ca2529d9e43805a99765749651a5484687d169e17dd6d14b2cbb826668742f4e750462a41bce0e403a6eb42bef6dcf6a3c301eb59feec188cb
7
- data.tar.gz: b7aade6d27904a5baececec20e03996ff570aa3b39e0086e5ab39fe4712711a6d980536866324c2158510bc8f01ee1e6c2a957fc841fa13104ec46184bdef9e6
6
+ metadata.gz: 9d3060c017cb9bcc9d65bbcb76622450005b8eb7c6de162c86ad543519f2705e0d4dcc598102f3da2d0829ee4666f0e932ce6aaad1398b4c060f22c77766272e
7
+ data.tar.gz: f0736eafd142aa3acabd97408f501f97c6a6dd13c96e382cc6c77e2c781b46b8cc51ac3bd65a17a757ae4bcfa63a773f63c83dffd652177c8f4f7e62dda57b3c
@@ -17,16 +17,16 @@ module Spree
17
17
 
18
18
  current_store.update_attributes store_params
19
19
 
20
- flash[:success] = Spree.t(:successfully_updated, :resource => Spree.t(:general_settings))
20
+ flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
21
21
  redirect_to edit_admin_general_settings_path
22
22
  end
23
23
 
24
24
  def dismiss_alert
25
25
  if request.xhr? and params[:alert_id]
26
26
  dismissed = Spree::Config[:dismissed_spree_alerts] || ''
27
- Spree::Config.set :dismissed_spree_alerts => dismissed.split(',').push(params[:alert_id]).join(',')
27
+ Spree::Config.set dismissed_spree_alerts: dismissed.split(',').push(params[:alert_id]).join(',')
28
28
  filter_dismissed_alerts
29
- render :nothing => true
29
+ render nothing: true
30
30
  end
31
31
  end
32
32
 
@@ -100,159 +100,162 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
100
100
 
101
101
  protected
102
102
 
103
- class << self
104
- attr_accessor :parent_data
105
-
106
- def belongs_to(model_name, options = {})
107
- @parent_data ||= {}
108
- @parent_data[:model_name] = model_name
109
- @parent_data[:model_class] = model_name.to_s.classify.constantize
110
- @parent_data[:find_by] = options[:find_by] || :id
111
- end
112
- end
113
-
114
- def resource_not_found
115
- flash[:error] = flash_message_for(model_class.new, :not_found)
116
- redirect_to collection_url
103
+ class << self
104
+ attr_accessor :parent_data
105
+
106
+ def belongs_to(model_name, options = {})
107
+ @parent_data ||= {}
108
+ @parent_data[:model_name] = model_name
109
+ @parent_data[:model_class] = model_name.to_s.classify.constantize
110
+ @parent_data[:find_by] = options[:find_by] || :id
117
111
  end
112
+ end
118
113
 
119
- def model_class
120
- "Spree::#{controller_name.classify}".constantize
121
- end
114
+ def model_class
115
+ @model_class ||= resource.model_class
116
+ end
122
117
 
123
- def model_name
124
- parent_data[:model_name].gsub('spree/', '')
125
- end
118
+ def resource_not_found
119
+ flash[:error] = flash_message_for(model_class.new, :not_found)
120
+ redirect_to collection_url
121
+ end
126
122
 
127
- def object_name
128
- controller_name.singularize
123
+ def resource
124
+ return @resource if @resource
125
+ if parent_data
126
+ parent_model_name = parent_data[:model_name]
129
127
  end
128
+ @resource = Spree::Admin::Resource.new controller_path, controller_name, parent_model_name
129
+ end
130
130
 
131
- def load_resource
132
- if member_action?
133
- @object ||= load_resource_instance
131
+ def load_resource
132
+ if member_action?
133
+ @object ||= load_resource_instance
134
134
 
135
- # call authorize! a third time (called twice already in Admin::BaseController)
136
- # this time we pass the actual instance so fine-grained abilities can control
137
- # access to individual records, not just entire models.
138
- authorize! action, @object
135
+ # call authorize! a third time (called twice already in Admin::BaseController)
136
+ # this time we pass the actual instance so fine-grained abilities can control
137
+ # access to individual records, not just entire models.
138
+ authorize! action, @object
139
139
 
140
- instance_variable_set("@#{object_name}", @object)
141
- else
142
- @collection ||= collection
140
+ instance_variable_set("@#{resource.object_name}", @object)
141
+ else
142
+ @collection ||= collection
143
143
 
144
- # note: we don't call authorize here as the collection method should use
145
- # CanCan's accessible_by method to restrict the actual records returned
144
+ # note: we don't call authorize here as the collection method should use
145
+ # CanCan's accessible_by method to restrict the actual records returned
146
146
 
147
- instance_variable_set("@#{controller_name}", @collection)
148
- end
147
+ instance_variable_set("@#{controller_name}", @collection)
149
148
  end
149
+ end
150
150
 
151
- def load_resource_instance
152
- if new_actions.include?(action)
153
- build_resource
154
- elsif params[:id]
155
- find_resource
156
- end
151
+ def load_resource_instance
152
+ if new_actions.include?(action)
153
+ build_resource
154
+ elsif params[:id]
155
+ find_resource
157
156
  end
157
+ end
158
158
 
159
- def parent_data
160
- self.class.parent_data
161
- end
159
+ def parent_data
160
+ self.class.parent_data
161
+ end
162
162
 
163
- def parent
164
- if parent_data.present?
165
- @parent ||= parent_data[:model_class].send("find_by_#{parent_data[:find_by]}", params["#{model_name}_id"])
166
- instance_variable_set("@#{model_name}", @parent)
167
- else
168
- nil
169
- end
163
+ def parent
164
+ if parent_data.present?
165
+ @parent ||= parent_data[:model_class].
166
+ send("find_by_#{parent_data[:find_by]}", params["#{resource.model_name}_id"])
167
+ instance_variable_set("@#{resource.model_name}", @parent)
168
+ else
169
+ nil
170
170
  end
171
+ end
171
172
 
172
- def find_resource
173
- if parent_data.present?
174
- parent.send(controller_name).find(params[:id])
175
- else
176
- model_class.find(params[:id])
177
- end
173
+ def find_resource
174
+ if parent_data.present?
175
+ parent.send(controller_name).find(params[:id])
176
+ else
177
+ model_class.find(params[:id])
178
178
  end
179
+ end
179
180
 
180
- def build_resource
181
- if parent_data.present?
182
- parent.send(controller_name).build
183
- else
184
- model_class.new
185
- end
181
+ def build_resource
182
+ if parent_data.present?
183
+ parent.send(controller_name).build
184
+ else
185
+ model_class.new
186
186
  end
187
+ end
187
188
 
188
- def collection
189
- return parent.send(controller_name) if parent_data.present?
190
- if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
191
- model_class.accessible_by(current_ability, action)
192
- else
193
- model_class.where(nil)
194
- end
189
+ def collection
190
+ return parent.send(controller_name) if parent_data.present?
191
+ if model_class.respond_to?(:accessible_by) &&
192
+ !current_ability.has_block?(params[:action], model_class)
193
+ model_class.accessible_by(current_ability, action)
194
+ else
195
+ model_class.where(nil)
195
196
  end
197
+ end
196
198
 
197
- def location_after_destroy
198
- collection_url
199
- end
199
+ def location_after_destroy
200
+ collection_url
201
+ end
200
202
 
201
- def location_after_save
202
- collection_url
203
- end
203
+ def location_after_save
204
+ collection_url
205
+ end
204
206
 
205
- # URL helpers
207
+ # URL helpers
206
208
 
207
- def new_object_url(options = {})
208
- if parent_data.present?
209
- spree.new_polymorphic_url([:admin, parent, model_class], options)
210
- else
211
- spree.new_polymorphic_url([:admin, model_class], options)
212
- end
209
+ def new_object_url(options = {})
210
+ if parent_data.present?
211
+ spree.new_polymorphic_url([:admin, parent, model_class], options)
212
+ else
213
+ spree.new_polymorphic_url([:admin, model_class], options)
213
214
  end
215
+ end
214
216
 
215
- def edit_object_url(object, options = {})
216
- if parent_data.present?
217
- spree.send "edit_admin_#{model_name}_#{object_name}_url", parent, object, options
218
- else
219
- spree.send "edit_admin_#{object_name}_url", object, options
220
- end
217
+ def edit_object_url(object, options = {})
218
+ if parent_data.present?
219
+ spree.send "edit_admin_#{resource.model_name}_#{resource.object_name}_url",
220
+ parent, object, options
221
+ else
222
+ spree.send "edit_admin_#{resource.object_name}_url", object, options
221
223
  end
224
+ end
222
225
 
223
- def object_url(object = nil, options = {})
224
- target = object ? object : @object
225
- if parent_data.present?
226
- spree.send "admin_#{model_name}_#{object_name}_url", parent, target, options
227
- else
228
- spree.send "admin_#{object_name}_url", target, options
229
- end
226
+ def object_url(object = nil, options = {})
227
+ target = object ? object : @object
228
+ if parent_data.present?
229
+ spree.send "admin_#{resource.model_name}_#{resource.object_name}_url", parent, target, options
230
+ else
231
+ spree.send "admin_#{resource.object_name}_url", target, options
230
232
  end
233
+ end
231
234
 
232
- def collection_url(options = {})
233
- if parent_data.present?
234
- spree.polymorphic_url([:admin, parent, model_class], options)
235
- else
236
- spree.polymorphic_url([:admin, model_class], options)
237
- end
235
+ def collection_url(options = {})
236
+ if parent_data.present?
237
+ spree.polymorphic_url([:admin, parent, model_class], options)
238
+ else
239
+ spree.polymorphic_url([:admin, model_class], options)
238
240
  end
241
+ end
239
242
 
240
- # Allow all attributes to be updatable.
241
- #
242
- # Other controllers can, should, override it to set custom logic
243
- def permitted_resource_params
244
- params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new
245
- end
243
+ # Allow all attributes to be updatable.
244
+ #
245
+ # Other controllers can, should, override it to set custom logic
246
+ def permitted_resource_params
247
+ params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new
248
+ end
246
249
 
247
- def collection_actions
248
- [:index]
249
- end
250
+ def collection_actions
251
+ [:index]
252
+ end
250
253
 
251
- def member_action?
252
- !collection_actions.include? action
253
- end
254
+ def member_action?
255
+ !collection_actions.include? action
256
+ end
254
257
 
255
- def new_actions
256
- [:new, :create]
257
- end
258
+ def new_actions
259
+ [:new, :create]
260
+ end
258
261
  end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ module Admin
3
+ class RolesController < ResourceController
4
+ end
5
+ end
6
+ end
@@ -9,28 +9,28 @@ module Spree
9
9
  # And then JSON building with something like Active Model Serializers
10
10
  def users
11
11
  if params[:ids]
12
- @users = Spree.user_class.where(:id => params[:ids].split(','))
12
+ @users = Spree.user_class.where(id: params[:ids].split(',').flatten)
13
13
  else
14
14
  @users = Spree.user_class.ransack({
15
- :m => 'or',
16
- :email_start => params[:q],
17
- :ship_address_firstname_start => params[:q],
18
- :ship_address_lastname_start => params[:q],
19
- :bill_address_firstname_start => params[:q],
20
- :bill_address_lastname_start => params[:q]
15
+ m: 'or',
16
+ email_start: params[:q],
17
+ ship_address_firstname_start: params[:q],
18
+ ship_address_lastname_start: params[:q],
19
+ bill_address_firstname_start: params[:q],
20
+ bill_address_lastname_start: params[:q]
21
21
  }).result.limit(10)
22
22
  end
23
23
  end
24
24
 
25
25
  def products
26
26
  if params[:ids]
27
- @products = Product.where(:id => params[:ids].split(","))
27
+ @products = Product.where(id: params[:ids].split(",").flatten)
28
28
  else
29
29
  @products = Product.ransack(params[:q]).result
30
30
  end
31
31
 
32
32
  @products = @products.distinct.page(params[:page]).per(params[:per_page])
33
- expires_in 15.minutes, :public => true
33
+ expires_in 15.minutes, public: true
34
34
  headers['Surrogate-Control'] = "max-age=#{15.minutes}"
35
35
  end
36
36
  end
@@ -35,6 +35,10 @@ module Spree
35
35
  end
36
36
 
37
37
  def update
38
+ if params[:user][:password].blank? && params[:user][:password_confirmation].blank?
39
+ params[:user].delete(:password)
40
+ params[:user].delete(:password_confirmation)
41
+ end
38
42
 
39
43
  if @user.update_attributes(user_params)
40
44
  set_roles
@@ -135,6 +135,11 @@ module Spree
135
135
  dom_id(record, 'spree')
136
136
  end
137
137
 
138
+ I18N_PLURAL_MANY_COUNT = 2.1
139
+ def plural_resource_name(resource_class)
140
+ resource_class.model_name.human(count: I18N_PLURAL_MANY_COUNT)
141
+ end
142
+
138
143
  private
139
144
  def attribute_name_for(field_name)
140
145
  field_name.gsub(' ', '_').downcase
@@ -31,7 +31,7 @@ module Spree
31
31
  selected = if options[:match_path].is_a? Regexp
32
32
  request.fullpath =~ options[:match_path]
33
33
  elsif options[:match_path]
34
- request.fullpath.starts_with?("#{admin_path}#{options[:match_path]}")
34
+ request.fullpath.starts_with?("#{spree.admin_path}#{options[:match_path]}")
35
35
  else
36
36
  args.include?(controller.controller_name.to_sym)
37
37
  end
@@ -0,0 +1,33 @@
1
+ module Spree
2
+ module Admin
3
+ class Resource
4
+ def initialize(controller_path, controller_name, parent_model)
5
+ @controller_path = controller_path
6
+ @controller_name = controller_name
7
+ @parent_model = parent_model
8
+ end
9
+
10
+ def sub_namespace_parts
11
+ @controller_path.split('/')[2..-2]
12
+ end
13
+
14
+ def model_class
15
+ sub_namespace = sub_namespace_parts.map { |s| s.capitalize }.join('::')
16
+ sub_namespace = "#{sub_namespace}::" if sub_namespace.length > 0
17
+ "Spree::#{sub_namespace}#{@controller_name.classify}".constantize
18
+ end
19
+
20
+ def model_name
21
+ sub_namespace = sub_namespace_parts.join('/')
22
+ sub_namespace = "#{sub_namespace}/" if sub_namespace.length > 0
23
+ @parent_model.gsub("spree/#{sub_namespace}", '')
24
+ end
25
+
26
+ def object_name
27
+ sub_namespace = sub_namespace_parts.join('_')
28
+ sub_namespace = "#{sub_namespace}_" if sub_namespace.length > 0
29
+ "#{sub_namespace}#{@controller_name.singularize}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -6,16 +6,16 @@
6
6
  remote: data-remote
7
7
  paginator: the paginator that renders the pagination tags inside
8
8
  -%>
9
- <%= paginator.render do -%>
9
+ <%= paginator.render do %>
10
10
  <ul class="pagination pagination-sm">
11
11
  <%= prev_page_tag %>
12
- <% each_page do |page| -%>
13
- <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
12
+ <% each_page do |page| %>
13
+ <% if page.left_outer? || page.right_outer? || page.inside_window? %>
14
14
  <%= page_tag page %>
15
- <% elsif !page.was_truncated? -%>
15
+ <% elsif !page.was_truncated? %>
16
16
  <%= gap_tag %>
17
- <% end -%>
18
- <% end -%>
17
+ <% end %>
18
+ <% end %>
19
19
  <%= next_page_tag %>
20
20
  </ul>
21
- <% end -%>
21
+ <% end %>
@@ -10,8 +10,8 @@
10
10
  <td class="text-center"><span class="label label-<%= adjustment.state %>"><%= adjustment.state %></td>
11
11
  <td class="actions actions-2 text-center">
12
12
  <% if adjustment.open? %>
13
- <%= link_to_edit adjustment, no_text: true %>
14
- <%= link_to_delete adjustment, no_text: true %>
13
+ <%= link_to_edit(adjustment, no_text: true) if can?(:edit, adjustment) %>
14
+ <%= link_to_delete(adjustment, no_text: true) if can?(:delete, adjustment) %>
15
15
  <% end %>
16
16
  </td>
17
17
  </tr>
@@ -17,13 +17,15 @@
17
17
  </tbody>
18
18
  </table>
19
19
 
20
- <div class="panel-footer">
21
- <div class="row text-center">
22
- <div class="col-md-6">
23
- <%= button_to Spree.t(:open_all_adjustments), open_adjustments_admin_order_path(@order), method: :get, class: "btn btn-success" %>
24
- </div>
25
- <div class="col-md-6">
26
- <%= button_to Spree.t(:close_all_adjustments), close_adjustments_admin_order_path(@order), method: :get, class: "btn btn-danger" %>
20
+ <% if can?(:edit, Spree::Adjustment) %>
21
+ <div class="panel-footer">
22
+ <div class="row text-center">
23
+ <div class="col-md-6">
24
+ <%= button_to Spree.t(:open_all_adjustments), open_adjustments_admin_order_path(@order), method: :get, class: "btn btn-success" %>
25
+ </div>
26
+ <div class="col-md-6">
27
+ <%= button_to Spree.t(:close_all_adjustments), close_adjustments_admin_order_path(@order), method: :get, class: "btn btn-danger" %>
28
+ </div>
27
29
  </div>
28
30
  </div>
29
- </div>
31
+ <% end %>
@@ -13,7 +13,7 @@
13
13
  <div class="form-actions" data-hook="buttons">
14
14
  <%= button Spree.t(:continue), 'save' %>
15
15
  <span class="or"><%= Spree.t(:or) %></span>
16
- <%= button_link_to Spree.t('actions.cancel'), admin_order_adjustments_url(@order), icon: 'delete' %>
16
+ <%= button_link_to Spree.t('actions.cancel'), spree.admin_order_adjustments_url(@order), icon: 'delete' %>
17
17
  </div>
18
18
  </fieldset>
19
19
  <% end %>
@@ -1,20 +1,20 @@
1
1
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: Spree.t(:adjustments)} %>
2
2
 
3
3
  <% content_for :page_title do %>
4
- / <%= Spree::Adjustment.model_name.human(count: :many) %>
4
+ / <%= plural_resource_name(Spree::Adjustment) %>
5
5
  <% end %>
6
6
 
7
7
  <% content_for :page_actions do %>
8
- <%= button_link_to Spree.t(:new_adjustment), new_admin_order_adjustment_url(@order), class: "btn-success", icon: 'add' %>
8
+ <%= button_link_to(Spree.t(:new_adjustment), new_admin_order_adjustment_url(@order), class: "btn-success", icon: 'add') if can? :create, Spree::Adjustment %>
9
9
  <% end %>
10
10
 
11
11
  <% if @adjustments.present? %>
12
- <div class="panel panel-default">
12
+ <div class="panel panel-default">
13
13
  <%= render :partial => 'adjustments_table' %>
14
14
  </div>
15
15
  <% else %>
16
16
  <div class="alert alert-warning">
17
- <%= Spree.t(:no_resource_found, resource: Spree::Adjustment.model_name.human(count: :many)) %>
17
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Adjustment)) %>
18
18
  </div>
19
19
  <% end %>
20
20
 
@@ -27,8 +27,8 @@
27
27
  </div>
28
28
  <% end %>
29
29
 
30
- <%= javascript_tag do -%>
30
+ <%= javascript_tag do %>
31
31
  var order_number = '<%= @order.number %>';
32
- <% end -%>
32
+ <% end %>
33
33
 
34
34
  <%= render partial: 'spree/admin/shared/order_summary' %>
@@ -13,7 +13,7 @@
13
13
  <div class="form-actions" data-hook="buttons">
14
14
  <%= button Spree.t(:continue), 'save' %>
15
15
  <span class="or"><%= Spree.t(:or) %></span>
16
- <%= button_link_to Spree.t('actions.cancel'), admin_order_adjustments_url(@order), :icon => 'delete' %>
16
+ <%= button_link_to Spree.t('actions.cancel'), spree.admin_order_adjustments_url(@order), :icon => 'delete' %>
17
17
  </div>
18
18
  </fieldset>
19
19
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::Country.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::Country) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_country), new_object_url, { :class => "btn-success", :icon => 'add', :id => 'admin_new_country' } %>
7
- <% end %>
7
+ <% end if can? :create, Spree::Country %>
8
8
 
9
9
  <table class="table" id='listing_countries' data-hook>
10
10
  <thead>
@@ -22,8 +22,8 @@
22
22
  <td><%= country.iso_name %></td>
23
23
  <td class="text-center"><%= country.states_required? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
24
24
  <td class="actions actions-2 text-right">
25
- <%= link_to_edit country, :no_text => true %>
26
- <%= link_to_delete country, :no_text => true %>
25
+ <%= link_to_edit(country, :no_text => true) if can? :edit, country %>
26
+ <%= link_to_delete(country, :no_text => true) if can? :delete, country %>
27
27
  </td>
28
28
  </tr>
29
29
  <% end %>
@@ -27,7 +27,7 @@
27
27
  <td><%= pretty_time(reimbursement.created_at) %></td>
28
28
  <td class="actions actions-1">
29
29
  <% if !reimbursement.reimbursed? %>
30
- <%= link_to_edit_url url_for([:edit, :admin, @order, reimbursement]), title: "admin_edit_#{dom_id(reimbursement)}", no_text: true %>
30
+ <%= link_to_edit_url(url_for([:edit, :admin, @order, reimbursement]), title: "admin_edit_#{dom_id(reimbursement)}", no_text: true) if can?(:edit, reimbursement) %>
31
31
  <% end %>
32
32
  </td>
33
33
  </tr>
@@ -38,10 +38,10 @@
38
38
  <td class='actions actions-2'>
39
39
  <%= button_to [:admin, return_item], { class: 'icon icon-thumbs-up icon_link no-text with-tip display-inline', params: { "return_item[acceptance_status]" => 'accepted' }, "data-action" => 'save', title: Spree.t(:accept), method: 'put' } do %>
40
40
  Spree.t(:accept)
41
- <% end %>
41
+ <% end if can?(:accept, return_item) %>
42
42
  <%= button_to [:admin, return_item], { class: 'icon icon-thumbs-down icon_link no-text with-tip display-inline', params: { "return_item[acceptance_status]" => 'rejected' }, "data-action" => 'remove', title: Spree.t(:reject), method: 'put' } do %>
43
43
  Spree.t(:reject)
44
- <% end %>
44
+ <% end if can?(:reject, return_item) %>
45
45
  </td>
46
46
  <% end %>
47
47
  </tr>
@@ -32,7 +32,7 @@
32
32
  </fieldset>
33
33
  <% end %>
34
34
 
35
- <% if !@customer_return.fully_reimbursed? && @pending_reimbursements.empty? %>
35
+ <% if !@customer_return.fully_reimbursed? && @pending_reimbursements.empty? && can?(:create, Spree::Reimbursement) %>
36
36
  <fieldset data-hook="reimbursements" class="marginb">
37
37
  <% if @customer_return.completely_decided? %>
38
38
  <%= form_for [:admin, @order, Spree::Reimbursement.new] do |f| %>
@@ -50,12 +50,12 @@
50
50
  <% end %>
51
51
 
52
52
  <fieldset data-hook="reimbursements">
53
- <legend><%= Spree::Reimbursement.model_name.human(count: :many) %></legend>
53
+ <legend><%= plural_resource_name(Spree::Reimbursement) %></legend>
54
54
  <% if @customer_return.reimbursements.any? %>
55
55
  <%= render partial: 'reimbursements_table', locals: {reimbursements: @customer_return.reimbursements} %>
56
56
  <% else %>
57
57
  <div class="alert alert-info no-objects-found">
58
- <%= Spree.t(:no_resource_found, resource: Spree::Reimbursement.model_name.human(count: :many)) %>
58
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Reimbursement)) %>
59
59
  </div>
60
60
  <% end %>
61
61
  </fieldset>