mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Fast fail set_order_cycles if distributor not ready
This commit is contained in:
@@ -23,11 +23,14 @@ class BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def set_order_cycles
|
||||
unless @distributor.ready_for_checkout?
|
||||
@order_cycles = OrderCycle.where('false')
|
||||
return
|
||||
end
|
||||
|
||||
@order_cycles = OrderCycle.with_distributor(@distributor).active
|
||||
.order(@distributor.preferred_shopfront_order_cycle_order)
|
||||
|
||||
ensure_shop_ready
|
||||
|
||||
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor, "FilterOrderCycles", current_customer.andand.tag_list)
|
||||
applicator.filter!(@order_cycles)
|
||||
|
||||
@@ -36,9 +39,4 @@ class BaseController < ApplicationController
|
||||
current_order(true).set_order_cycle! @order_cycles.first
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_shop_ready
|
||||
# Don't display order cycles if shop is not ready for checkout
|
||||
@order_cycles = {} unless @distributor.ready_for_checkout?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user