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,21 +1,22 @@
1
1
  <ul data-hook="admin_configurations_sidebar_menu" class="collapse nav nav-pills nav-stacked" id="sidebar-configuration">
2
- <%= configurations_sidebar_menu_item Spree.t(:general_settings), edit_admin_general_settings_path %>
3
- <%= configurations_sidebar_menu_item Spree.t(:tax_categories), admin_tax_categories_path %>
4
- <%= configurations_sidebar_menu_item Spree.t(:tax_rates), admin_tax_rates_path %>
5
- <%= configurations_sidebar_menu_item Spree.t(:zones), admin_zones_path %>
6
- <%= configurations_sidebar_menu_item Spree.t(:countries), admin_countries_path %>
2
+ <%= configurations_sidebar_menu_item(Spree.t(:general_settings), spree.edit_admin_general_settings_path) if can? :manage, Spree::Config %>
3
+ <%= configurations_sidebar_menu_item(Spree.t(:tax_categories), spree.admin_tax_categories_path) if can? :manage, Spree::TaxCategory %>
4
+ <%= configurations_sidebar_menu_item(Spree.t(:tax_rates), spree.admin_tax_rates_path) if can? :manage, Spree::TaxRate %>
5
+ <%= configurations_sidebar_menu_item(Spree.t(:zones), spree.admin_zones_path) if can? :manage, Spree::Zone %>
6
+ <%= configurations_sidebar_menu_item(Spree.t(:countries), spree.admin_countries_path) if can? :manage, Spree::Country %>
7
7
 
8
8
  <% if country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) || Spree::Country.first %>
9
- <%= configurations_sidebar_menu_item Spree.t(:states), admin_country_states_path(country) %>
9
+ <%= configurations_sidebar_menu_item(Spree.t(:states), spree.admin_country_states_path(country)) if can? :manage, Spree::Country %>
10
10
  <% end %>
11
11
 
12
- <%= configurations_sidebar_menu_item Spree.t(:payment_methods), admin_payment_methods_path %>
13
- <%= configurations_sidebar_menu_item Spree.t(:shipping_methods), admin_shipping_methods_path %>
14
- <%= configurations_sidebar_menu_item Spree.t(:shipping_categories), admin_shipping_categories_path %>
15
- <%= configurations_sidebar_menu_item Spree.t(:stock_transfers), admin_stock_transfers_path %>
16
- <%= configurations_sidebar_menu_item Spree.t(:stock_locations), spree.admin_stock_locations_path %>
17
- <%= configurations_sidebar_menu_item Spree.t(:analytics_trackers), admin_trackers_path %>
18
- <%= configurations_sidebar_menu_item Spree.t(:refund_reasons), admin_refund_reasons_path %>
19
- <%= configurations_sidebar_menu_item Spree.t(:reimbursement_types), admin_reimbursement_types_path %>
20
- <%= configurations_sidebar_menu_item Spree.t(:return_authorization_reasons), admin_return_authorization_reasons_path %>
21
- </ul>
12
+ <%= configurations_sidebar_menu_item(Spree.t(:payment_methods), spree.admin_payment_methods_path) if can? :manage, Spree::PaymentMethod %>
13
+ <%= configurations_sidebar_menu_item(Spree.t(:shipping_methods), spree.admin_shipping_methods_path) if can? :manage, Spree::ShippingMethod %>
14
+ <%= configurations_sidebar_menu_item(Spree.t(:shipping_categories), spree.admin_shipping_categories_path) if can? :manage, Spree::ShippingCategory %>
15
+ <%= configurations_sidebar_menu_item(Spree.t(:stock_transfers), spree.admin_stock_transfers_path) if can? :manage, Spree::StockTransfer %>
16
+ <%= configurations_sidebar_menu_item(Spree.t(:stock_locations), spree.admin_stock_locations_path) if can? :manage, Spree::StockLocation %>
17
+ <%= configurations_sidebar_menu_item(Spree.t(:analytics_trackers), spree.admin_trackers_path) if can? :manage, Spree::Tracker %>
18
+ <%= configurations_sidebar_menu_item(Spree.t(:refund_reasons), spree.admin_refund_reasons_path) if can? :manage, Spree::RefundReason %>
19
+ <%= configurations_sidebar_menu_item(Spree.t(:reimbursement_types), spree.admin_reimbursement_types_path) if can? :manage, Spree::ReimbursementType %>
20
+ <%= configurations_sidebar_menu_item(Spree.t(:return_authorization_reasons), spree.admin_return_authorization_reasons_path) if can? :manage, Spree::ReturnAuthorizationReason %>
21
+ <%= configurations_sidebar_menu_item(Spree.t(:roles), spree.admin_roles_path) if can? :manage, Spree::Role %>
22
+ </ul>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::ShippingCategory.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::ShippingCategory) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_shipping_category), new_object_url, :class => "btn-success", :icon => 'add' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::ShippingCategory %>
8
8
 
