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
@@ -1,13 +1,13 @@
1
1
  <%= render :partial => 'spree/admin/shared/order_tabs', :locals => { :current => Spree.t(:customer_returns) } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <% if @order.shipments.any?(&:shipped?) %>
4
+ <% if @order.shipments.any?(&:shipped?) && can?(:create, Spree::CustomerReturn) %>
5
5
  <%= button_link_to Spree.t(:new_customer_return), spree.new_admin_order_customer_return_path(@order), icon: 'add', class: 'btn-success' %>
6
6
  <% end %>
7
7
  <% end %>
8
8
 
9
9
  <% content_for :page_title do %>
10
- / <%= Spree::CustomerReturn.model_name.human(count: :many) %>
10
+ / <%= plural_resource_name(Spree::CustomerReturn) %>
11
11
  <% end %>
12
12
 
13
13
  <% if @order.shipments.any?(&:shipped?) %>
@@ -37,7 +37,7 @@
37
37
  <% end %>
38
38
  </td>
39
39
  <td class='actions actions-1' data-hook="admin_orders_customer_returns_index_row_actions">
40
- <%= link_to_edit_url edit_admin_order_customer_return_path(@order, customer_return), title: "admin_edit_#{dom_id(customer_return)}", no_text: true %>
40
+ <%= link_to_edit_url(edit_admin_order_customer_return_path(@order, customer_return), title: "admin_edit_#{dom_id(customer_return)}", no_text: true) if can?(:edit, customer_return) %>
41
41
  </td>
42
42
  </tr>
43
43
  <% end %>
@@ -45,8 +45,8 @@
45
45
  </table>
46
46
  <% else %>
47
47
  <div class="alert alert-info no-objects-found">
48
- <%= Spree.t(:no_resource_found, resource: Spree::CustomerReturn.model_name.human(count: :many)) %>,
49
- <%= link_to Spree.t(:add_one), spree.new_admin_order_customer_return_path(@order) %>!
48
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::CustomerReturn)) %>,
49
+ <%= link_to(Spree.t(:add_one), spree.new_admin_order_customer_return_path(@order)) if can?(:create, Spree::CustomerReturn) %>!
50
50
  </div>
51
51
  <% end %>
52
52
  <% else %>
@@ -44,7 +44,7 @@
44
44
  <div class="form-actions" data-hook="buttons">
45
45
  <%= button Spree.t(:create), 'save' %>
46
46
  <span class="or"><%= Spree.t(:or) %></span>
47
- <%= button_link_to Spree.t('actions.cancel'), admin_order_customer_returns_url(@order), :icon => 'delete' %>
47
+ <%= button_link_to Spree.t('actions.cancel'), spree.admin_order_customer_returns_url(@order), :icon => 'delete' %>
48
48
  </div>
49
49
  </fieldset>
50
50
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <%= Spree.t(:general_settings) %>
3
3
  <% end %>
4
4
 
5
- <%= form_tag admin_general_settings_path, :method => :put do %>
5
+ <%= form_tag admin_general_settings_path, method: :put do %>
6
6
  <div id="preferences" data-hook>
7
7
 
8
8
  <fieldset class="general no-border-top">
@@ -13,7 +13,7 @@
13
13
  <div class="form-group" data-hook="admin_general_setting_input_name">
14
14
  <%= f.label :name %>
15
15
  <%= f.text_field :name, class: 'form-control' %>
16
- </div>
16
+ </div>
17
17
  </div>
18
18
 
19
19
  <div class="col-md-6">
@@ -29,7 +29,7 @@
29
29
  <div class="form-group" data-hook="admin_general_setting_input_meta_keywords">
30
30
  <%= f.label :meta_keywords %>
31
31
  <%= f.text_field :meta_keywords, class: 'form-control' %>
32
- </div>
32
+ </div>
33
33
  </div>
34
34
 
35
35
  <div class="col-md-6">
@@ -75,14 +75,14 @@
75
75
  type = Spree::Config.preference_type(key) %>
76
76
  <div class="checkbox">
77
77
  <%= label_tag key do %>
78
- <%= preference_field_tag(key, Spree::Config[key], :type => type) %>
78
+ <%= preference_field_tag(key, Spree::Config[key], type: type) %>
79
79
  <%= Spree.t(key) %>
80
80
  <% end %>
81
81
  </div>
82
- <% end %>
82
+ <% end %>
83
83
  </div>
