mirror of
https://github.com/Growstuff/growstuff.git
synced 2025-12-23 17:47:49 -05:00
Merge pull request #4352 from Growstuff/add-public-food-key
feat: Add Public Food Key to Crop model
This commit is contained in:
committed by
GitHub
parent
ff6a6e2e11
commit
30e7c5d01c
@@ -195,6 +195,7 @@ class CropsController < ApplicationController
|
||||
:request_notes, :reason_for_rejection,
|
||||
:rejection_notes,
|
||||
:description,
|
||||
:public_food_key,
|
||||
:row_spacing, :spread, :height,
|
||||
:sowing_method, :sun_requirements, :growing_degree_days,
|
||||
scientific_names_attributes: %i(scientific_name _destroy id)
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
= f.number_field :growing_degree_days, min: 0
|
||||
- if @crop.parent
|
||||
%span.help-block Parent: #{@crop.parent.growing_degree_days}
|
||||
= f.text_field :public_food_key, label: 'Australian Food Composition Database Public Food Key'
|
||||
|
||||
- unless @crop.approved?
|
||||
= link_to 'Search wikipedia', "https://en.wikipedia.org/w/index.php?search=#{@crop.name}", target: '_blank'
|
||||
|
||||
@@ -140,6 +140,12 @@
|
||||
= icon 'fas', 'external-link-alt'
|
||||
Wikipedia (English)
|
||||
|
||||
- if @crop.public_food_key.present?
|
||||
%li.list-group-item
|
||||
= link_to "https://afcd.foodstandards.gov.au/fooddetails.aspx?PFKID=#{@crop.public_food_key}", target: "_blank", rel: "noopener noreferrer" do
|
||||
= icon 'fas', 'external-link-alt'
|
||||
Australian Food Composition Database
|
||||
|
||||
%li.list-group-item
|
||||
= link_to "https://www.gardenate.com/plant/#{CGI.escape @crop.name}",
|
||||
target: "_blank",
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddPublicFoodKeyToCrops < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :crops, :public_food_key, :string
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_11_30_035701) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_11_30_053104) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -261,6 +261,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_11_30_035701) do
|
||||
t.integer "growing_degree_days"
|
||||
t.string "en_youtube_url"
|
||||
t.text "description"
|
||||
t.string "public_food_key"
|
||||
t.index ["creator_id"], name: "index_crops_on_creator_id"
|
||||
t.index ["name"], name: "index_crops_on_name"
|
||||
t.index ["parent_id"], name: "index_crops_on_parent_id"
|
||||
|
||||
@@ -196,7 +196,7 @@ describe "crop detail page", :js do
|
||||
context 'crop is Perennial' do
|
||||
let(:crop) { FactoryBot.create(:perennial_crop) }
|
||||
|
||||
it { expect(page).to have_text 'Perennial' }
|
||||
it { expect(find('.index-cards.facts')).to have_text 'Perennial' }
|
||||
it { expect(page).to have_text 'living more than two years' }
|
||||
it { expect(page).to have_no_text 'Annual' }
|
||||
end
|
||||
@@ -204,7 +204,7 @@ describe "crop detail page", :js do
|
||||
context 'crop Perennial value is null' do
|
||||
let(:crop) { FactoryBot.create(:crop, perennial: nil) }
|
||||
|
||||
it { expect(page).to have_no_text 'Perennial' }
|
||||
it { expect(find('.index-cards.facts')).to have_no_text 'Perennial' }
|
||||
it { expect(page).to have_no_text 'Annual' }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user