9
9
  <% if @shipping_categories.any? %>
10
10
  <table class="table">
@@ -19,8 +19,8 @@
19
19
  <tr id="<%= spree_dom_id shipping_category %>" data-hook="category_row">
20
20
  <td><%= shipping_category.name %></td>
21
21
  <td class="actions actions-2 text-right">
22
- <%= link_to_edit shipping_category, :no_text => true %>
23
- <%= link_to_delete shipping_category, :no_text => true %>
22
+ <%= link_to_edit(shipping_category, :no_text => true) if can? :edit, shipping_category %>
23
+ <%= link_to_delete(shipping_category, :no_text => true) if can? :edit, shipping_category %>
24
24
  </td>
25
25
  </tr>
26
26
  <% end %>
@@ -28,7 +28,7 @@
28
28
  </table>
29
29
  <% else %>
30
30
  <div class="alert alert-info no-objects-found">
31
- <%= Spree.t(:no_resource_found, resource: Spree::ShippingCategory.model_name.human(count: :many)) %>,
32
- <%= link_to Spree.t(:add_one), new_object_url %>!
31
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::ShippingCategory)) %>,
32
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::ShippingCategory %>!
33
33
  </div>
34
34
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::ShippingMethod.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::ShippingMethod) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_shipping_method), new_object_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_shipping_method_link' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::ShippingMethod %>
8
8
 
9
9
  <% if @shipping_methods.any? %>
10
10
  <table class="table" id='listing_shipping_methods'>
@@ -25,8 +25,8 @@
25
25
  <td><%= shipping_method.calculator.description %></td>
26
26
  <td class="text-center"><%= shipping_method.display_on.blank? ? Spree.t(:both) : Spree.t(shipping_method.display_on) %></td>
27
27
  <td data-hook="admin_shipping_methods_index_row_actions" class="actions actions-2 text-right">
28
- <%= link_to_edit shipping_method, :no_text => true %>
29
- <%= link_to_delete shipping_method, :no_text => true %>
28
+ <%= link_to_edit(shipping_method, :no_text => true) if can? :edit, shipping_method %>
29
+ <%= link_to_delete(shipping_method, :no_text => true) if can? :delete, shipping_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::ShippingMethod.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::ShippingMethod)) %>,
38
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::PaymentMethod %>!
39
39
  </div>
40
40
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: 'State Changes' } %>
2
2
 
3
3
  <% content_for :page_title do %>
4
- <%= Spree::StateChange.model_name.human(count: :many) %>
4
+ <%= plural_resource_name(Spree::StateChange) %>
5
5
  <% end %>
6
6
 
7
7
  <% if @state_changes.any? %>
@@ -14,8 +14,8 @@
14
14
  <td><%= state.name %></td>
15
15
  <td class="text-center"><%= state.abbr %></td>
16
16
  <td class="actions actions-2 text-right">
17
- <%= link_to_edit state, :no_text => true %>
18
- <%= link_to_delete state, :no_text => true %>
17
+ <%= link_to_edit(state, :no_text => true) if can? :edit, state %>
18
+ <%= link_to_delete(state, :no_text => true) if can? :delete, state %>
19
19
  </td>
20
20
  </tr>
21
21
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::State.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::State) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_state), new_admin_country_state_url(@country), { :class => "btn-success", :icon => 'add', :id => 'new_state_link' } %>
7
- <% end %>
7
+ <% end if can? :create, Spree::State %>
8
8
 
