mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Revert order permissions changes
This commit is contained in:
@@ -63,36 +63,28 @@ module Permissions
|
||||
|
||||
# Any orders placed through any hub that I manage
|
||||
def managed_orders_where_values
|
||||
query = Spree::Order.
|
||||
where(distributor_id: @permissions.managed_enterprises.select("enterprises.id"))
|
||||
|
||||
apply_where_clause(query).reduce(:and)
|
||||
Spree::Order.
|
||||
where(distributor_id: @permissions.managed_enterprises.select("enterprises.id")).
|
||||
where_clause.__send__(:predicates).
|
||||
reduce(:and)
|
||||
end
|
||||
|
||||
# Any order that is placed through an order cycle one of my managed enterprises coordinates
|
||||
def coordinated_orders_where_values
|
||||
query = Spree::Order.
|
||||
where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id))
|
||||
|
||||
apply_where_clause(query).reduce(:and)
|
||||
Spree::Order.
|
||||
where(order_cycle_id: @permissions.coordinated_order_cycles.select(:id)).
|
||||
where_clause.__send__(:predicates).
|
||||
reduce(:and)
|
||||
end
|
||||
|
||||
def produced_orders_where_values
|
||||
query = Spree::Order.with_line_items_variants_and_products_outer.
|
||||
Spree::Order.with_line_items_variants_and_products_outer.
|
||||
where(
|
||||
distributor_id: granted_distributor_ids,
|
||||
spree_products: { supplier_id: enterprises_with_associated_orders }
|
||||
)
|
||||
|
||||
apply_where_clause(query).reduce(:and)
|
||||
end
|
||||
|
||||
def apply_where_clause(query)
|
||||
if ENV['DEPENDENCIES_NEXT']
|
||||
query.where_clause.__send__(:predicates)
|
||||
else
|
||||
query.where_values
|
||||
end
|
||||
).
|
||||
where_clause.__send__(:predicates).
|
||||
reduce(:and)
|
||||
end
|
||||
|
||||
def enterprises_with_associated_orders
|
||||
|
||||
Reference in New Issue
Block a user