mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Allow to remove adjustments
Managers of an order cycle and the distributor of an order are allowed to remove an adjustment from the order.
This commit is contained in:
@@ -152,6 +152,19 @@ class AbilityDecorator
|
||||
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Shipment
|
||||
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Adjustment
|
||||
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::ReturnAuthorization
|
||||
can [:destroy], Spree::Adjustment do |adjustment|
|
||||
# Sharing code with destroying a line item. This should be unified and probably applied for other actions as well.
|
||||
binding.pry
|
||||
if user.admin?
|
||||
true
|
||||
elsif adjustment.adjustable.instance_of? Spree::Order
|
||||
order = adjustment.adjustable
|
||||
user.enterprises.include?(order.distributor) || user == order.order_cycle.manager
|
||||
elsif adjustment.adjustable.instance_of? Spree::LineItem
|
||||
order = adjustment.adjustable.order
|
||||
user.enterprises.include?(order.distributor) || user == order.order_cycle.manager
|
||||
end
|
||||
end
|
||||
|
||||
can [:create], OrderCycle
|
||||
|
||||
|
||||
Reference in New Issue
Block a user