9
9
  <div data-hook="country" class="form-group">
10
10
  <%= label_tag :country, Spree.t(:country) %>
@@ -86,10 +86,9 @@
86
86
  </div>
87
87
 
88
88
  <% content_for :head do %>
89
- <%= javascript_include_tag 'spree/backend/address_states.js' %>
90
- <%= javascript_tag do -%>
89
+ <%= javascript_tag do %>
91
90
  $(document).ready(function(){
92
91
  $('span#country .select2').on('change', function() { update_state(''); });
93
92
  });
94
- <% end -%>
93
+ <% end %>
95
94
  <% end %>
@@ -1,11 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::StockLocation.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::StockLocation) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_stock_location), new_object_url, { :class => "btn-success", :icon => 'add', :id => 'admin_new_stock_location' } %>
7
- <%= button_link_to Spree.t(:new_stock_transfer), new_admin_stock_transfer_path, { :icon => 'add', :class => 'btn-primary' } %>
8
- <% end %>
7
+ <% end if can? :create, Spree::StockLocation %>
9
8
 
10
9
  <% if @stock_locations.any? %>
11
10
  <table class="table" id='listing_stock_locations' data-hook>
@@ -27,8 +26,8 @@
27
26
  <td><span class="state <%= state(stock_location) %>"><%= Spree.t(state(stock_location)) %></span></td>
28
27
  <td><%= link_to Spree.t(:stock_movements), admin_stock_location_stock_movements_path(stock_location.id) %> </td>
29
28
  <td class="actions actions-2 text-center">
30
- <%= link_to_edit stock_location, :no_text => true %>
31
- <%= link_to_delete stock_location, :no_text => true %>
29
+ <%= link_to_edit(stock_location, :no_text => true) if can? :create, stock_location %>
30
+ <%= link_to_delete(stock_location, :no_text => true) if can? :create, stock_location %>
32
31
  </td>
33
32
  </tr>
34
33
  <% end %>
@@ -36,7 +35,7 @@
36
35
  </table>
37
36
  <% else %>
38
37
  <div class="alert alert-info no-objects-found">
39
- <%= Spree.t(:no_resource_found, resource: Spree::StockLocation.model_name.human(count: :many)) %>,
40
- <%= link_to Spree.t(:add_one), new_object_url %>!
38
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::StockLocation)) %>,
39
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::StockLocation %>!
41
40
  </div>
42
41
  <% end %>
@@ -35,7 +35,7 @@
35
35
  </table>
36
36
  <% else %>
37
37
  <div class="alert alert-info no-objects-found">
38
- <%= Spree.t(:no_resource_found, resource: Spree::StockMovement.model_name.human(count: :many)) %>,
38
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::StockMovement)) %>,
39
39
  <%= link_to Spree.t(:add_one), spree.new_admin_stock_location_stock_movement_path(@stock_location) %>!
40
40
  </div>
41
41
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::StockTransfer.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::StockTransfer) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
- <%= button_link_to Spree.t(:new_stock_transfer), new_object_url, { :icon => 'add', :class => 'btn-success' } %>
7
- <% end %>
6
+ <%= button_link_to Spree.t(:new_stock_transfer), new_admin_stock_transfer_path, { :icon => 'add', :class => 'btn-success' } %>
7
+ <% end if can? :create, Spree::StockTransfer %>
8
8
 
9
9
  <div data-hook="admin_orders_index_search" class="well">
10
10
  <fieldset>
@@ -74,8 +74,8 @@
74
74
  </table>
75
75
  <% else %>
76
76
  <div class="alert alert-info no-objects-found">
77
- <%= Spree.t(:no_resource_found, resource: Spree::StockTransfer.model_name.human(count: :many)) %>,
78
- <%= link_to Spree.t(:add_one), new_object_url %>!
77
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::StockTransfer)) %>,
78
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::StockTransfer %>!
79
79
  </div>
80
80
  <% end %>