84
84
  </div>
85
-
85
+
86
86
  <%#-------------------------------------------------%>
87
87
  <%# Clear cache %>
88
88
  <%#-------------------------------------------------%>
@@ -97,10 +97,10 @@
97
97
  </div>
98
98
  <div data-hook="general_settings_clear_cache">
99
99
  <%= button Spree.t(:clear_cache), 'ok', 'button', id: "clear_cache" %>
100
- </div>
100
+ </div>
101
101
  </div>
102
102
  </div>
103
-
103
+
104
104
  </div>
105
105
  <div class="col-md-6">
106
106
 
@@ -127,7 +127,7 @@
127
127
  <div class="form-actions" data-hook="buttons">
128
128
  <%= button Spree.t('actions.update'), 'save' %>
129
129
  <span class="or"><%= Spree.t(:or) %></span>
130
- <%= button_link_to Spree.t('actions.cancel'), edit_admin_general_settings_url, :icon => 'delete' %>
130
+ <%= button_link_to Spree.t('actions.cancel'), edit_admin_general_settings_url, icon: 'delete' %>
131
131
  </div>
132
132
 
133
133
  </fieldset>
@@ -22,7 +22,7 @@
22
22
  <div class="form-actions" data-hook="buttons">
23
23
  <%= button Spree.t('actions.update'), 'save' %>
24
24
  <span class="or"><%= Spree.t(:or) %></span>
25
- <%= button_link_to Spree.t('actions.cancel'), admin_product_images_url(@product), :id => 'cancel_link', :icon => 'delete' %>
25
+ <%= button_link_to Spree.t('actions.cancel'), spree.admin_product_images_url(@product), :id => 'cancel_link', :icon => 'delete' %>
26
26
  </div>
27
27
  </div>
28
28
  </div>
@@ -1,14 +1,14 @@
1
1
  <%= render partial: 'spree/admin/shared/product_tabs', locals: { current: 'Images' } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <%= button_link_to Spree.t(:new_image), new_admin_product_image_url(@product), { class: "btn-success", icon: 'add', id: 'new_image_link' } %>
4
+ <%= button_link_to(Spree.t(:new_image), spree.new_admin_product_image_url(@product), { class: "btn-success", icon: 'add', id: 'new_image_link' }) if can? :create, Spree::Image %>
5
5
  <% end %>
6
6
 
7
7
  <% has_variants = @product.has_variants? %>
8
8
 
9
9
  <% unless @product.variant_images.any? %>
10
10
  <div class="alert alert-warning">
11
- <%= Spree.t(:no_resource_found, resource: Spree::Image.model_name.human(count: :many)) %>.
11
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Image)) %>.
12
12
  </div>
13
13
  <% else %>
14
14
  <table class="table sortable" data-hook="images_table" data-sortable-link="<%= update_positions_admin_product_images_url(@product) %>">
@@ -33,7 +33,9 @@
33
33
  <% (@product.variant_images).each do |image| %>
34
34
  <tr id="<%= spree_dom_id image %>" data-hook="images_row">
35
35
  <td class="move-handle text-center">
36
- <span class="icon icon-move handle"></span>
36
+ <% if can? :edit, image %>
37
+ <span class="icon icon-move handle"></span>
38
+ <% end %>
37
39
  </td>
38
40
  <td class="image">
39
41
  <%= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product) %>
@@ -43,8 +45,8 @@
43
45
  <% end %>
44
46
  <td><%= image.alt %></td>
45
47
  <td class="actions actions-2 text-right">
46
- <%= link_to_with_icon 'edit', Spree.t(:edit), edit_admin_product_image_url(@product, image), class: 'btn btn-primary btn-sm', no_text: true, data: { action: 'edit' } %>
47
- <%= link_to_delete image, { url: admin_product_image_url(@product, image), no_text: true } %>
48
+ <%= link_to_with_icon('edit', Spree.t(:edit), spree.edit_admin_product_image_url(@product, image), class: 'btn btn-primary btn-sm', no_text: true, data: { action: 'edit' }) if can? :edit, image %>
49
+ <%= link_to_delete(image, { url: spree.admin_product_image_url(@product, image), no_text: true }) if can? :destroy, image %>
48
50
  </td>
49
51
  </tr>
50
52
  <% end %>
@@ -11,7 +11,7 @@
11
11
  <div class="form-actions" data-hook="buttons">
