mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user