mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adding notes field to products
This commit is contained in:
@@ -43,7 +43,6 @@ class Enterprise < ActiveRecord::Base
|
||||
.uniq
|
||||
}
|
||||
|
||||
|
||||
scope :with_distributed_products_outer,
|
||||
joins('LEFT OUTER JOIN product_distributions ON product_distributions.distributor_id = enterprises.id').
|
||||
joins('LEFT OUTER JOIN spree_products ON spree_products.id = product_distributions.product_id')
|
||||
|
||||
@@ -6,7 +6,7 @@ Spree::Product.class_eval do
|
||||
|
||||
accepts_nested_attributes_for :product_distributions, :allow_destroy => true
|
||||
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name, :notes
|
||||
|
||||
validates_presence_of :supplier
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/ insert_bottom "[data-hook='admin_product_form_additional_fields']"
|
||||
|
||||
= f.field_container :notes do
|
||||
= f.label :notes, t(:notes)
|
||||
= f.text_area :notes, { :class => 'fullwidth', rows: 5 }
|
||||
= f.error_message_on :notes
|
||||
|
||||
5
db/migrate/20140204011203_add_notes_to_products.rb
Normal file
5
db/migrate/20140204011203_add_notes_to_products.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddNotesToProducts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spree_products, :notes, :text
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140121050239) do
|
||||
ActiveRecord::Schema.define(:version => 20140204011203) do
|
||||
|
||||
create_table "adjustment_metadata", :force => true do |t|
|
||||
t.integer "adjustment_id"
|
||||
@@ -622,6 +622,7 @@ ActiveRecord::Schema.define(:version => 20140121050239) do
|
||||
t.string "variant_unit"
|
||||
t.float "variant_unit_scale"
|
||||
t.string "variant_unit_name"
|
||||
t.text "notes"
|
||||
end
|
||||
|
||||
add_index "spree_products", ["available_on"], :name => "index_products_on_available_on"
|
||||
|
||||
@@ -78,6 +78,19 @@ feature %q{
|
||||
login_to_admin_as @new_user
|
||||
end
|
||||
|
||||
|
||||
context "Additional fields" do
|
||||
#let(:product) { create(:simple_product, supplier: @supplier2) }
|
||||
|
||||
it "should have a notes field" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link product.name
|
||||
page.should have_content "Notes"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "create new product" do
|
||||
click_link 'Products'
|
||||
click_link 'New Product'
|
||||
|
||||
Reference in New Issue
Block a user