Revert order permissions changes

This commit is contained in:
Matt-Yorkley
2021-02-13 16:11:49 +00:00
parent 7924865ff8
commit 6c00fe44ae

View File

@@ -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