mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Load landing page distributors from enterprise groups instead of yaml file
This commit is contained in:
@@ -8,19 +8,7 @@ class HomeController < BaseController
|
||||
end
|
||||
|
||||
def temp_landing_page
|
||||
@regions = []
|
||||
|
||||
DISTRIBUTOR_CONFIG[Rails.env]["regions"].each do |region_data|
|
||||
region = {}
|
||||
region[:name] = region_data["name"]
|
||||
distributors = []
|
||||
region_data["distributors"].each do |distributor_data|
|
||||
enterprise = Enterprise.find_by_name(distributor_data["name"])
|
||||
distributors << enterprise if !enterprise.nil? && enterprise.is_distributor
|
||||
end
|
||||
region[:distributors] = distributors
|
||||
@regions << region
|
||||
end
|
||||
@groups = EnterpriseGroup.on_front_page
|
||||
|
||||
render layout: false
|
||||
end
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
%h3 WHERE WOULD YOU LIKE TO SHOP?
|
||||
%p.secondary Select your hub from the list below
|
||||
.row.landing-page-row.with-bottom-border
|
||||
- @regions.each do |region|
|
||||
- @groups.each do |group|
|
||||
.large-3.columns
|
||||
.region-header
|
||||
%h5= region[:name].upcase
|
||||
- region[:distributors].each do |distributor|
|
||||
%h5= group.name.upcase
|
||||
- group.enterprises.is_distributor.each do |distributor|
|
||||
.row.distributor-link-row
|
||||
.large-12.columns
|
||||
= succeed ',' do
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
|
||||
development: &test
|
||||
regions:
|
||||
- name: "Inner Melbourne"
|
||||
distributors:
|
||||
- name: "Green Grass"
|
||||
- name: "AusFarmers United"
|
||||
- name: "Blackburn FreeGrossers"
|
||||
- name: "Melb Uni Co-op"
|
||||
- name: "Edible garden"
|
||||
- name: "FruitAndVeg"
|
||||
- name: "MoreFreshStuff"
|
||||
|
||||
- name: "South East Melbourne"
|
||||
distributors:
|
||||
- name: "MegaFoods"
|
||||
- name: "Eco Butchers"
|
||||
- name: "Eastern Wines"
|
||||
- name: "QuickFresh"
|
||||
|
||||
- name: "Mildura"
|
||||
distributors:
|
||||
- name: "Fooderers"
|
||||
- name: "Food Local"
|
||||
|
||||
- name: "South East Gippsland"
|
||||
distributors:
|
||||
- name: "Green Food Trading Corporation"
|
||||
- name: "Better Food"
|
||||
- name: "Gippsland Poultry"
|
||||
|
||||
test:
|
||||
<<: *test
|
||||
|
||||
staging:
|
||||
regions:
|
||||
- name: "Inner Melbourne"
|
||||
distributors:
|
||||
- name: "Eaterprises (Ballantyne)"
|
||||
- name: "PepperTree Place"
|
||||
- name: "Childcare Center"
|
||||
- name: "Bulk Foods Coop"
|
||||
- name: "Sporting Club"
|
||||
|
||||
- name: "South East Melbourne"
|
||||
distributors:
|
||||
- name: "South East Food Hub"
|
||||
- name: "Primary School"
|
||||
- name: "Farmers Market"
|
||||
- name: "Neighbourhood Coop"
|
||||
|
||||
- name: "Regional Victoria"
|
||||
distributors:
|
||||
- name: "SW Food Hub"
|
||||
- name: "Farmer Coop"
|
||||
- name: "Mildura Food Centre"
|
||||
- name: "Grow Lightly (Korumburra)"
|
||||
|
||||
|
||||
production:
|
||||
regions:
|
||||
- name: "Eaterprises"
|
||||
distributors:
|
||||
- name: "Murundaka (Heidelberg)"
|
||||
- name: "Ballantyne (Thornbury)"
|
||||
- name: "O'Hea Street, Coburg"
|
||||
@@ -1,3 +0,0 @@
|
||||
# YAML distributors config
|
||||
DISTRIBUTOR_CONFIG = YAML.load(File.read(File.expand_path('../../distributors.yml', __FILE__)))
|
||||
DISTRIBUTOR_CONFIG.merge! DISTRIBUTOR_CONFIG.fetch(Rails.env, {})
|
||||
@@ -3,14 +3,18 @@ require 'spec_helper'
|
||||
feature %q{
|
||||
As a consumer
|
||||
I want to see the landing page
|
||||
So I choose a distributor
|
||||
So I can choose a distributor
|
||||
}, js: true do
|
||||
include AuthenticationWorkflow
|
||||
|
||||
background do
|
||||
# for the link to be visible, it would also have to be in 'distributors.yml'
|
||||
FactoryGirl.create(:address, :address1 => "25 Myrtle Street", :zipcode => "3153", :city => "Bayswater")
|
||||
FactoryGirl.create(:distributor_enterprise, :name => "Green Grass", :address => Spree::Address.find_by_zipcode("3153"))
|
||||
d1 = create(:distributor_enterprise, name: 'Murandaka')
|
||||
d2 = create(:distributor_enterprise, name: 'Ballantyne')
|
||||
d3 = create(:distributor_enterprise, name: "O'Hea Street")
|
||||
|
||||
eg1 = create(:enterprise_group, name: 'Group One', on_front_page: true, enterprises: [d1, d2])
|
||||
eg2 = create(:enterprise_group, name: 'Group Two', on_front_page: true, enterprises: [d3])
|
||||
|
||||
visit root_path
|
||||
end
|
||||
|
||||
@@ -40,13 +44,18 @@ feature %q{
|
||||
end
|
||||
|
||||
describe "hub list" do
|
||||
it "should display hub link" do
|
||||
page.should have_link "Green Grass"
|
||||
it "should display grouped hubs" do
|
||||
page.should have_content 'GROUP ONE'
|
||||
page.should have_link 'Murandaka'
|
||||
page.should have_link 'Ballantyne'
|
||||
|
||||
page.should have_content 'GROUP TWO'
|
||||
page.should have_link "O'Hea Street"
|
||||
end
|
||||
|
||||
it "should link to the hub page" do
|
||||
click_on "Green Grass"
|
||||
page.should have_content "CART"
|
||||
click_on 'Murandaka'
|
||||
page.should have_content 'CART'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user