mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Locking line_items on API update
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
Spree::Api::LineItemsController.class_eval do
|
||||
after_filter :apply_enterprise_fees, only: :update
|
||||
|
||||
around_filter :lock, only: :update
|
||||
|
||||
private
|
||||
|
||||
def lock
|
||||
authorize! :read, order
|
||||
@line_item = order.line_items.find(params[:id])
|
||||
@line_item.with_lock do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def apply_enterprise_fees
|
||||
authorize! :read, order
|
||||
order.update_distribution_charge!
|
||||
|
||||
Reference in New Issue
Block a user