12
12
  <%= button Spree.t('actions.update'), 'save' %>
13
13
  <span class="or"><%= Spree.t(:or) %></span>
14
- <%= button_link_to Spree.t('actions.cancel'), admin_product_images_url(@product), icon: 'delete', id: 'cancel_link' %>
14
+ <%= button_link_to Spree.t('actions.cancel'), spree.admin_product_images_url(@product), icon: 'delete', id: 'cancel_link' %>
15
15
  </div>
16
16
  </fieldset>
17
17
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::OptionType.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::OptionType) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
@@ -38,7 +38,7 @@
38
38
  </table>
39
39
  <% else %>
40
40
  <div class="alert alert-info no-objects-found">
41
- <%= Spree.t(:no_resource_found, resource: Spree::OptionType.model_name.human(count: :many)) %>,
41
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::OptionType)) %>,
42
42
  <%= link_to Spree.t(:add_one), new_object_url %>!
43
43
  </div>
44
44
  <% end %>
@@ -27,26 +27,26 @@
27
27
 
28
28
  <% if order.line_items.exists? %>
29
29
  <div class="alert alert-success" id="order-total" data-hook="order_details_total">
30
- <%= Spree.t(:order_total) %>:
30
+ <%= Spree.t(:order_total) %>:
31
31
  <strong class="order-total">
32
32
  <%= order.display_total %>
33
33
  </strong>
34
34
  </div>
35
35
  <% end %>
36
36
 
37
- <%= javascript_tag do -%>
37
+ <%= javascript_tag do %>
38
38
  var order_number = '<%= @order.number %>';
39
39
  var shipments = [];
40
40
 
41
41
  <% @order.shipments.each do |shipment| %>
42
42
  shipments.push(
43
43
  <%== shipment.as_json(
44
- :root => false,
44
+ :root => false,
45
45
  :only => [
46
46
  :id, :tracking, :number, :state, :stock_location_id
47
47
  ], :include => [
48
48
  :inventory_units, :stock_location
49
- ]).to_json
49
+ ]).to_json
50
50
  %>
51
51
  );
52
52
  <% end %>
@@ -14,7 +14,7 @@
14
14
  </td>
15
15
  <td data-hook="admin_order_form_line_item_actions" class="actions">
16
16
  <%= link_to_delete f.object, {
17
- url: admin_order_line_item_url(@order.number, f.object),
17
+ url: spree.admin_order_line_item_url(@order.number, f.object),
18
18
  no_text: true
19
19
  } %>
20
20
  </td>
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  <% end %>
28
28
 
29
- <%= javascript_tag do -%>
29
+ <%= javascript_tag do %>
30
30
  var order_number = '<%= @order.number %>';
31
31
  var shipments = [];
32
32
 
@@ -35,5 +35,5 @@
35
35
  <% end %>
36
36
 
37
37
  <%= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:js] %>
38
- <% end -%>
38
+ <% end %>
39
39
  </div>
@@ -13,8 +13,12 @@
13
13
  <div class="col-md-8">
14
14
  <div class="form-group">
15
15
  <%= f.label :email, Spree.t(:email) %>
16
- <%= f.email_field :email, class: 'form-control' %>
17
- </div>
16
+ <% if can? :edit, @order.user %>
17
+ <%= f.email_field :email, class: 'form-control' %>
18
+ <% else %>
19
+ <p><%= @order.user.email %></p>
20
+ <% end %>
21
+ </div>
18
22
  </div>
19
23
  <div class="col-md-4">
20
24
  <div class="form-group">
@@ -43,9 +47,9 @@
43
47
  <% end %>
44
48
  </div>
45
49
  </div>
46
- </div>
50
+ </div>
47
51
  </div>
48
-
52
+
49
53
  </div>
50
54
 
51
55
  <div class="row">
@@ -56,9 +60,13 @@
56
60
  </div>
57
61
 
58
62
  <div class="panel-body">
59
- <%= f.fields_for :bill_address do |ba_form| %>
60
- <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "billing" } %>
61
- <% end %>
63
+ <% if can? :edit, @order.user %>
64
+ <%= f.fields_for :bill_address do |ba_form| %>
65
+ <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "billing" } %>
66
+ <% end %>
67
+ <% else %>
68
+ <%= render partial: 'spree/admin/shared/address', locals: { address: @order.bill_address } %>
69
+ <% end %>
62
70
  </div>