81
81
 
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::StockTransfer.model_name.human(count: :many) %> (<%= @stock_transfer.number %>)
2
+ <%= plural_resource_name(Spree::StockTransfer) %> (<%= @stock_transfer.number %>)
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_stock_transfer), new_admin_stock_transfer_path, { :icon => 'add', :class => 'btn-success' } %>
7
- <% end %>
7
+ <% end if can? :create, Spree::StockTransfer %>
8
8
 
9
9
  <fieldset>
10
10
  <legend><%= Spree.t(:stock_transfer) %></legend>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::TaxCategory.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::TaxCategory) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
- <%= button_link_to Spree.t(:new_tax_category), new_object_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_tax_categories_link' %>
7
- <% end %>
6
+ <%= button_link_to Spree.t(:new_tax_category), new_object_url, class: "btn-success", icon: 'add', id: 'admin_new_tax_categories_link' %>
7
+ <% end if can? :create, Spree::TaxCategory %>
8
8
 
9
9
  <% if @tax_categories.any? %>
10
10
  <table class="table" id='listing_tax_categories' data-hook>
@@ -28,15 +28,15 @@
28
28
  <td><%= tax_category.description %></td>
29
29
  <td><%= tax_category.is_default? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
30
30
  <td class="actions actions-2 text-right">
31
- <%= link_to_edit tax_category, :no_text => true %>
32
- <%= link_to_delete tax_category, :no_text => true %>
31
+ <%= link_to_edit(tax_category, no_text: true) if can? :edit, tax_category %>
32
+ <%= link_to_delete(tax_category, no_text: true) if can? :delete, tax_category %>
33
33
  </tr>
34
34
  <% end %>
35
35
  </tbody>
36
36
  </table>
37
37
  <% else %>
38
38
  <div class="alert alert-info no-objects-found">
39
- <%= Spree.t(:no_resource_found, resource: Spree::TaxCategory.model_name.human(count: :many)) %>,
40
- <%= link_to Spree.t(:add_one), new_object_url %>!
39
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::TaxCategory)) %>,
40
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::TaxCategory %>!
41
41
  </div>
42
42
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::TaxRate.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::TaxRate) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_tax_rate), new_object_url, class: "btn-success", icon: 'add' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::TaxRate %>
8
8
 
9
9
  <% if @tax_rates.any? %>
10
10
  <table class="table">
@@ -31,8 +31,8 @@
31
31
  <td><%=tax_rate.show_rate_in_label? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
32
32
  <td><%=tax_rate.calculator.to_s %></td>
33
33
  <td class="actions actions-2 text-right">
34
- <%= link_to_edit tax_rate, no_text: true %>
35
- <%= link_to_delete tax_rate, no_text: true %>
34
+ <%= link_to_edit(tax_rate, no_text: true) if can? :edit, tax_rate %>
35
+ <%= link_to_delete(tax_rate, no_text: true) if can? :delete, tax_rate %>
36
36
  </td>
37
37
  </tr>
38
38
  <% end %>
@@ -40,7 +40,7 @@
40
40
  </table>
41
41
  <% else %>
42
42
  <div class="alert alert-info no-objects-found">
43
- <%= Spree.t(:no_resource_found, resource: Spree::TaxRate.model_name.human(count: :many)) %>,
44
- <%= link_to Spree.t(:add_one), new_object_url %>!
43
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::TaxRate)) %>,
44
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::TaxRate %>!
45
45
  </div>
46
46
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree::Taxonomy.model_name.human(count: :many) %>
2
+ <%= plural_resource_name(Spree::Taxonomy) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  <% else %>
14
14
  <div class="alert alert-info no-objects-found">
15
- <%= Spree.t(:no_resource_found, resource: Spree::Taxonomy.model_name.human(count: :many)) %>,
15
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Taxonomy)) %>,
16
16
  <%= link_to Spree.t(:add_one), new_object_url %>!
17
17
  </div>
18
18
  <% end %>
@@ -15,7 +15,7 @@
15
15
  <% end %>
16
16
 
17
17
  <% content_for :head do %>
18
- <%= javascript_tag do -%>
18
+ <%= javascript_tag do %>
19
19
  $(document).ready(function() {
20
20
  var field = $('#permalink_part'),
21
21
  target = $('#permalink_part_display'),
@@ -26,5 +26,5 @@
26
26
  target.text(permalink_part_default + $(this).val());
27
27
  });
