diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 27a335d9c4..4414dd4ece 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -1,6 +1,9 @@ class EnterprisesController < BaseController + layout "darkswarm" helper Spree::ProductsHelper include OrderCyclesHelper + before_filter :set_order_cycles, only: :shop + before_filter :load_active_distributors, only: :shop def index @enterprises = Enterprise.all @@ -66,8 +69,6 @@ class EnterprisesController < BaseController order_cycle_options = OrderCycle.active.with_distributor(distributor) order.order_cycle = order_cycle_options.first if order_cycle_options.count == 1 order.save! - - redirect_to main_app.shop_path end def check_permalink @@ -82,4 +83,15 @@ class EnterprisesController < BaseController end end end + + private + + def set_order_cycles + @order_cycles = OrderCycle.with_distributor(@distributor).active + + # And default to the only order cycle if there's only the one + if @order_cycles.count == 1 + current_order(true).set_order_cycle! @order_cycles.first + end + end end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index c0c2c225a5..c350791158 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -3,10 +3,9 @@ require 'open_food_network/scope_product_to_hub' class ShopController < BaseController layout "darkswarm" before_filter :require_distributor_chosen - before_filter :set_order_cycles - before_filter :load_active_distributors def show + redirect_to main_app.enterprise_shop_path(current_distributor) end def products @@ -36,15 +35,6 @@ class ShopController < BaseController private - def set_order_cycles - @order_cycles = OrderCycle.with_distributor(@distributor).active - - # And default to the only order cycle if there's only the one - if @order_cycles.count == 1 - current_order(true).set_order_cycle! @order_cycles.first - end - end - def products_for_shop if current_order_cycle current_order_cycle. diff --git a/app/views/shop/show.html.haml b/app/views/enterprises/shop.html.haml similarity index 100% rename from app/views/shop/show.html.haml rename to app/views/enterprises/shop.html.haml diff --git a/config/routes.rb b/config/routes.rb index 912741322e..0d5d034df4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,7 @@ Openfoodnetwork::Application.routes.draw do get :shop # old world end end + get '/:id/shop', to: 'enterprises#shop', as: 'enterprise_shop' devise_for :enterprise, controllers: { confirmations: 'enterprise_confirmations' }