63
71
  </div>
64
72
  </div>
@@ -69,26 +77,28 @@
69
77
  <h1 class="panel-title"><%= Spree.t(:shipping_address) %></h1>
70
78
  </div>
71
79
  <div class="panel-body">
72
- <%= f.fields_for :ship_address do |sa_form| %>
73
- <div class="form-group">
74
- <span data-hook="use_billing">
75
- <%= check_box_tag 'order[use_billing]', '1', ((@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address.same_as?(@order.ship_address)) %>
76
- <%= label_tag 'order[use_billing]', Spree.t(:use_billing_address) %>
77
- </span>
78
- </div>
80
+ <% if can? :edit, @order.user %>
81
+ <%= f.fields_for :ship_address do |sa_form| %>
82
+ <div class="form-group">
83
+ <span data-hook="use_billing">
84
+ <%= check_box_tag 'order[use_billing]', '1', ((@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address.same_as?(@order.ship_address)) %>
85
+ <%= label_tag 'order[use_billing]', Spree.t(:use_billing_address) %>
86
+ </span>
87
+ </div>
79
88
 
80
- <%= render partial: 'spree/admin/shared/address_form', locals: { f: sa_form, type: 'shipping' } %>
89
+ <%= render partial: 'spree/admin/shared/address_form', locals: { f: sa_form, type: 'shipping' } %>
90
+ <% end %>
91
+ <% else %>
92
+ <%= render partial: 'spree/admin/shared/address', locals: { address: @order.ship_address } %>
81
93
  <% end %>
82
94
  </div>
83
95
  </div>
84
96
  </div>
85
97
  </div>
86
98
 
87
- <div class="form-actions" data-hook="buttons">
88
- <%= button Spree.t('actions.update'), 'save' %>
89
- </div>
90
-
91
- <% content_for :head do %>
92
- <%= javascript_include_tag 'spree/backend/address_states.js' %>
99
+ <% if can? :edit, @order.user %>
100
+ <div class="form-actions" data-hook="buttons">
101
+ <%= button Spree.t('actions.update'), 'save' %>
102
+ </div>
93
103
  <% end %>
94
104
  </div>
@@ -4,21 +4,23 @@
4
4
  / <%= Spree.t(:customer_details) %>
5
5
  <% end %>
6
6
 
7
- <div id="select-customer" class="panel panel-default" data-hook>
8
- <div class="panel-heading">
9
- <h1 class="panel-title">
10
- <%= Spree.t(:customer_search) %>
11
- </h1>
7
+ <% if can? :edit, @order.user %>
8
+ <div id="select-customer" class="panel panel-default" data-hook>
9
+ <div class="panel-heading">
10
+ <h1 class="panel-title">
11
+ <%= Spree.t(:customer_search) %>
12
+ </h1>
13
+ </div>
14
+ <div class="panel-body">
15
+ <%= hidden_field_tag :customer_search, nil, class: 'error-message' %>
16
+ <%= render partial: "spree/admin/orders/customer_details/autocomplete", formats: :js %>
17
+ </div>
12
18
  </div>
13
- <div class="panel-body">
14
- <%= hidden_field_tag :customer_search, nil, class: 'error-message' %>
15
- <%= render partial: "spree/admin/orders/customer_details/autocomplete", formats: :js %>
16
- </div>
17
- </div>
19
+ <% end %>
18
20
 
19
21
  <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @order } %>
20
22
 
21
- <%= form_for @order, url: admin_order_customer_url(@order) do |f| %>
23
+ <%= form_for @order, url: spree.admin_order_customer_url(@order) do |f| %>
22
24
  <%= render 'form', f: f %>
23
25
  <% end %>
24
26
 
@@ -10,14 +10,14 @@
10
10
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: 'Shipments' } %>
11
11
 
12
12
  <% content_for :page_title do %>
13
- / <%= Spree::Shipment.model_name.human(count: :many) %>
13
+ / <%= plural_resource_name(Spree::Shipment) %>
14
14
  <% end %>
15
15
 
16
16
  <div data-hook="admin_order_edit_header">
17
17
  <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @order } %>
18
18
  </div>
19
19
 
20
- <% if @order.payments.exists? && @order.considered_risky? %>
20
+ <% if @order.payments.valid.any? && @order.considered_risky? %>
21
21
  <%= render 'spree/admin/orders/risk_analysis', latest_payment: @order.payments.valid.last %>