28
28
  });
29
- <% end -%>
29
+ <% end %>
30
30
  <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_tracker), new_object_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_tracker_link' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::Tracker %>
8
8
 
9
9
  <% if @trackers.any? %>
10
10
  <table class="table">
@@ -27,8 +27,8 @@
27
27
  <td><%= tracker.analytics_id %></td>
28
28
  <td class="text-center"><%= tracker.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
29
29
  <td class="actions text-right">
30
- <%= link_to_edit tracker, :no_text => true %>
31
- <%= link_to_delete tracker, :no_text => true %>
30
+ <%= link_to_edit(tracker, :no_text => true) if can? :edit, tracker %>
31
+ <%= link_to_delete(tracker, :no_text => true) if can? :delete, tracker %>
32
32
  </td>
33
33
  </tr>
34
34
  <% end %>
@@ -36,7 +36,7 @@
36
36
  </table>
37
37
  <% else %>
38
38
  <div class="alert alert-warning">
39
- <%= Spree.t(:no_resource_found, resource: Spree::Tracker.model_name.human(count: :many)) %>,
40
- <%= link_to Spree.t(:add_one), new_object_url %>!
39
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Tracker)) %>,
40
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::Tracker %>!
41
41
  </div>
42
42
  <% end %>
@@ -1,16 +1,16 @@
1
1
  <% content_for :sidebar do %>
2
2
  <ul class="nav nav-pills nav-stacked" data-hook="admin_user_tab_options">
3
3
  <li<%== ' class="active"' if current == :account %>>
4
- <%= link_to_with_icon 'user', Spree.t(:"admin.user.account"), edit_admin_user_path(@user) %>
4
+ <%= link_to_with_icon 'user', Spree.t(:"admin.user.account"), spree.edit_admin_user_path(@user) %>
5
5
  </li>
6
6
  <li<%== ' class="active"' if current == :address %>>
7
- <%= link_to_with_icon 'user', Spree.t(:"admin.user.addresses"), addresses_admin_user_path(@user) %>
7
+ <%= link_to_with_icon 'user', Spree.t(:"admin.user.addresses"), spree.addresses_admin_user_path(@user) %>
8
8
  </li>
9
9
  <li<%== ' class="active"' if current == :orders %>>
10
- <%= link_to_with_icon 'shopping-cart', Spree.t(:"admin.user.orders"), orders_admin_user_path(@user) %>
10
+ <%= link_to_with_icon 'shopping-cart', Spree.t(:"admin.user.orders"), spree.orders_admin_user_path(@user) %>
11
11
  </li>
12
12
  <li<%== ' class="active"' if current == :items %>>
13
- <%= link_to_with_icon 'edit', Spree.t(:"admin.user.items"), items_admin_user_path(@user) %>
13
+ <%= link_to_with_icon 'edit', Spree.t(:"admin.user.items"), spree.items_admin_user_path(@user) %>
14
14
  </li>
15
15
  </ul>
16
16
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_title do %>
2
- <%= link_to "#{@user.email}", edit_admin_user_url(@user) %> / <%= Spree.t(:editing_resource, resource: Spree::Address.model_name.human(count: :many)) %>
2
+ <%= link_to "#{@user.email}", edit_admin_user_url(@user) %> / <%= Spree.t(:editing_resource, resource: plural_resource_name(Spree::Address)) %>
3
3
  <% end %>
4
4
 
5
5
  <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :address } %>
@@ -16,7 +16,7 @@
16
16
  <%= render :partial => 'addresses_form', :locals => { :f => f } %>
17
17
 
18
18
  <div class="form-actions text-center well" data-hook="admin_user_edit_form_button">
19
- <%= render :partial => 'spree/admin/shared/edit_resource_links', :locals => { :collection_url => admin_users_url } %>
19
+ <%= render :partial => 'spree/admin/shared/edit_resource_links', :locals => { :collection_url => spree.admin_users_url } %>
20
20
  </div>
21
21
  <% end %>
22
22
  </div>
