Allow managers to remove line items from order

Managers of an order cycle and the distributor of an order are allowed to
remove a line item from the order.
This commit is contained in:
Maikel Linke
2015-05-01 14:49:34 +10:00
parent b7bac326bd
commit e6e063670c
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
Spree::Admin::LineItemsController.class_eval do
private
def load_order
@order = Spree::Order.find_by_number!(params[:order_id])
authorize! :update, @order
end
end

View File

@@ -144,6 +144,9 @@ class AbilityDecorator
end
can [:admin, :bulk_management], Spree::Order if user.admin? || user.enterprises.any?(&:is_distributor)
can [:admin, :create], Spree::LineItem
can [:destroy], Spree::LineItem do |item|
user.admin? || user.enterprises.include?(order.distributor) || user == order.order_cycle.manager
end
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Payment
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Shipment