From 22a37cdc8a00dc7e874a45606fd1bfb08aa0c025 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Sat, 11 Apr 2015 22:44:32 +1000 Subject: [PATCH] Rename managed_producers_in as managed_participating_producers --- lib/open_food_network/order_cycle_permissions.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/open_food_network/order_cycle_permissions.rb b/lib/open_food_network/order_cycle_permissions.rb index f149cabaa3..445b04a734 100644 --- a/lib/open_food_network/order_cycle_permissions.rb +++ b/lib/open_food_network/order_cycle_permissions.rb @@ -33,10 +33,10 @@ module OpenFoodNetwork managed_permitted = granting(:add_to_order_cycle, to: [@coordinator], scope: managed_participating_enterprises ).pluck(:id) # Any hubs in this OC that have been granted P-OC by producers I manage in this OC - hubs_permitted = granted(:add_to_order_cycle, by: managed_producers_in(@order_cycle), scope: @order_cycle.distributors).pluck(:id) + hubs_permitted = granted(:add_to_order_cycle, by: managed_participating_producers, scope: @order_cycle.distributors).pluck(:id) # Any hubs in this OC that have granted P-OC to producers I manage in this OC - hubs_permitting = granting(:add_to_order_cycle, to: managed_producers_in(@order_cycle), scope: @order_cycle.distributors).pluck(:id) + hubs_permitting = granting(:add_to_order_cycle, to: managed_participating_producers, scope: @order_cycle.distributors).pluck(:id) # Any producers in this OC that have been granted P-OC by hubs I manage in this OC producers_permitted = granted(:add_to_order_cycle, by: managed_participating_hubs, scope: @order_cycle.suppliers).pluck(:id) @@ -135,7 +135,7 @@ module OpenFoodNetwork Spree::Variant.where(id: coordinator_variants | permitted_variants | active_variants) else # Any variants produced by MY PRODUCERS that are in this order cycle, where my producer has granted P-OC to the hub - producers = granting(:add_to_order_cycle, to: [hub], scope: managed_producers_in(@order_cycle)) + producers = granting(:add_to_order_cycle, to: [hub], scope: managed_participating_producers) permitted_variants = Spree::Variant.joins(:product).where('spree_products.supplier_id IN (?)', producers) # PLUS any of my incoming producers' variants that are already in an outgoing exchange of this hub, so things don't break @@ -171,7 +171,7 @@ module OpenFoodNetwork Spree::Variant.where(id: coordinator_variants | permitted_variants | active_variants) else # Any of my managed producers in this order cycle granted P-OC by the hub - granted_producers = granted(:add_to_order_cycle, by: [hub], scope: managed_producers_in(@order_cycle)) + granted_producers = granted(:add_to_order_cycle, by: [hub], scope: managed_participating_producers) # Any variants produced by MY PRODUCERS that are in this order cycle, where my producer has granted P-OC to the hub granting_producers = granting(:add_to_order_cycle, to: [hub], scope: granted_producers) @@ -185,14 +185,14 @@ module OpenFoodNetwork private def managed_participating_enterprises - managed_enterprises.where(id: order_cycle.suppliers | order_cycle.distributors) + managed_enterprises.where(id: @order_cycle.suppliers | @order_cycle.distributors) end def managed_participating_hubs managed_participating_enterprises.is_hub end - def managed_producers_in(order_cycle) + def managed_participating_producers managed_participating_enterprises.is_primary_producer end @@ -222,7 +222,7 @@ module OpenFoodNetwork def order_cycle_exchange_ids_distributing_my_variants # Find my producers in this order cycle - producers = managed_producers_in(@order_cycle).pluck :id + producers = managed_participating_producers.pluck :id # Any outgoing exchange where the distributor has been granted P-OC by one or more of those producers hubs = granted(:add_to_order_cycle, by: producers, scope: Enterprise.is_hub) permitted_exchanges = @order_cycle.exchanges.outgoing.where(receiver_id: hubs).pluck :id