mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-26 01:37:39 -04:00
Compare commits
1 Commits
release74
...
feature/ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b0e228609 |
@@ -27,7 +27,7 @@ services:
|
||||
command: sleep infinity
|
||||
|
||||
db:
|
||||
image: postgres:17
|
||||
image: postgres:latest
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
|
||||
16
Gemfile.lock
16
Gemfile.lock
@@ -201,7 +201,7 @@ GEM
|
||||
comfy_bootstrap_form (4.0.9)
|
||||
rails (>= 5.0.0)
|
||||
concurrent-ruby (1.3.5)
|
||||
connection_pool (2.5.5)
|
||||
connection_pool (2.5.4)
|
||||
crass (1.0.6)
|
||||
crowdin-api (1.12.0)
|
||||
open-uri (>= 0.1.0, < 0.2.0)
|
||||
@@ -327,7 +327,7 @@ GEM
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.14.7)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-tasks (1.1.2)
|
||||
i18n-tasks (1.1.0)
|
||||
activesupport (>= 4.0.2)
|
||||
ast (>= 2.1.0)
|
||||
erubi
|
||||
@@ -417,7 +417,7 @@ GEM
|
||||
mini_magick (4.12.0)
|
||||
mini_mime (1.1.5)
|
||||
mini_portile2 (2.8.9)
|
||||
minitest (5.26.2)
|
||||
minitest (5.26.1)
|
||||
moneta (1.0.0)
|
||||
msgpack (1.8.0)
|
||||
multi_json (1.15.0)
|
||||
@@ -548,7 +548,7 @@ GEM
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rdoc (6.16.1)
|
||||
rdoc (6.15.1)
|
||||
erb
|
||||
psych (>= 4.0.0)
|
||||
tsort
|
||||
@@ -630,7 +630,7 @@ GEM
|
||||
rubocop-factory_bot (2.28.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rails (2.34.1)
|
||||
rubocop-rails (2.33.4)
|
||||
activesupport (>= 4.2.0)
|
||||
lint_roller (~> 1.1)
|
||||
rack (>= 1.1)
|
||||
@@ -639,9 +639,9 @@ GEM
|
||||
rubocop-rake (0.7.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (>= 1.72.1)
|
||||
rubocop-rspec (3.8.0)
|
||||
rubocop-rspec (3.7.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.81)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rspec_rails (2.32.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
@@ -731,7 +731,7 @@ GEM
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
webrick (1.9.2)
|
||||
webrick (1.9.1)
|
||||
websocket (1.2.11)
|
||||
websocket-driver (0.8.0)
|
||||
base64
|
||||
|
||||
@@ -188,7 +188,7 @@ class CropsController < ApplicationController
|
||||
|
||||
def crop_params
|
||||
params.require(:crop).permit(
|
||||
:name, :en_wikipedia_url, :en_youtube_url,
|
||||
:name, :en_wikipedia_url,
|
||||
:parent_id, :perennial,
|
||||
:request_notes, :reason_for_rejection,
|
||||
:rejection_notes,
|
||||
|
||||
@@ -17,12 +17,4 @@ module CropsHelper
|
||||
def crop_ebay_seeds_url(crop)
|
||||
"https://www.ebay.com/sch/i.html?_nkw=#{CGI.escape crop.name}"
|
||||
end
|
||||
|
||||
def youtube_video_id(url)
|
||||
return unless url
|
||||
|
||||
regex = %r{(?:youtube(?:-nocookie)?\.com/(?:[^/\n\s]+/\S+/|(?:v|e(?:mbed)?)/|\S*?[?&]v=)|youtu\.be/)([a-zA-Z0-9_-]{11})}
|
||||
match = url.match(regex)
|
||||
match[1] if match
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,6 +19,10 @@ module OpenFarmData
|
||||
fetch_attr('tags_array')
|
||||
end
|
||||
|
||||
def description
|
||||
fetch_attr('description')
|
||||
end
|
||||
|
||||
def common_names
|
||||
fetch_attr('common_names')
|
||||
end
|
||||
|
||||
@@ -55,12 +55,6 @@ class Crop < ApplicationRecord
|
||||
message: 'is not a valid English Wikipedia URL'
|
||||
},
|
||||
if: :approved?
|
||||
validates :en_youtube_url,
|
||||
format: {
|
||||
with: %r{\A(?:https?://)?(?:www\.)?(?:youtube(?:-nocookie)?\.com/(?:(?:v|e(?:mbed)?)/|\S*?[?&]v=)|youtu\.be/)[a-zA-Z0-9_-]{11}(?:[?&]\S*)?\z},
|
||||
message: 'is not a valid YouTube URL'
|
||||
},
|
||||
allow_blank: true
|
||||
validates :name, uniqueness: { scope: :approval_status }, if: :pending?
|
||||
|
||||
def to_s
|
||||
@@ -165,14 +159,8 @@ class Crop < ApplicationRecord
|
||||
(companions + parent.companions).uniq
|
||||
end
|
||||
|
||||
before_destroy :destroy_reverse_companionships
|
||||
|
||||
private
|
||||
|
||||
def destroy_reverse_companionships
|
||||
CropCompanion.where(crop_b: self).destroy_all
|
||||
end
|
||||
|
||||
def count_uses_of_property(col_name)
|
||||
plantings.unscoped
|
||||
.where(crop_id: id)
|
||||
|
||||
@@ -55,9 +55,6 @@
|
||||
= f.url_field :en_wikipedia_url, id: "en_wikipedia_url", label: 'Wikipedia URL'
|
||||
%span.help-block
|
||||
Link to the crop's page on the English language Wikipedia (required).
|
||||
= f.url_field :en_youtube_url, label: 'YouTube URL'
|
||||
%span.help-block
|
||||
Link to a YouTube video about the crop in English.
|
||||
|
||||
-# Only crop wranglers see the crop hierarchy (for now)
|
||||
- if can? :wrangle, @crop
|
||||
|
||||
@@ -30,12 +30,6 @@
|
||||
- @crop.all_companions.each do |companion|
|
||||
= render 'crops/tiny', crop: companion
|
||||
|
||||
- if @crop.en_youtube_url.present?
|
||||
%section.youtube
|
||||
%h2 Video
|
||||
.embed-responsive.embed-responsive-16by9
|
||||
%iframe.embed-responsive-item{ src: "https://www.youtube.com/embed/#{youtube_video_id(@crop.en_youtube_url)}", allowfullscreen: true }
|
||||
|
||||
%section.photos
|
||||
= cute_icon
|
||||
= render 'crops/photos', crop: @crop
|
||||
@@ -163,10 +157,3 @@
|
||||
= icon 'fas', 'external-link-alt'
|
||||
Wikihow instructions
|
||||
|
||||
%li.list-group-item
|
||||
= link_to "https://www.youtube.com/results?search_query=#{CGI.escape "growing #{@crop.name}"}",
|
||||
target: "_blank",
|
||||
class: 'card-link',
|
||||
rel: "noopener noreferrer" do
|
||||
= icon 'fab', 'youtube'
|
||||
YouTube
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddEnYoutubeUrlToCrops < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
add_column :crops, :en_youtube_url, :string
|
||||
end
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddDescriptionToCrops < ActiveRecord::Migration[7.2]
|
||||
# Temporary model to avoid validation issues
|
||||
class Crop < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :crops, :description, :text
|
||||
|
||||
# Ensure the new column is available to the temporary model
|
||||
Crop.reset_column_information
|
||||
|
||||
Crop.find_each do |crop|
|
||||
next if crop.openfarm_data.blank?
|
||||
|
||||
description = crop.openfarm_data.dig('attributes', 'description')
|
||||
crop.update_column(:description, description) if description.present?
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :crops, :description
|
||||
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_28_200506) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_09_01_144900) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -259,8 +259,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_11_28_200506) do
|
||||
t.string "sowing_method"
|
||||
t.string "sun_requirements"
|
||||
t.integer "growing_degree_days"
|
||||
t.string "en_youtube_url"
|
||||
t.text "description"
|
||||
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"
|
||||
@@ -585,6 +583,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_11_28_200506) do
|
||||
t.integer "harvests_count", default: 0
|
||||
t.integer "likes_count", default: 0
|
||||
t.boolean "failed", default: false, null: false
|
||||
t.boolean "from_other_source"
|
||||
t.integer "overall_rating"
|
||||
t.index ["crop_id"], name: "index_plantings_on_crop_id"
|
||||
t.index ["garden_id"], name: "index_plantings_on_garden_id"
|
||||
|
||||
@@ -101,7 +101,7 @@ describe CropsController do
|
||||
it { expect { subject }.to change(AlternateName, :count).by(2) }
|
||||
it { expect { subject }.to change(ScientificName, :count).by(1) }
|
||||
|
||||
context 'with data' do
|
||||
context 'with openfarm data' do
|
||||
let(:crop_params) do
|
||||
{
|
||||
crop: {
|
||||
@@ -110,18 +110,16 @@ describe CropsController do
|
||||
row_spacing: 10,
|
||||
spread: 20,
|
||||
height: 30,
|
||||
description: 'hello',
|
||||
sowing_method: 'direct',
|
||||
sun_requirements: 'full sun',
|
||||
growing_degree_days: 100,
|
||||
en_youtube_url: 'https://www.youtube.com/watch?v=INZybkX8tLI'
|
||||
growing_degree_days: 100
|
||||
},
|
||||
alt_name: { '1': "egg plant", '2': "purple apple" },
|
||||
sci_name: { '1': "fancy sci name", '2': "" }
|
||||
}
|
||||
end
|
||||
|
||||
it 'saves data' do
|
||||
it 'saves openfarm data' do
|
||||
subject
|
||||
crop = Crop.last
|
||||
expect(crop.row_spacing).to eq(10)
|
||||
@@ -130,8 +128,6 @@ describe CropsController do
|
||||
expect(crop.sowing_method).to eq('direct')
|
||||
expect(crop.sun_requirements).to eq('full sun')
|
||||
expect(crop.growing_degree_days).to eq(100)
|
||||
expect(crop.description).to eq 'hello'
|
||||
expect(crop.en_youtube_url).to eq 'https://www.youtube.com/watch?v=INZybkX8tLI'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -544,20 +544,6 @@ describe Crop do
|
||||
end
|
||||
end
|
||||
|
||||
context "destroying a crop" do
|
||||
let!(:crop_a) { FactoryBot.create(:crop) }
|
||||
let!(:crop_b) { FactoryBot.create(:crop) }
|
||||
|
||||
before do
|
||||
CropCompanion.create(crop_a: crop_a, crop_b: crop_b)
|
||||
CropCompanion.create(crop_a: crop_b, crop_b: crop_a)
|
||||
end
|
||||
|
||||
it "destroys companion links" do
|
||||
expect { crop_a.destroy }.to change { CropCompanion.count }.from(2).to(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "crop rejections" do
|
||||
let!(:rejected_reason) do
|
||||
FactoryBot.create(:crop, name: 'tomato',
|
||||
|
||||
Reference in New Issue
Block a user