From dd1b3311d72b91c73b88af9a28079ef8799f3c36 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Mon, 6 Jan 2014 15:23:21 +1100 Subject: [PATCH] Removing all the old order populator stuff --- app/assets/images/matte.png | Bin 0 -> 1434 bytes .../javascripts/darkswarm/overrides.js.coffee | 20 ++++++++++++++++++ app/controllers/shop_controller.rb | 2 ++ app/controllers/suburbs_controller.rb | 2 +- app/views/shop/_products.html.haml | 2 +- app/views/shop/show.html.haml | 7 ++++-- spec/controllers/shop_controller_spec.rb | 17 +++++++++++++++ spec/features/consumer/shopping_spec.rb | 19 +++++++++++++++++ 8 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 app/assets/images/matte.png create mode 100644 app/assets/javascripts/darkswarm/overrides.js.coffee diff --git a/app/assets/images/matte.png b/app/assets/images/matte.png new file mode 100644 index 0000000000000000000000000000000000000000..845642cab2f758d59b7ac21ec37cf38cccab3944 GIT binary patch literal 1434 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqS!2~4FYNzf3Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS=07?@QuLn2Bde0{8v^Kf6`()~Xj@TAnpKdC8`Lf!&sHg;q@=(~U%$M( zT(8_%FTW^V-_X+15@d#vkuFe$ZgFK^Nn(X=Ua>OF1ees}+T7#d8#0MoBXEYLU9GXQxBrqI_HztY@Xxa#7Ppj3o=u^L<)Qdy9y zACy|0Us{w5jJPyqkW~d%&PAz-CHX}m`T04pPz=b(FUc>?$S+WE4mMNJ@J&q4%mWE% zf_3=%T6yLbmn7yTr+T{BDgn*V%gju%GBL9-GP86xH#0N=hP$h=g_*0XtGSV}g`<(9 zp|hJ4Os`9Ra%paAUI|QZ3PP_1PQ9SSkXrz>*(J3ovn(~mttdZN0qkk3Ox$iU#c3W? zZwhX=08Eakt zacfG@&7xZl0(WkDt1l=J`~N?1UC|?vGL7bmtS_cr*!WU3w6cHRmg17{UwD?DWPfgR z{_`rGdY$Q;*1cZ$y5|0OoAvLj@0svA1$nLg`uO95_n)PWa&L>d8qPnz^YyM{Gv0j^ za1xlf=l=T@_jAk^205^r#k))l;R<|fA#--#>wEdzbxwB}dOa=|V35)1>A0TCSzuY4 zdpV%YvSJ_ql}$R=Uz>(UIm^$uz~ptBJ#zP5Kh4tJcQtO2 zopJr@S2b1(>v!K>G;wlbqx_D(?mf)4JsWT4ggyEBv0}~aW3Se);_~S}>ZG0eIW+XJ zd;rtbb<4LG$|#C`zFGH2k<*~TdD2zprv+RB9bO&vR;@N0cC4OzHtVcg@n63w6QSX%OHqSei^4@e-6bx@ZH~IHH0}01i`;fIZ{waU zqac>c8+ItJj?Z{{{?Mx2bJN$~>-k^(zn)csq4Z4Ul*)aJeLmdKI;Vst0L%0n AfdBvi literal 0 HcmV?d00001 diff --git a/app/assets/javascripts/darkswarm/overrides.js.coffee b/app/assets/javascripts/darkswarm/overrides.js.coffee new file mode 100644 index 0000000000..6db1441f08 --- /dev/null +++ b/app/assets/javascripts/darkswarm/overrides.js.coffee @@ -0,0 +1,20 @@ +Foundation.libs.section.toggle_active = (e)-> + $this = $(this) + self = Foundation.libs.section + region = $this.parent() + content = $this.siblings(self.settings.content_selector) + section = region.parent() + settings = $.extend({}, self.settings, self.data_options(section)) + prev_active_region = section.children(self.settings.region_selector).filter("." + self.settings.active_class) + + #for anchors inside [data-section-title] + e.preventDefault() if not settings.deep_linking and content.length > 0 + e.stopPropagation() #do not catch same click again on parent + unless region.hasClass(self.settings.active_class) + prev_active_region.removeClass self.settings.active_class + region.addClass self.settings.active_class + #force resize for better performance (do not wait timer) + self.resize region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true + else if not settings.one_up# and (self.small(section) or self.is_vertical_nav(section) or self.is_horizontal_nav(section) or self.is_accordion(section)) + region.removeClass self.settings.active_class + settings.callback section diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index 33457dd7a9..36d3504c5a 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -5,6 +5,8 @@ class ShopController < BaseController before_filter :set_order_cycles 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 end def products diff --git a/app/controllers/suburbs_controller.rb b/app/controllers/suburbs_controller.rb index 21c4040d22..4fe73f29d8 100644 --- a/app/controllers/suburbs_controller.rb +++ b/app/controllers/suburbs_controller.rb @@ -2,4 +2,4 @@ class SuburbsController < ActionController::Base def index @suburbs = Suburb.matching(params[:term]).order(:name).limit(8) end -end \ No newline at end of file +end diff --git a/app/views/shop/_products.html.haml b/app/views/shop/_products.html.haml index 245f6eee80..e7fbf55055 100644 --- a/app/views/shop/_products.html.haml +++ b/app/views/shop/_products.html.haml @@ -12,7 +12,7 @@ %tbody{"ng-repeat" => "product in data.products "} %tr.product %td - %img{src: "{{ product.master.images[0].small_url }}"} + -#%img{src: "{{ product.master.images[0].small_url }}"} -#{{product.master.images[0].alt}} %td %h5 diff --git a/app/views/shop/show.html.haml b/app/views/shop/show.html.haml index 2c4532478c..2e874ed521 100644 --- a/app/views/shop/show.html.haml +++ b/app/views/shop/show.html.haml @@ -5,7 +5,8 @@ %h4 = @distributor.name %location= @distributor.address.city - %small Change location + %small + %a{href: "/"} Change location = render partial: "shop/order_cycles" -#%description @@ -23,7 +24,9 @@ %p.title.avenir{"data-section-title" => ""} %a{href: "#producers"} Our Producers .content{"data-section-content" => ""} - %p Content of section 2. + %ul + - for producer in @producers + %li= producer.name %section %p.title.avenir{"data-section-title" => ""} diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 8f355c259b..5f2a677679 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -8,6 +8,7 @@ describe ShopController do response.should redirect_to root_path end + describe "with a distributor in place" do before do controller.stub(:current_distributor).and_return d @@ -56,6 +57,22 @@ describe ShopController do end + describe "producers/suppliers" do + let(:supplier) { create(:supplier_enterprise) } + let(:product) { create(:product, supplier: supplier) } + let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) } + + before do + exchange = Exchange.find(order_cycle.exchanges.to_enterprises(d).outgoing.first.id) + exchange.variants << product.master + end + + it "builds a list of producers/suppliers" do + spree_get :show + assigns[:producers].should == [supplier] + end + end + describe "returning products" do let(:product) { create(:product) } let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) } diff --git a/spec/features/consumer/shopping_spec.rb b/spec/features/consumer/shopping_spec.rb index e5bd0c3cc7..9a136df99d 100644 --- a/spec/features/consumer/shopping_spec.rb +++ b/spec/features/consumer/shopping_spec.rb @@ -17,6 +17,25 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should have_text distributor.name end + describe "With products in order cycles" do + let(:supplier) { create(:supplier_enterprise) } + let(:product) { create(:product, supplier: supplier) } + let(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) } + + before do + exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id) + exchange.variants << product.master + end + + it "shows the suppliers/producers for a distributor" do + visit shop_path + click_link "Our Producers" + page.should have_content supplier.name + end + + end + + describe "selecting an order cycle" do it "selects an order cycle if only one is open" do # create order cycle