mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Extract removal of unauthorized OC exchange attributes to method
This commit is contained in:
@@ -79,13 +79,7 @@ module OpenFoodNetwork
|
||||
|
||||
def update_exchange(sender_id, receiver_id, incoming, attrs = {})
|
||||
exchange = @order_cycle.exchanges.where(sender_id: sender_id, receiver_id: receiver_id, incoming: incoming).first
|
||||
|
||||
unless manages_coordinator? || manager_for(exchange)
|
||||
attrs.delete :enterprise_fee_ids
|
||||
attrs.delete :pickup_time
|
||||
attrs.delete :pickup_instructions
|
||||
attrs.delete :tag_list
|
||||
end
|
||||
remove_unauthorized_exchange_attributes(exchange, attrs)
|
||||
|
||||
if permission_for exchange
|
||||
variant_ids = attrs.delete :variant_ids
|
||||
@@ -98,6 +92,15 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
def remove_unauthorized_exchange_attributes(exchange, exchange_attrs)
|
||||
unless manages_coordinator? || manager_for(exchange)
|
||||
exchange_attrs.delete :enterprise_fee_ids
|
||||
exchange_attrs.delete :pickup_time
|
||||
exchange_attrs.delete :pickup_instructions
|
||||
exchange_attrs.delete :tag_list
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_untouched_exchanges
|
||||
if manages_coordinator?
|
||||
untouched_exchanges.each(&:destroy)
|
||||
|
||||
Reference in New Issue
Block a user