mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Altering permissions for exchanges, so the exchange is visible to managers of at least one of the enterprises invloved
This commit is contained in:
@@ -55,8 +55,9 @@ module OpenFoodNetwork
|
||||
|
||||
# Find the exchanges of an order cycle that an admin can manage
|
||||
def order_cycle_exchanges(order_cycle)
|
||||
enterprises = managed_and_related_enterprises_with :add_to_order_cycle
|
||||
order_cycle.exchanges.to_enterprises(enterprises).from_enterprises(enterprises)
|
||||
ids = order_cycle_exchange_ids_involving_my_enterprises(order_cycle)
|
||||
|
||||
Exchange.where(id: ids, order_cycle_id: order_cycle)
|
||||
end
|
||||
|
||||
def managed_products
|
||||
@@ -103,5 +104,10 @@ module OpenFoodNetwork
|
||||
def related_enterprise_products
|
||||
Spree::Product.where('supplier_id IN (?)', related_enterprises_with(:manage_products))
|
||||
end
|
||||
|
||||
def order_cycle_exchange_ids_involving_my_enterprises(order_cycle)
|
||||
# Any exchanges that my managed enterprises are involved in directly
|
||||
order_cycle.exchanges.involving(managed_enterprises).pluck :id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user