diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1bfb4a7d42..b5bcef894e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,9 +9,8 @@ class ApplicationController < ActionController::Base @cms_site = Cms::Site.where(:identifier => 'open-food-web').first end - def load_data_for_sidebar - @suppliers = Enterprise.is_supplier.all + @suppliers = Enterprise.is_primary_producer @distributors = Enterprise.is_distributor.with_distributed_active_products_on_hand.by_name end diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 11b3a34beb..1b05eaf1c3 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -4,7 +4,7 @@ class EnterprisesController < BaseController end def suppliers - @suppliers = Enterprise.is_supplier + @suppliers = Enterprise.is_primary_producer end def distributors diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 0d66f83f8e..d4679f6424 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -15,7 +15,7 @@ class Enterprise < ActiveRecord::Base before_validation :set_unused_address_fields scope :by_name, order('name') - scope :is_supplier, where(:is_primary_producer => true) + scope :is_primary_producer, where(:is_primary_producer => true) scope :is_distributor, where(:is_distributor => true) scope :with_distributed_active_products_on_hand, lambda { joins(:distributed_products).where('spree_products.deleted_at IS NULL AND spree_products.available_on <= ? AND spree_products.count_on_hand > 0', Time.now).select('distinct(enterprises.*)') } diff --git a/app/views/spree/admin/products/_supplier_form.html.haml b/app/views/spree/admin/products/_supplier_form.html.haml index 9bfc0bec4a..aafb9175e1 100644 --- a/app/views/spree/admin/products/_supplier_form.html.haml +++ b/app/views/spree/admin/products/_supplier_form.html.haml @@ -1,5 +1,5 @@ = f.field_container :supplier do = f.label :supplier %br - = f.collection_select(:supplier_id, Enterprise.is_supplier, :id, :name, :include_blank => true) + = f.collection_select(:supplier_id, Enterprise.is_primary_producer, :id, :name, :include_blank => true) = f.error_message_on :supplier diff --git a/db/seeds.rb b/db/seeds.rb index 9a566de0ce..dd6be815e2 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -74,19 +74,19 @@ unless Spree::Product.count > 0 FactoryGirl.create(:product, :name => 'Garlic', :price => 20.00, - :supplier => Enterprise.is_supplier[0], + :supplier => Enterprise.is_primary_producer[0], :distributors => [Enterprise.is_distributor[0]], :taxons => [Spree::Taxon.find_by_name('Vegetables')]) FactoryGirl.create(:product, :name => 'Fuji Apple', :price => 5.00, - :supplier => Enterprise.is_supplier[1], + :supplier => Enterprise.is_primary_producer[1], :distributors => Enterprise.is_distributor, :taxons => [Spree::Taxon.find_by_name('Fruit')]) FactoryGirl.create(:product, :name => 'Beef - 5kg Trays', :price => 50.00, - :supplier => Enterprise.is_supplier[2], + :supplier => Enterprise.is_primary_producer[2], :distributors => [Enterprise.is_distributor[2]], :taxons => [Spree::Taxon.find_by_name('Meat and Fish')]) end diff --git a/spec/factories.rb b/spec/factories.rb index 79d26f5731..8348f98afd 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -43,7 +43,7 @@ FactoryGirl.modify do # When this fix has been merged into a version of Spree that we're using, this line can be removed. sequence(:name) { |n| "Product ##{n} - #{Kernel.rand(9999)}" } - supplier { Enterprise.is_supplier.first || FactoryGirl.create(:supplier_enterprise) } + supplier { Enterprise.is_primary_producer.first || FactoryGirl.create(:supplier_enterprise) } on_hand 3 # before(:create) do |product, evaluator|