From 4809237eccfc542d9902d1afb0b3b92c6a5ebd00 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 12 Apr 2017 15:17:42 +1000 Subject: [PATCH] Fast fail `set_order_cycles` if distributor not ready --- app/controllers/base_controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index e5535b71ad..7f9a0f2df6 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -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