22
22
  <% end %>
23
23
 
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::Order.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::Order) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_order), new_admin_order_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_order' %>
7
- <% end if can? :edit, Spree::Order.new %>
7
+ <% end if can? :create, Spree::Order %>
8
8
 
9
9
  <% content_for :table_filter do %>
10
10
  <div data-hook="admin_orders_index_search">
@@ -171,7 +171,7 @@
171
171
  <tbody>
172
172
  <% @orders.each do |order| %>
173
173
  <tr data-hook="admin_orders_index_rows" class="state-<%= order.state.downcase %> <%= cycle('odd', 'even') %>">
174
- <td><%= l (@show_only_completed ? order.completed_at : order.created_at).to_date %></td>
174
+ <td><%= l (@show_only_completed ? order.completed_at : order.created_at).try(&:to_date) %></td>
175
175
  <td><%= link_to order.number, edit_admin_order_path(order) %></td>
176
176
  <td>
177
177
  <span class="label label-<%= order.considered_risky ? 'considered_risky' : 'considered_safe' %>">
@@ -216,8 +216,8 @@
216
216
  </table>
217
217
  <% else %>
218
218
  <div class="alert alert-info no-objects-found">
219
- <%= Spree.t(:no_resource_found, resource: Spree::Order.model_name.human(count: :many)) %>,
220
- <%= link_to Spree.t(:add_one), new_admin_order_url %>!
219
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Order)) %>,
220
+ <%= link_to(Spree.t(:add_one), new_admin_order_url) if can? :create, Spree::Order %>!
221
221
  </div>
222
222
  <% end %>
223
223
 
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::PaymentMethod.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::PaymentMethod) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_payment_method), new_object_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_payment_methods_link' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::PaymentMethod %>
8
8
 
9
9
  <% if @payment_methods.any? %>
10
10
  <table class="table" id='listing_payment_methods'>
@@ -25,8 +25,8 @@
25
25
  <td class="text-center"><%= method.display_on.blank? ? Spree.t(:both) : Spree.t(method.display_on) %></td>
26
26
  <td class="text-center"><%= method.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
27
27
  <td data-hook="admin_payment_methods_index_row_actions" class="actions actions-2 text-right">
28
- <%= link_to_edit method, :no_text => true %>
29
- <%= link_to_delete method, :no_text => true %>
28
+ <%= link_to_edit(method, :no_text => true) if can? :edit, method %>
29
+ <%= link_to_delete(method, :no_text => true) if can? :delete, method %>
30
30
  </td>
31
31
  </tr>
32
32
  <% end %>
@@ -34,7 +34,7 @@
34
34
  </table>
35
35
  <% else %>
36
36
  <div class="alert alert-info no-objects-found">
37
- <%= Spree.t(:no_resource_found, resource: Spree::PaymentMethod.model_name.human(count: :many)) %>,
38
- <%= link_to Spree.t(:add_one), new_object_url %>!
37
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::PaymentMethod)) %>,
38
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::PaymentMethod %>!
39
39
  </div>
40
40
  <% end %>
@@ -26,9 +26,9 @@
26
26
  <td class="actions actions-2 text-center">
27
27
  <% payment.actions.each do |action| %>
28
28
  <% if action == 'credit' %>
29
- <%= link_to_with_icon 'refund', Spree.t(:refund), new_admin_order_payment_refund_path(@order, payment), no_text: true, class: "btn btn-default btn-sm" %>
29
+ <%= link_to_with_icon('refund', Spree.t(:refund), new_admin_order_payment_refund_path(@order, payment), no_text: true, class: "btn btn-default btn-sm") if can?(:create, Spree::Refund) %>
30
30
  <% else %>
31
- <%= link_to_with_icon action, Spree.t(action), fire_admin_order_payment_path(@order, payment, e: action), method: :put, no_text: true, data: { action: action }, class: "btn btn-default btn-sm" %>
31
+ <%= link_to_with_icon(action, Spree.t(action), fire_admin_order_payment_path(@order, payment, e: action), method: :put, no_text: true, data: { action: action }, class: "btn btn-default btn-sm") if can?(action, payment) %>
32
32
  <% end %>
33
33
  <% end %>
34
34
  </td>
@@ -1,7 +1,7 @@
1
1
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: "Payments" } %>
2
2
 
3
3
  <% content_for :page_actions do %>
