mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-23 07:18:22 -04:00
Split "days until maturity" into min and max fields.
This commit is contained in:
1 parent
329e147add
commit
233f9dfd88
8 files changed
+37
-16
No files matched your search
@@ -112,6 +112,7 @@ class SeedsController < ApplicationController
|
||||
def seed_params
|
||||
params.require(:seed).permit(
|
||||
:owner_id, :crop_id, :description, :quantity, :plant_before,
|
||||
:days_until_maturity, :organic, :gmo, :heirloom, :tradable_to, :slug)
|
||||
:days_until_maturity_min, :days_until_maturity_max, :organic, :gmo,
|
||||
:heirloom, :tradable_to, :slug)
|
||||
end
|
||||
end
|
||||
+6
-1
@@ -13,7 +13,12 @@ class Seed < ActiveRecord::Base
|
||||
:only_integer => true,
|
||||
:greater_than_or_equal_to => 0 },
|
||||
:allow_nil => true
|
||||
validates :days_until_maturity,
|
||||
validates :days_until_maturity_min,
|
||||
:numericality => {
|
||||
:only_integer => true,
|
||||
:greater_than_or_equal_to => 0 },
|
||||
:allow_nil => true
|
||||
validates :days_until_maturity_max,
|
||||
:numericality => {
|
||||
:only_integer => true,
|
||||
:greater_than_or_equal_to => 0 },
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
- if seed.days_until_maturity_min.blank?
|
||||
- if seed.days_until_maturity_max.blank?
|
||||
unknown
|
||||
- else
|
||||
= seed.days_until_maturity_max.to_s
|
||||
- elsif seed.days_until_maturity_max.blank?
|
||||
= seed.days_until_maturity_min.to_s
|
||||
- else
|
||||
!= "#{seed.days_until_maturity_min}–#{seed.days_until_maturity_max}"
|
||||
@@ -22,9 +22,12 @@
|
||||
.col-md-2
|
||||
= f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : ''
|
||||
.form-group
|
||||
= f.label :days_until_maturity, 'Days until maturity:', :class => 'control-label col-md-2'
|
||||
= f.label :days_until_maturity_min, 'Days until maturity, min:', :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :days_until_maturity, :class => 'form-control'
|
||||
= f.number_field :days_until_maturity_min, :class => 'form-control'
|
||||
= f.label :days_until_maturity_max, 'Days until maturity, max:', :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :days_until_maturity_max, :class => 'form-control'
|
||||
.form-group
|
||||
= f.label :organic, 'Organic?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
= @seed.plant_before.to_s
|
||||
%p
|
||||
%b Days until maturity:
|
||||
= @seed.days_until_maturity.to_s
|
||||
= render :partial => 'days_until_maturity', :locals => { :seed => @seed }
|
||||
%p
|
||||
%b Organic?
|
||||
= @seed.organic
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class AddPropertiesToSeeds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :seeds, :days_until_maturity, :integer
|
||||
add_column :seeds, :days_until_maturity_min, :integer
|
||||
add_column :seeds, :days_until_maturity_max, :integer
|
||||
add_column :seeds, :organic, :text, :default => 'unknown'
|
||||
add_column :seeds, :gmo, :text, :default => 'unknown'
|
||||
add_column :seeds, :heirloom, :text, :default => 'unknown'
|
||||
|
||||
+10
-9
@@ -308,19 +308,20 @@ ActiveRecord::Schema.define(version: 20150124110540) do
|
||||
end
|
||||
|
||||
create_table "seeds", force: true do |t|
|
||||
t.integer "owner_id", null: false
|
||||
t.integer "crop_id", null: false
|
||||
t.integer "owner_id", null: false
|
||||
t.integer "crop_id", null: false
|
||||
t.text "description"
|
||||
t.integer "quantity"
|
||||
t.date "plant_before"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "tradable_to", default: "nowhere"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "tradable_to", default: "nowhere"
|
||||
t.string "slug"
|
||||
t.integer "days_until_maturity"
|
||||
t.text "organic", default: "unknown"
|
||||
t.text "gmo", default: "unknown"
|
||||
t.text "heirloom", default: "unknown"
|
||||
t.integer "days_until_maturity_min"
|
||||
t.integer "days_until_maturity_max"
|
||||
t.text "organic", default: "unknown"
|
||||
t.text "gmo", default: "unknown"
|
||||
t.text "heirloom", default: "unknown"
|
||||
end
|
||||
|
||||
add_index "seeds", ["slug"], name: "index_seeds_on_slug", unique: true, using: :btree
|
||||
|
||||
@@ -17,7 +17,8 @@ feature "Harvesting a crop", :js => true do
|
||||
within "form#new_seed" do
|
||||
fill_in "Quantity:", :with => 42
|
||||
fill_in "Plant before:", :with => "2014-06-15"
|
||||
fill_in "Days until maturity:", :with => 999
|
||||
fill_in "Days until maturity, min:", :with => 999
|
||||
fill_in "Days until maturity, max:", :with => 1999
|
||||
select "certified organic", :from => "Organic?"
|
||||
select "non-certified GMO-free", :from => "GMO?"
|
||||
select "heirloom", :from => "Heirloom?"
|
||||
|
||||
Reference in new issue
Block a user