mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Auto-merge from CI [skip ci]
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,11 +144,27 @@ 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
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
/ replace "code[erb-loud]:contains('button t(:update)')"
|
||||
|
||||
= button t(:update_and_recalculate_fees), 'icon-refresh'
|
||||
Reference in New Issue
Block a user