@@ -18,11 +18,11 @@
18
18
  </div>
19
19
 
20
20
  <div data-hook="admin_user_edit_form">
21
- <%= form_for [:admin, @user], as: :user, url: admin_user_url(@user), method: :put do |f| %>
21
+ <%= form_for [:admin, @user], as: :user, url: spree.admin_user_url(@user), method: :put do |f| %>
22
22
  <%= render :partial => 'form', :locals => { :f => f } %>
23
23
 
24
24
  <div data-hook="admin_user_edit_form_button">
25
- <%= render :partial => 'spree/admin/shared/edit_resource_links', :locals => { :collection_url => admin_users_url } %>
25
+ <%= render :partial => 'spree/admin/shared/edit_resource_links', :locals => { :collection_url => spree.admin_users_url } %>
26
26
  </div>
27
27
  <% end %>
28
28
  </div>
@@ -12,7 +12,7 @@
12
12
 
13
13
  <% content_for :table_filter do %>
14
14
  <div data-hook="admin_users_index_search">
15
- <%= search_form_for [:admin, @search], url: admin_users_url do |f| %>
15
+ <%= search_form_for [:admin, @search], url: spree.admin_users_url do |f| %>
16
16
  <div class="form-group">
17
17
  <%= f.label Spree.t(:email) %>
18
18
  <%= f.text_field :email_cont, class: "form-control js-quick-search-target" %>
@@ -53,7 +53,7 @@
53
53
  </table>
54
54
  <% else %>
55
55
  <div class="alert alert-info no-objects-found">
56
- <%= Spree.t(:no_resource_found, resource: Spree::Order.model_name.human(count: :many)) %>,
56
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Order)) %>,
57
57
  <%= link_to Spree.t(:add_one), spree.new_admin_order_path %>!
58
58
  </div>
59
59
  <% end %>
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <div data-hook="admin_user_new_form">
10
- <%= form_for [:admin, @user], url: admin_users_url, method: :post do |f| %>
10
+ <%= form_for [:admin, @user], url: spree.admin_users_url, method: :post do |f| %>
11
11
  <%= render :partial => 'form', :locals => { :f => f } %>
12
12
 
13
13
  <div data-hook="admin_user_new_form_buttons">
@@ -40,7 +40,7 @@
40
40
  </table>
41
41
  <% else %>
42
42
  <div class="alert alert-info no-objects-found">
43
- <%= Spree.t(:no_resource_found, resource: Spree::Order.model_name.human(count: :many)) %>,
43
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Order)) %>,
44
44
  <%= link_to Spree.t(:add_one), spree.new_admin_order_path %>!
45
45
  </div>
46
46
  <% end %>
@@ -17,14 +17,16 @@
17
17
  <% @variants.each do |variant| %>
18
18
  <tr id="<%= spree_dom_id variant %>" <%= 'style="color:red;"' if variant.deleted? %> data-hook="variants_row">
19
19
  <td class="move-handle">
20
- <span class="icon icon-move handle"></span>
20
+ <% if can? :edit, variant %>
21
+ <span class="icon icon-move handle"></span>
22
+ <% end %>
21
23
  </td>
22
24
  <td><%= variant.options_text %></td>
23
25
  <td><%= variant.display_price.to_html %></td>
24
26
  <td><%= variant.sku %></td>
25
27
  <td class="actions actions-2 text-right">
26
- <%= link_to_edit(variant, :no_text => true) unless variant.deleted? %>
27
- <%= link_to_delete(variant, :no_text => true) unless variant.deleted? %>
28
+ <%= link_to_edit(variant, :no_text => true) if can?(:edit, variant) && !variant.deleted? %>
29
+ <%= link_to_delete(variant, :no_text => true) if can?(:destroy, variant) && !variant.deleted? %>
28
30
  </td>
29
31
  </tr>
30
32
  <% end %>
@@ -37,21 +39,23 @@
37
39
  </table>
38
40
  <% else %>
39
41
  <div class="no-objects-found alert alert-info">
