mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Altering shop page routing so that shop url is copy-and-pastable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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' }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user