Adding group siblings to the shop page

This commit is contained in:
Will Marshall
2014-03-13 14:50:06 +11:00
parent 179844b5cf
commit 3370865a01
6 changed files with 49 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ class Shop::ShopController < BaseController
def show
# All suppliers of all our products
@producers = Exchange.where(receiver_id: @distributor.id).map{ |ex| ex.variants.map {|v| v.product.supplier }}.flatten.uniq
@groups = current_distributor.groups
end
def products
@@ -14,7 +15,6 @@ class Shop::ShopController < BaseController
.products_distributed_by(current_distributor).andand
.select { |p| p.has_stock_for_distribution?(current_order_cycle, current_distributor) }.andand
.sort_by {|p| p.name }
render json: "", status: 404
end
end

View File

@@ -0,0 +1,13 @@
%section
%p.title.avenir{"data-section-title" => ""}
%a{href: "#groups"} Our Groups
.content{"data-section-content" => ""}
%ul
- for group in @groups
%li
%h4= group.name
%ul
- for sibling in group.enterprises.except(current_distributor)
%li
%a{"data-reveal-id" => "sibling_details_#{sibling.id}"}
= sibling.name

View File

@@ -0,0 +1,19 @@
- for producer in @producers
.reveal-modal{id: "producer_details_#{producer.id}"}
%h2
%img.left{src: producer.logo.url(:thumb)}
= producer.name
%img.about.right{src: producer.promo_image.url(:large)}
= producer.description.andand.html_safe
%a.close-reveal-modal &#215;
- for group in @groups
- for sibling in group.enterprises.except(current_distributor)
.reveal-modal{id: "sibling_details_#{sibling.id}"}
%h2
%img.left{src: sibling.logo.url(:thumb)}
= sibling.name
%img.about.right{src: sibling.promo_image.url(:large)}
= sibling.description.andand.html_safe
%a.close-reveal-modal &#215;

View File

@@ -1,9 +0,0 @@
- for producer in @producers
.reveal-modal{id: "producer_details_#{producer.id}"}
%h2
%img.left{src: producer.logo.url(:thumb)}
= producer.name
%img.about.right{src: producer.promo_image.url(:large)}
= producer.description.andand.html_safe
%a.close-reveal-modal &#215;

View File

@@ -11,8 +11,8 @@
%strong {{ order_cycle.orders_close_at | date_in_words }}
= render partial: "shop/details"
-# This partial generates the producer detail popovers
= render partial: "shop/shop/producer_details"
-# This partial generates the producer and group sibling modals
= render partial: "shop/shop/modals"
%tabs
.row
@@ -20,12 +20,7 @@
= render 'shop/shop/about_us'
= render 'shop/shop/producers'
%section
%p.title.avenir{"data-section-title" => ""}
%a{href: "#groups"} Our Groups
.content{"data-section-content" => ""}
%p Coming Soon
= render 'shop/shop/groups'
%section
%p.title.avenir{"data-section-title" => ""}

View File

@@ -14,6 +14,18 @@ describe Shop::ShopController do
controller.stub(:current_distributor).and_return d
end
describe "Tabs and plumbing" do
it "builds a list of sibling distributors" do
sibling1 = create(:distributor_enterprise)
sibling2 = create(:distributor_enterprise)
g1 = create(:enterprise_group, on_front_page: true, enterprises: [d, sibling1])
g2 = create(:enterprise_group, on_front_page: true, enterprises: [d, sibling2])
spree_get :show
assigns[:groups].sort.should == [g1, g2].sort
end
end
describe "Selecting order cycles" do
it "should select an order cycle when only one order cycle is open" do
oc1 = create(:order_cycle, distributors: [d])
@@ -42,7 +54,7 @@ describe Shop::ShopController do
it "should return the order cycle details when the oc is selected" do
oc1 = create(:order_cycle, distributors: [d])
oc2 = create(:order_cycle, distributors: [d])
spree_post :order_cycle, order_cycle_id: oc2.id
response.should be_success
response.body.should have_content oc2.id