diff --git a/app/controllers/admin/distributors_controller.rb b/app/controllers/admin/distributors_controller.rb deleted file mode 100644 index 21d561a1ea..0000000000 --- a/app/controllers/admin/distributors_controller.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Admin - class DistributorsController < ResourceController - before_filter :load_distributor_set, :only => :index - before_filter :load_countries, :except => :index - - def bulk_update - @distributor_set = DistributorSet.new(params[:distributor_set]) - if @distributor_set.save - redirect_to main_app.admin_distributors_path, :notice => 'Distributor collection times updated.' - else - render :index - end - end - - private - def load_distributor_set - @distributor_set = DistributorSet.new :distributors => collection - end - - def load_countries - @countries = Spree::Country.order(:name) - end - - def collection - super.order(:name) - end - end -end diff --git a/app/controllers/admin/suppliers_controller.rb b/app/controllers/admin/suppliers_controller.rb deleted file mode 100644 index 63eb594bf3..0000000000 --- a/app/controllers/admin/suppliers_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Admin - class SuppliersController < ResourceController - before_filter :load_data, :except => [:index] - - helper 'spree/products' - - private - def load_data - @countries = Spree::Country.order(:name) - end - - def collection - super.order(:name) - end - end -end diff --git a/app/controllers/distributors_controller.rb b/app/controllers/distributors_controller.rb deleted file mode 100644 index 97c6d81691..0000000000 --- a/app/controllers/distributors_controller.rb +++ /dev/null @@ -1,35 +0,0 @@ -class DistributorsController < BaseController - def show - options = {:distributor_id => params[:id]} - options.merge(params.reject { |k,v| k == :id }) - - @distributor = Distributor.find params[:id] - - @searcher = Spree::Config.searcher_class.new(options) - @products = @searcher.retrieve_products - end - - def select - distributor = Distributor.find params[:id] - - order = current_order(true) - - if order.can_change_distributor? - order.distributor = distributor - order.save! - end - - redirect_to distributor - end - - def deselect - order = current_order(true) - - if order.can_change_distributor? - order.distributor = nil - order.save! - end - - redirect_to root_path - end -end diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb deleted file mode 100644 index 3b76225449..0000000000 --- a/app/controllers/suppliers_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -class SuppliersController < BaseController - def index - @suppliers = Supplier.all - end - - def show - options = {:supplier_id => params[:id]} - options.merge(params.reject { |k,v| k == :id }) - - @supplier = Supplier.find params[:id] - - @searcher = Spree::Config.searcher_class.new(options) - @products = @searcher.retrieve_products - end -end diff --git a/app/models/distributor.rb b/app/models/distributor.rb deleted file mode 100644 index 1bc2d274c5..0000000000 --- a/app/models/distributor.rb +++ /dev/null @@ -1,31 +0,0 @@ -class Distributor < ActiveRecord::Base - belongs_to :pickup_address, :foreign_key => 'pickup_address_id', :class_name => 'Spree::Address' - has_many :orders, :class_name => 'Spree::Order' - - has_many :product_distributions, :dependent => :destroy - has_many :products, :through => :product_distributions - - accepts_nested_attributes_for :pickup_address - - validates_presence_of :name, :pickup_address - validates_associated :pickup_address - - scope :by_name, order('name') - scope :with_active_products_on_hand, lambda { joins(:products).where('spree_products.deleted_at IS NULL AND spree_products.available_on <= ? AND spree_products.count_on_hand > 0', Time.now).select('distinct(distributors.*)') } - - after_initialize :initialize_country - before_validation :set_unused_address_fields - - def initialize_country - self.pickup_address ||= Spree::Address.new - self.pickup_address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.pickup_address.new_record? - end - - def set_unused_address_fields - pickup_address.firstname = pickup_address.lastname = pickup_address.phone = 'unused' if pickup_address.present? - end - - def to_param - "#{id}-#{name.parameterize}" - end -end diff --git a/app/models/supplier.rb b/app/models/supplier.rb deleted file mode 100644 index 76518a5f34..0000000000 --- a/app/models/supplier.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Supplier < ActiveRecord::Base - has_many :products, :class_name => 'Spree::Product' - belongs_to :address, :class_name => 'Spree::Address' - - accepts_nested_attributes_for :address - - validates_presence_of :name, :address - validates_associated :address - - after_initialize :initialize_country - before_validation :set_unused_address_fields - - def has_products_on_hand? - self.products.where('count_on_hand > 0').present? - end - - def to_param - "#{id}-#{name.parameterize}" - end - - - private - - def initialize_country - self.address ||= Spree::Address.new - self.address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record? - end - - def set_unused_address_fields - address.firstname = address.lastname = address.phone = 'unused' if address.present? - end - -end diff --git a/app/overrides/distributors_admin_tab.rb b/app/overrides/distributors_admin_tab.rb deleted file mode 100644 index b0b71bfcea..0000000000 --- a/app/overrides/distributors_admin_tab.rb +++ /dev/null @@ -1,11 +0,0 @@ -Deface::Override.new(:virtual_path => "spree/layouts/admin", - :name => "distributors_admin_tabs", - :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(:distributors, :url => main_app.admin_distributors_path) %>", - :disabled => false) - -Deface::Override.new(:virtual_path => "spree/layouts/admin", - :name => "suppliers_admin_tabs", - :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(:suppliers, :url => main_app.admin_suppliers_path) %>", - :disabled => false) diff --git a/app/views/admin/distributors/_form.html.haml b/app/views/admin/distributors/_form.html.haml deleted file mode 100644 index efc0dd37f0..0000000000 --- a/app/views/admin/distributors/_form.html.haml +++ /dev/null @@ -1,42 +0,0 @@ -- content_for :head do - = render 'shared/cms_elrte_head' - -%table{"data-hook" => "distributors"} - %tr{"data-hook" => "name"} - %td Name: - %td= f.text_field :name - %tr{"data-hook" => "description"} - %td Description: - %td= f.text_field :description - %tr{'data-hook' => "long_description"} - %td Extended Description: - %td= f.text_area :long_description, :class => 'rich_text' - %tr{"data-hook" => "contact"} - %td Contact: - %td= f.text_field :contact - %tr{"data-hook" => "phone"} - %td Phone: - %td= f.text_field :phone - %tr{"data-hook" => "email"} - %td Email: - %td= f.text_field :email - %tr{"data-hook" => "url"} - %td URL: - %td= f.text_field :url - %tr{"data-hook" => "abn"} - %td ABN: - %td= f.text_field :abn - %tr{"data-hook" => "acn"} - %td ACN: - %td= f.text_field :acn -%fieldset - %legend Pickup details - %table{"data-hook" => "distributors_pickup_details"} - %tr{"data-hook" => "next_collection_at"} - %td Next collection date/time: - %td= f.text_field :next_collection_at - %tr{"data-hook" => "pickup_times"} - %td Regular pickup times: - %td= f.text_field :pickup_times - = f.fields_for :pickup_address do |pickup_address_form| - = render 'spree/admin/shared/address_form', :f => pickup_address_form diff --git a/app/views/admin/distributors/edit.html.erb b/app/views/admin/distributors/edit.html.erb deleted file mode 100644 index a67c215206..0000000000 --- a/app/views/admin/distributors/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ - -<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @distributor } %> -<%= form_for [:admin, @distributor] do |f| %> - <%= render :partial => 'form', :locals => { :f => f } %> - <%= render :partial => 'spree/admin/shared/edit_resource_links' %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/distributors/index.html.erb b/app/views/admin/distributors/index.html.erb deleted file mode 100644 index 86eef01337..0000000000 --- a/app/views/admin/distributors/index.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -
- -<%= form_for @distributor_set, :url => main_app.bulk_update_admin_distributors_path do |f| %> -| Name | -Next Collection Date/Time | -Description | -- |
|---|---|---|---|
| <%= link_to distributor.name, main_app.admin_distributor_path(distributor) %> | -<%= distributor_form.text_field :next_collection_at %> | -<%= distributor.description %> | -- <%= link_to_edit distributor, :class => 'edit' %> - <%= link_to_delete distributor %> - | -
| <%= t(:none) %> | |||
Hello, world!
This is a paragraph.
' - email 'supplier@example.com' - address { Spree::Address.first || FactoryGirl.create(:address) } - end - - factory :distributor, :class => Distributor do - sequence(:name) { |n| "Distributor #{n}" } - contact 'Mr Turing' - phone '1000100100' - description 'The creator' - long_description 'Hello, world!
This is a paragraph.
' - email 'alan@somewhere.com' - url 'http://example.com' - pickup_times "Whenever you're free" - next_collection_at 'Thursday 10am' - pickup_address { Spree::Address.first || FactoryGirl.create(:address) } - end - factory :product_distribution, :class => ProductDistribution do product { |pd| Spree::Product.first || FactoryGirl.create(:product) } distributor { |pd| Enterprise.is_distributor.first || FactoryGirl.create(:distributor_enterprise) } diff --git a/spec/requests/admin/distributors_spec.rb b/spec/requests/admin/distributors_spec.rb deleted file mode 100644 index d409eba3ff..0000000000 --- a/spec/requests/admin/distributors_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "spec_helper" - -feature %q{ - As an administration - I want manage the distributors of products -} do - include AuthenticationWorkflow - include WebHelper - - - scenario "listing distributors" do - d = create(:distributor) - - login_to_admin_section - click_link 'Distributors' - - page.should have_content d.name - end - - scenario "viewing a distributor" do - d = create(:distributor) - - login_to_admin_section - click_link 'Distributors' - click_link d.name - - page.should have_content d.name - end - - scenario "creating a new distributor" do - login_to_admin_section - - click_link 'Distributors' - click_link 'New Distributor' - - fill_in 'distributor_name', :with => 'Eaterprises' - fill_in 'distributor_description', :with => 'Connecting farmers and eaters' - fill_in 'distributor_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - fill_in 'distributor_contact', :with => 'Kirsten or Ren' - fill_in 'distributor_phone', :with => '0413 897 321' - - fill_in 'distributor_pickup_address_attributes_address1', :with => '35 Ballantyne St' - fill_in 'distributor_pickup_address_attributes_city', :with => 'Thornbury' - fill_in 'distributor_pickup_address_attributes_zipcode', :with => '3072' - select('Australia', :from => 'distributor_pickup_address_attributes_country_id') - select('Victoria', :from => 'distributor_pickup_address_attributes_state_id') - - fill_in 'distributor_next_collection_at', :with => 'Thursday, 22nd Feb, 6 - 9 PM' - fill_in 'distributor_pickup_times', :with => 'Thursday, 22nd Feb, 6 - 9 PM. Friday, 23nd Feb, 6 - 9 PM' - fill_in 'distributor_email', :with => 'info@eaterprises.com.au' - fill_in 'distributor_url', :with => 'http://eaterprises.com.au' - fill_in 'distributor_abn', :with => '09812309823' - fill_in 'distributor_acn', :with => '' - - click_button 'Create' - - flash_message.should == 'Distributor "Eaterprises" has been successfully created!' - end - - - scenario "updating many distributor next collection times at once" do - # Given three distributors - 3.times { create(:distributor) } - - # When I go to the distributors page - login_to_admin_section - click_link 'Distributors' - - # And I fill in some new collection times and save them - fill_in 'distributor_set_distributors_attributes_0_next_collection_at', :with => 'One' - fill_in 'distributor_set_distributors_attributes_1_next_collection_at', :with => 'Two' - fill_in 'distributor_set_distributors_attributes_2_next_collection_at', :with => 'Three' - click_button 'Update' - - # Then my times should have been saved - flash_message.should == 'Distributor collection times updated.' - Distributor.all.map { |d| d.next_collection_at }.should == %w(One Two Three) - end - -end diff --git a/spec/requests/admin/suppliers_spec.rb b/spec/requests/admin/suppliers_spec.rb deleted file mode 100644 index acd91568be..0000000000 --- a/spec/requests/admin/suppliers_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "spec_helper" - -feature %q{ - As an administration - I want manage the suppliers of products -} do - include AuthenticationWorkflow - include WebHelper - - background do - end - - scenario "listing suppliers" do - s = create(:supplier) - - login_to_admin_section - click_link 'Suppliers' - - page.should have_content s.name - end - - scenario "viewing a supplier" do - s = create(:supplier) - - login_to_admin_section - click_link 'Suppliers' - click_link s.name - - page.should have_content s.name - end - - scenario "creating a new supplier" do - login_to_admin_section - - click_link 'Suppliers' - click_link 'New Supplier' - - fill_in 'supplier_name', :with => 'David Arnold' - fill_in 'supplier_description', :with => 'A farmer with a difference' - fill_in 'supplier_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - - fill_in 'supplier_address_attributes_address1', :with => '35 Byron Ave' - fill_in 'supplier_address_attributes_city', :with => 'Ararat' - fill_in 'supplier_address_attributes_zipcode', :with => '1112' - select('Australia', :from => 'supplier_address_attributes_country_id') - select('Victoria', :from => 'supplier_address_attributes_state_id') - - fill_in 'supplier_email', :with => 'david@here.com' - fill_in 'supplier_website', :with => 'http://somewhere.com' - fill_in 'supplier_twitter', :with => 'davida' - - click_button 'Create' - - flash_message.should == 'Supplier "David Arnold" has been successfully created!' - end -end