40
- <%= Spree.t(:no_resource_found, resource: Spree::Variant.model_name.human(count: :many)) %>,
41
- <%= link_to Spree.t(:add_one), spree.new_admin_product_variant_path(@product) %>!
42
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Variant)) %>,
43
+ <%= link_to(Spree.t(:add_one), spree.new_admin_product_variant_path(@product)) if can? :create, Spree::Variant %>!
42
44
  </div>
43
45
  <% end %>
44
46
 
45
47
  <% if @product.empty_option_values? %>
46
- <p class='first_add_option_types no-objects-found' data-hook="first_add_option_types">
47
- <%= Spree.t(:to_add_variants_you_must_first_define) %>
48
- <%= link_to Spree.t(:option_types), admin_product_url(@product) %>
49
- <%= Spree.t(:and) %>
50
- <%= link_to Spree.t(:option_values), admin_option_types_url %>
51
- </p>
48
+ <% if can?(:create, Spree::OptionType) && can?(:create, Spree::OptionValue) %>
49
+ <p class='first_add_option_types no-objects-found' data-hook="first_add_option_types">
50
+ <%= Spree.t(:to_add_variants_you_must_first_define) %>
51
+ <%= link_to(Spree.t(:option_types), spree.admin_product_url(@product)) %>
52
+ <%= Spree.t(:and) %>
53
+ <%= link_to Spree.t(:option_values), spree.admin_option_types_url %>
54
+ </p>
55
+ <% end %>
52
56
  <% else %>
53
57
  <% content_for :page_actions do %>
54
- <%= button_link_to Spree.t(:new_variant), new_admin_product_variant_url(@product), { :remote => :true, :icon => 'add', :'data-update' => 'new_variant', :class => 'btn-success', id: 'new_var_link' } %>
55
- <%= button_link_to (@deleted.blank? ? Spree.t(:show_deleted) : Spree.t(:show_active)), admin_product_variants_url(@product, :deleted => @deleted.blank? ? "on" : "off"), { :class => 'btn-default', :icon => 'filter' } %>
58
+ <%= button_link_to(Spree.t(:new_variant), spree.new_admin_product_variant_url(@product), { :remote => :true, :icon => 'add', :'data-update' => 'new_variant', :class => 'btn-success', id: 'new_var_link' }) if can? :create, Spree::Variant %>
59
+ <%= button_link_to (@deleted.blank? ? Spree.t(:show_deleted) : Spree.t(:show_active)), spree.admin_product_variants_url(@product, :deleted => @deleted.blank? ? "on" : "off"), { :class => 'btn-default', :icon => 'filter' } %>
56
60
  <% end %>
57
61
  <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <% content_for :page_actions do %>
6
6
  <%= button_link_to Spree.t(:new_zone), new_object_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_zone_link' %>
7
- <% end %>
7
+ <% end if can? :create, Spree::Zone %>
8
8
 
9
9
  <%= paginate @zones %>
10
10
 
@@ -27,8 +27,8 @@
27
27
  <td><%= zone.description %></td>
28
28
  <td><%= zone.default_tax? ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
29
29
  <td class="actions actions-2 text-right">
30
- <%=link_to_edit zone, :no_text => true %>
31
- <%=link_to_delete zone, :no_text => true %>
30
+ <%= link_to_edit(zone, :no_text => true) if can? :edit, zone %>
31
+ <%= link_to_delete(zone, :no_text => true) if can? :delete, zone %>
32
32
  </td>
33
33
  </tr>
34
34
  <% end %>
@@ -36,8 +36,8 @@
36
36
  </table>
37
37
  <% else %>
38
38
  <div class="alert alert-info no-objects-found">
39
- <%= Spree.t(:no_resource_found, resource: Spree::Zone.model_name.human(count: :many)) %>,
40
- <%= link_to Spree.t(:add_one), new_object_url %>!
39
+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Zone)) %>,
40
+ <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::Zone %>!
41
41
  </div>
42
42
  <% end %>
43
43
 
data/config/routes.rb CHANGED
@@ -164,6 +164,7 @@ Spree::Core::Engine.add_routes do
164
164
 
165
165
  resources :trackers
166
166
  resources :payment_methods
167
+ resources :roles
167
168
 
168
169
  resources :users do
169
170
  member do