As participating Hub, I cannot edit incoming exchanges despite being granted P-OC by the producer

This commit is contained in:
Rob Harrington
2015-04-09 13:41:43 +10:00
parent 69004ac477
commit c28ebf63ab
2 changed files with 10 additions and 18 deletions

View File

@@ -152,7 +152,13 @@ module OpenFoodNetwork
# Find the variants that a user can edit within incoming exchanges
def editable_variants_for_incoming_exchanges_between(producer, coordinator, options={})
visible_variants_for_incoming_exchanges_between(producer, coordinator, options)
return Spree::Variant.where("1=0") unless options[:order_cycle]
if managed_enterprises.pluck(:id).include?(producer.id) || managed_enterprises.pluck(:id).include?(coordinator.id)
# All variants belonging to the producer
Spree::Variant.joins(:product).where('spree_products.supplier_id = (?)', producer)
else
Spree::Variant.where("1=0")
end
end
# Find the variants that a user is permitted see within outgoing exchanges