4
- <% if @order.outstanding_balance? %>
4
+ <% if @order.outstanding_balance? && can?(:create, Spree::Payment) %>
5
5
  <span id="new_payment_section">
6
6
  <%= button_link_to Spree.t(:new_payment), new_admin_order_payment_url(@order), class: "btn-success", icon: 'add' %>
7
7
  </span>
@@ -20,6 +20,6 @@
20
20
  <% else %>
21
21
  <div class="alert alert-info">
22
22
  <%= Spree.t(:cannot_create_payment_without_payment_methods) %>
23
- <%= link_to Spree.t(:please_define_payment_methods), admin_payment_methods_url %>
23
+ <%= link_to Spree.t(:please_define_payment_methods), spree.admin_payment_methods_url %>
24
24
  </div>
25
25
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <tr class="product_property fields" id="spree_<%= dom_id(f.object) %>" data-hook="product_property">
2
2
  <td class="move-handle">
3
- <% if f.object.persisted? %>
3
+ <% if f.object.persisted? && can?(:edit, f.object) %>
4
4
  <span class="icon icon-move handle"></span>
5
5
  <%= f.hidden_field :id %>
6
6
  <% end %>
@@ -12,7 +12,7 @@
12
12
  <%= f.text_field :value, class: 'form-control' %>
13
13
  </td>
14
14
  <td class="actions actions-1">
15
- <% if f.object.persisted? %>
15
+ <% if f.object.persisted? && can?(:destroy, f.object) %>
16
16
  <%= link_to_delete f.object, no_text: true %>
17
17
  <% end %>
18
18
  </td>
@@ -2,11 +2,11 @@
2
2
  <%= render 'spree/admin/shared/error_messages', :target => @product %>
3
3
 
4
4
  <% content_for :page_actions do %>
5
- <%= button_link_to Spree.t(:add_product_properties), "javascript:;", { :icon => 'add', :'data-target' => "tbody#product_properties", :class => 'btn-success spree_add_fields' } %>
5
+ <%= button_link_to(Spree.t(:add_product_properties), "javascript:;", { :icon => 'add', :'data-target' => "tbody#product_properties", :class => 'btn-success spree_add_fields' }) %>
6
6
  <span class="js-new-ptype-link"><%= button_link_to Spree.t(:select_from_prototype), available_admin_prototypes_url, { :icon => 'properties', :remote => true, 'data-update' => 'prototypes', :class => 'btn-default' } %></span>
7
- <% end %>
7
+ <% end if can? :create, Spree::ProductProperty %>
8
8
 
9
- <%= form_for @product, :url => admin_product_url(@product), :method => :put do |f| %>
9
+ <%= form_for @product, :url => spree.admin_product_url(@product), :method => :put do |f| %>
10
10
  <fieldset>
11
11
  <div id="prototypes" data-hook></div>
12
12
 
@@ -25,13 +25,13 @@
25
25
  </tbody>
26
26
  </table>
27
27
 
28
- <%= render 'spree/admin/shared/edit_resource_links' %>
28
+ <%= render('spree/admin/shared/edit_resource_links') if can? :update, Spree::ProductProperty %>
29
29
 
30
30
  <%= hidden_field_tag 'clear_product_properties', 'true' %>
31
31
  </fieldset>
32
32
  <% end %>
33
33
 
34
- <%= javascript_tag do -%>
34
+ <%= javascript_tag do %>
35
35
  var properties = <%= raw(@properties.to_json) %>;
36
36
  $('#product_properties').on('keydown', 'input.autocomplete', function() {
37
37
  already_auto_completed = $(this).is('ac_input');
@@ -40,4 +40,4 @@
40
40
  $(this).focus();
41
41
  }
42
42
  });
43
- <% end -%>
43
+ <% end %>
@@ -6,7 +6,7 @@
6
6
  <span class="caret"></span>
7
7
  </button>
8
8
  <ul class="dropdown-menu" role="menu" data-hook="taxon_product_dropdown">
9
- <li><a href="javascript:;" class="edit-product js-edit-product"><%= Spree.t(:edit_product) %></a></li>
9
+ <li><a href="javascript:;" class="edit-product js-edit-product"><%= Spree.t(:edit) %></a></li>
10
10
  <li><a href="javascript:;" class="delete-product js-delete-product"><%= Spree.t(:delete_from_taxon) %></a></li>
11
11
  </ul>
12
12
  </div>