Compare commits

...

7 Commits

Author SHA1 Message Date
google-labs-jules[bot]
4b9763e1da feat: Add problem tracking feature
This commit introduces a new `Problem` model, analogous to `Crop`, to allow users to track problems they have on their plantings (e.g., aphids on tomatoes).

Key features:
- A new `Problem` model that can be curated by admins (`problem_wranglers`).
- Users can associate problems with their plantings and upload photos of the problems.
- Aggregated problem information is displayed on the crop detail page (e.g., "Problems: aphids (27), blight (13)").
- Users can mention problems in posts (e.g., `[aphids](problem)`), which automatically links to the problem's page.
- Admin functionality for reviewing and approving new problem suggestions.

Resolves merge conflict in app/controllers/plantings_controller.rb
2025-09-07 11:47:53 +00:00
Daniel O'Connor
8709ac6e8f Mark unique 2025-09-01 11:26:05 +00:00
Daniel O'Connor
d75f503b16 Add DB schema 2025-09-01 11:04:48 +00:00
Daniel O'Connor
1dfc5abca9 Add DB schema 2025-09-01 11:04:44 +00:00
Daniel O'Connor
cc97916bac Add problems table 2025-09-01 11:01:46 +00:00
Daniel O'Connor
2134b934f8 Merge branch 'dev' into feature/problems 2025-09-01 19:45:25 +09:30
google-labs-jules[bot]
c8cfb5d42a feat: Add problem tracking feature
This commit introduces a new `Problem` model, analogous to `Crop`, to allow you to track problems you have on your plantings (e.g., aphids on tomatoes).

Key features:
- A new `Problem` model that can be curated by admins (`problem_wranglers`).
- You can associate problems with your plantings and upload photos of the problems.
- Aggregated problem information is displayed on the crop detail page (e.g., "Problems: aphids (27), blight (13)").
- You can mention problems in posts (e.g., `[aphids](problem)`), which automatically links to the problem's page.
- Admin functionality for reviewing and approving new problem suggestions.
2025-09-01 07:52:48 +00:00
161 changed files with 995 additions and 907 deletions

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -6,7 +6,7 @@ jobs:
contributors: contributors:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v4
- name: Install ruby version specified in .ruby-version - name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
@@ -53,7 +53,7 @@ jobs:
steps: steps:
- name: Checkout this repo - name: Checkout this repo
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Configure sysctl limits - name: Configure sysctl limits
run: | run: |

View File

@@ -12,7 +12,6 @@ submit the change with your pull request.
- Miles Gould / [pozorvlak](https://github.com/pozorvlak) - Miles Gould / [pozorvlak](https://github.com/pozorvlak)
- Mackenzie Morgan / [maco](https://github.com/maco) - Mackenzie Morgan / [maco](https://github.com/maco)
- Brenda Wallace / [br3nda](https://github.com/br3nda) - Brenda Wallace / [br3nda](https://github.com/br3nda)
- Daniel O'Connor / [CloCkWeRX](https://github.com/CloCkWeRX)
## Contributors ## Contributors
@@ -69,6 +68,7 @@ submit the change with your pull request.
- Jym Paul Carandang / [jacarandang](https://github.com/jacarandang) - Jym Paul Carandang / [jacarandang](https://github.com/jacarandang)
- Anthony Atkinson / [sha1sum](https://github.com/sha1sum) - Anthony Atkinson / [sha1sum](https://github.com/sha1sum)
- Terence Conquest / [twconquest](https://github.com/twconquest) - Terence Conquest / [twconquest](https://github.com/twconquest)
- Daniel O'Connor / [CloCkWeRX](https://github.com/CloCkWeRX)
- DV Dasari / [dv2](https://github.com/dv2) - DV Dasari / [dv2](https://github.com/dv2)
- Eric Tillberg / [Thrillberg](https://github.com/Thrillberg) - Eric Tillberg / [Thrillberg](https://github.com/Thrillberg)
- Lucas Nogueira / [lucasnogueira](https://github.com/lucasnogueira) - Lucas Nogueira / [lucasnogueira](https://github.com/lucasnogueira)
@@ -95,11 +95,10 @@ submit the change with your pull request.
- Ítalo Pires / [italopires](https://github.com/italopires) - Ítalo Pires / [italopires](https://github.com/italopires)
- Bennett Zink / [bennett-zink](https://github.com/bennett-zink) - Bennett Zink / [bennett-zink](https://github.com/bennett-zink)
- Dominick Thornton / [domthor](https://github.com/domthor) - Dominick Thornton / [domthor](https://github.com/domthor)
## Bots ## Bots
### Security and Dependency Updates ### Security and Dependency Updates
- `codefactor-io[bot]` - `codefactor-io[bot]`
- DeppBot / [deppbot](https://github.com/deppbot) - DeppBot / [deppbot](https://github.com/deppbot)
- `dependabot[bot]` [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview) - `dependabot[bot]` [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)
- [google-labs-jules[bot]](https://github.com/apps/google-labs-jules)

View File

@@ -91,9 +91,10 @@ gem 'bootstrap-datepicker-rails'
# DRY-er easier bootstrap 4 forms # DRY-er easier bootstrap 4 forms
gem "bootstrap_form", ">= 4.5.0" gem "bootstrap_form", ">= 4.5.0"
# For connecting to other services (eg Flickr) # For connecting to other services (eg Twitter)
gem 'omniauth', '~> 1.3' gem 'omniauth', '~> 1.3'
gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-flickr', '>= 0.0.15'
gem 'omniauth-twitter'
# Pretty charts # Pretty charts
gem "chartkick" gem "chartkick"
@@ -201,5 +202,3 @@ group :travis do
end end
gem "i18n_data", "~> 1.1"

View File

@@ -33,29 +33,29 @@ GEM
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.2.2.2) actioncable (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
actionmailbox (7.2.2.2) actionmailbox (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
activejob (= 7.2.2.2) activejob (= 7.2.2.1)
activerecord (= 7.2.2.2) activerecord (= 7.2.2.1)
activestorage (= 7.2.2.2) activestorage (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
mail (>= 2.8.0) mail (>= 2.8.0)
actionmailer (7.2.2.2) actionmailer (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
actionview (= 7.2.2.2) actionview (= 7.2.2.1)
activejob (= 7.2.2.2) activejob (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
mail (>= 2.8.0) mail (>= 2.8.0)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
actionpack (7.2.2.2) actionpack (7.2.2.1)
actionview (= 7.2.2.2) actionview (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
racc racc
rack (>= 2.2.4, < 3.2) rack (>= 2.2.4, < 3.2)
@@ -64,15 +64,15 @@ GEM
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
useragent (~> 0.16) useragent (~> 0.16)
actiontext (7.2.2.2) actiontext (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
activerecord (= 7.2.2.2) activerecord (= 7.2.2.1)
activestorage (= 7.2.2.2) activestorage (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.2.2.2) actionview (7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.11) erubi (~> 1.11)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
@@ -87,22 +87,22 @@ GEM
active_utils (3.5.0) active_utils (3.5.0)
activesupport (>= 4.2) activesupport (>= 4.2)
i18n i18n
activejob (7.2.2.2) activejob (7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.2.2.2) activemodel (7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
activerecord (7.2.2.2) activerecord (7.2.2.1)
activemodel (= 7.2.2.2) activemodel (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
timeout (>= 0.4.0) timeout (>= 0.4.0)
activestorage (7.2.2.2) activestorage (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
activejob (= 7.2.2.2) activejob (= 7.2.2.1)
activerecord (= 7.2.2.2) activerecord (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
marcel (~> 1.0) marcel (~> 1.0)
activesupport (7.2.2.2) activesupport (7.2.2.1)
base64 base64
benchmark (>= 0.3) benchmark (>= 0.3)
bigdecimal bigdecimal
@@ -183,7 +183,7 @@ GEM
image_processing (~> 1.1) image_processing (~> 1.1)
marcel (~> 1.0.0) marcel (~> 1.0.0)
ssrf_filter (~> 1.0) ssrf_filter (~> 1.0)
chartkick (5.2.0) chartkick (5.1.5)
childprocess (5.0.0) childprocess (5.0.0)
coderay (1.1.3) coderay (1.1.3)
coercible (1.0.0) coercible (1.0.0)
@@ -251,7 +251,7 @@ GEM
elasticsearch-transport (7.0.0) elasticsearch-transport (7.0.0)
faraday faraday
multi_json multi_json
erb (5.0.2) erb (5.0.1)
erubi (1.13.1) erubi (1.13.1)
erubis (2.7.0) erubis (2.7.0)
excon (1.2.5) excon (1.2.5)
@@ -341,8 +341,6 @@ GEM
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.8, >= 1.8.1) ruby-progressbar (~> 1.8, >= 1.8.1)
terminal-table (>= 1.5.1) terminal-table (>= 1.5.1)
i18n_data (1.1.0)
simple_po_parser (~> 1.1)
icalendar (2.11.2) icalendar (2.11.2)
base64 base64
ice_cube (~> 0.16) ice_cube (~> 0.16)
@@ -353,7 +351,7 @@ GEM
image_processing (1.12.2) image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3) ruby-vips (>= 2.0.17, < 3)
io-console (0.8.1) io-console (0.8.0)
irb (1.15.2) irb (1.15.2)
pp (>= 0.6.0) pp (>= 0.6.0)
rdoc (>= 4.0.0) rdoc (>= 4.0.0)
@@ -425,14 +423,14 @@ GEM
bigdecimal (~> 3.1) bigdecimal (~> 3.1)
net-http (0.6.0) net-http (0.6.0)
uri uri
net-imap (0.5.9) net-imap (0.4.20)
date date
net-protocol net-protocol
net-pop (0.1.2) net-pop (0.1.2)
net-protocol net-protocol
net-protocol (0.2.2) net-protocol (0.2.2)
timeout timeout
net-smtp (0.5.1) net-smtp (0.5.0)
net-protocol net-protocol
netrc (0.11.0) netrc (0.11.0)
nio4r (2.7.4) nio4r (2.7.4)
@@ -442,7 +440,7 @@ GEM
nokogiri (1.18.9-x86_64-linux-gnu) nokogiri (1.18.9-x86_64-linux-gnu)
racc (~> 1.4) racc (~> 1.4)
oauth (0.5.6) oauth (0.5.6)
oj (3.16.11) oj (3.16.10)
bigdecimal (>= 3.0) bigdecimal (>= 3.0)
ostruct (>= 0.2) ostruct (>= 0.2)
omniauth (1.9.2) omniauth (1.9.2)
@@ -454,9 +452,12 @@ GEM
omniauth-oauth (1.1.0) omniauth-oauth (1.1.0)
oauth oauth
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
open-uri (0.1.0) open-uri (0.1.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
ostruct (0.6.3) ostruct (0.6.2)
parallel (1.27.0) parallel (1.27.0)
parser (3.3.9.0) parser (3.3.9.0)
ast (~> 2.4.1) ast (~> 2.4.1)
@@ -498,20 +499,20 @@ GEM
rackup (1.0.1) rackup (1.0.1)
rack (< 3) rack (< 3)
webrick webrick
rails (7.2.2.2) rails (7.2.2.1)
actioncable (= 7.2.2.2) actioncable (= 7.2.2.1)
actionmailbox (= 7.2.2.2) actionmailbox (= 7.2.2.1)
actionmailer (= 7.2.2.2) actionmailer (= 7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
actiontext (= 7.2.2.2) actiontext (= 7.2.2.1)
actionview (= 7.2.2.2) actionview (= 7.2.2.1)
activejob (= 7.2.2.2) activejob (= 7.2.2.1)
activemodel (= 7.2.2.2) activemodel (= 7.2.2.1)
activerecord (= 7.2.2.2) activerecord (= 7.2.2.1)
activestorage (= 7.2.2.2) activestorage (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.2.2.2) railties (= 7.2.2.1)
rails-controller-testing (1.0.5) rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1) actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1)
@@ -531,9 +532,9 @@ GEM
rails_stdout_logging rails_stdout_logging
rails_serve_static_assets (0.0.5) rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5) rails_stdout_logging (0.0.5)
railties (7.2.2.2) railties (7.2.2.1)
actionpack (= 7.2.2.2) actionpack (= 7.2.2.1)
activesupport (= 7.2.2.2) activesupport (= 7.2.2.1)
irb (~> 1.13) irb (~> 1.13)
rackup (>= 1.0.0) rackup (>= 1.0.0)
rake (>= 12.2) rake (>= 12.2)
@@ -552,8 +553,8 @@ GEM
recaptcha (5.20.1) recaptcha (5.20.1)
redis-client (0.23.2) redis-client (0.23.2)
connection_pool connection_pool
regexp_parser (2.11.2) regexp_parser (2.11.1)
reline (0.6.2) reline (0.6.1)
io-console (~> 0.5) io-console (~> 0.5)
responders (3.1.1) responders (3.1.1)
actionpack (>= 5.2) actionpack (>= 5.2)
@@ -581,7 +582,7 @@ GEM
rspec-mocks (3.13.5) rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0) rspec-support (~> 3.13.0)
rspec-rails (8.0.2) rspec-rails (8.0.1)
actionpack (>= 7.2) actionpack (>= 7.2)
activesupport (>= 7.2) activesupport (>= 7.2)
railties (>= 7.2) railties (>= 7.2)
@@ -607,7 +608,7 @@ GEM
rswag-ui (2.16.0) rswag-ui (2.16.0)
actionpack (>= 5.2, < 8.1) actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1) railties (>= 5.2, < 8.1)
rubocop (1.80.1) rubocop (1.79.2)
json (~> 2.3) json (~> 2.3)
language_server-protocol (~> 3.17.0.2) language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0) lint_roller (~> 1.1.0)
@@ -627,7 +628,7 @@ GEM
rubocop-factory_bot (2.27.1) rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1) lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1) rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.33.3) rubocop-rails (2.32.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
lint_roller (~> 1.1) lint_roller (~> 1.1)
rack (>= 1.1) rack (>= 1.1)
@@ -647,7 +648,7 @@ GEM
ruby-units (4.1.0) ruby-units (4.1.0)
ruby-vips (2.2.1) ruby-vips (2.2.1)
ffi (~> 1.12) ffi (~> 1.12)
rubyzip (3.0.1) rubyzip (2.4.1)
sass (3.7.4) sass (3.7.4)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
@@ -661,17 +662,17 @@ GEM
sprockets (> 3.0) sprockets (> 3.0)
sprockets-rails sprockets-rails
tilt tilt
scout_apm (5.7.1) scout_apm (5.7.0)
parser parser
searchkick (5.3.1) searchkick (5.3.1)
activemodel (>= 6.1) activemodel (>= 6.1)
hashie hashie
securerandom (0.4.1) securerandom (0.4.1)
selenium-webdriver (4.35.0) selenium-webdriver (4.34.0)
base64 (~> 0.2) base64 (~> 0.2)
logger (~> 1.4) logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5) rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 4.0) rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0) websocket (~> 1.0)
sidekiq (7.3.9) sidekiq (7.3.9)
base64 base64
@@ -679,7 +680,6 @@ GEM
logger logger
rack (>= 2.2.4) rack (>= 2.2.4)
redis-client (>= 0.22.2) redis-client (>= 0.22.2)
simple_po_parser (1.1.6)
sprockets (3.7.5) sprockets (3.7.5)
base64 base64
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@@ -694,7 +694,7 @@ GEM
temple (0.10.4) temple (0.10.4)
terminal-table (4.0.0) terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4) unicode-display_width (>= 1.1.1, < 4)
terser (1.2.6) terser (1.2.5)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
thor (1.4.0) thor (1.4.0)
thread_safe (0.3.6) thread_safe (0.3.6)
@@ -704,7 +704,7 @@ GEM
trollop (1.16.2) trollop (1.16.2)
tzinfo (2.0.6) tzinfo (2.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (3.1.5) unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4) unicode-emoji (4.0.4)
unicorn (6.1.0) unicorn (6.1.0)
@@ -730,8 +730,7 @@ GEM
rack-test (>= 0.5.3) rack-test (>= 0.5.3)
webrick (1.9.1) webrick (1.9.1)
websocket (1.2.11) websocket (1.2.11)
websocket-driver (0.8.0) websocket-driver (0.7.6)
base64
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
will_paginate (4.0.1) will_paginate (4.0.1)
@@ -793,7 +792,6 @@ DEPENDENCIES
haml_lint (>= 0.25.1) haml_lint (>= 0.25.1)
hashie (>= 3.5.3) hashie (>= 3.5.3)
i18n-tasks i18n-tasks
i18n_data (~> 1.1)
icalendar icalendar
jquery-rails jquery-rails
jquery-ui-rails! jquery-ui-rails!
@@ -811,6 +809,7 @@ DEPENDENCIES
oj oj
omniauth (~> 1.3) omniauth (~> 1.3)
omniauth-flickr (>= 0.0.15) omniauth-flickr (>= 0.0.15)
omniauth-twitter
percy-capybara (~> 5.0.0) percy-capybara (~> 5.0.0)
pg pg
platform-api platform-api

View File

@@ -62,3 +62,5 @@ For more information about this project, contact [info@growstuff.org](mailto:inf
Security Issues: If you find an authorization bypass or data breach, please contact our maintainers directly at [maintainers@growstuff.org](mailto:maintainers@growstuff.org). Security Issues: If you find an authorization bypass or data breach, please contact our maintainers directly at [maintainers@growstuff.org](mailto:maintainers@growstuff.org).
You can also contact us on [Twitter](http://twitter.com/growstufforg/) or
[Facebook](https://www.facebook.com/pages/Growstuff/1531133417099494) or [Github](https://github.com/Growstuff/growstuff/issues)..

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,13 +1,7 @@
.crop-icon { .crop-icon {
height: 1em; height: 1em;
} }
.card-footer {
.btn-group-vertical {
.btn {
text-wrap: initial
}
}
}
.crop-thumbnail { .crop-thumbnail {
.text { .text {
bottom: 0; bottom: 0;

View File

@@ -1,8 +1,6 @@
// stats shown on homepage. eg. "999 members..." // stats shown on homepage. eg. "999 members..."
.stats { .stats {
a { font-weight: bold;
font-weight: bold;
}
} }
.crops, .crops,

View File

@@ -33,6 +33,13 @@
} }
} }
.location-not-set {
background-image: image-url("location-not-set.en.png");
background-position: center;
background-repeat: no-repeat;
height: 250px;
width: 100%;
}
.card { .card {
.badge-location { .badge-location {
background-color: darken($blue, 10%); background-color: darken($blue, 10%);

View File

@@ -10,33 +10,9 @@
width: 100%; width: 100%;
} }
#navbarSupportedContent { .navbar .nav > li {
ul {
flex-direction: column-reverse;
flex-wrap: nowrap;
li.nav-item {
display: block;
a {
display: grid;
grid-template-columns: 2em 1fr 2em;
}
a.dropdown-toggle::after {
width: 100%;
text-align: right;
}
}
}
}
.crop-actions {
flex-direction: column;
width: 100%;
a {
margin: auto;
display: block; display: block;
} }
}
.navbar .navbar-form { .navbar .navbar-form {
padding-left: 0; padding-left: 0;

View File

@@ -10,7 +10,6 @@ body {
.navbar { .navbar {
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: flex-start
} }
.navbar-brand { .navbar-brand {
.site-name { .site-name {
@@ -368,6 +367,9 @@ ul.thumbnail-buttons {
h1 { h1 {
font-size: 400%; font-size: 400%;
} }
.stats a {
color: $black;
}
// signup widget on homepage // signup widget on homepage
.signup { .signup {

View File

@@ -57,6 +57,6 @@ class AlternateNamesController < ApplicationController
private private
def alternate_name_params def alternate_name_params
params.require(:alternate_name).permit(:crop_id, :name, :creator_id, :language) params.require(:alternate_name).permit(:crop_id, :name, :creator_id)
end end
end end

View File

@@ -78,7 +78,6 @@ class ApplicationController < ActionController::Base
:tos_agreement, :tos_agreement,
# profile stuff # profile stuff
:bio, :location, :latitude, :longitude, :bio, :location, :latitude, :longitude,
:website_url, :instagram_handle, :facebook_handle, :bluesky_handle, :other_url,
# email settings # email settings
:show_email, :newsletter, :send_notification_email, :send_planting_reminder, :show_email, :newsletter, :send_notification_email, :send_planting_reminder,
# update password # update password

View File

@@ -13,55 +13,43 @@ class CommentsController < ApplicationController
end end
def new def new
@commentable = find_commentable
@comment = Comment.new @comment = Comment.new
if @commentable @post = Post.find_by(id: params[:post_id])
@comments = @commentable.comments
if @post
@comments = @post.comments
respond_with(@comments) respond_with(@comments)
else else
redirect_to(request.referer || root_url, redirect_to(request.referer || root_url,
alert: "Can't post a comment on a non-existent commentable") alert: "Can't post a comment on a non-existent post")
end end
end end
def edit def edit
# TODO: Why does this need a collection of comments? @comments = @comment.post.comments
@comments = @comment.commentable.comments
@commentable = @comment.commentable
end end
def create def create
@comment = Comment.new(comment_params) @comment = Comment.new(comment_params)
@commentable = @comment.commentable
@comment.author = current_member @comment.author = current_member
@comment.save @comment.save
respond_with @comment, location: @commentable respond_with @comment, location: @comment.post
end end
def update def update
@comment.update(body: comment_params['body']) @comment.update(body: comment_params['body'])
respond_with @comment, location: @comment.commentable respond_with @comment, location: @comment.post
end end
def destroy def destroy
@commentable = @comment.commentable @post = @comment.post
@comment.destroy @comment.destroy
respond_with(@commentable) respond_with(@post)
end end
private private
def find_commentable
return unless params[:comment]
if params[:comment][:commentable_type] == 'Photo'
Photo.find(params[:comment][:commentable_id])
elsif params[:comment][:commentable_type] == 'Post'
Post.find(params[:comment][:commentable_id])
end
end
def comment_params def comment_params
params.require(:comment).permit(:body, :commentable_id, :commentable_type) params.require(:comment).permit(:body, :post_id)
end end
end end

View File

@@ -39,6 +39,12 @@ class CropsController < ApplicationController
respond_with @crops respond_with @crops
end end
def openfarm
@crop = Crop.find(params[:crop_slug])
@crop.update_openfarm_data!
respond_with @crop, location: @crop
end
def gbif def gbif
@crop = Crop.find(params[:crop_slug]) @crop = Crop.find(params[:crop_slug])
@crop.update_gbif_data! @crop.update_gbif_data!
@@ -69,6 +75,7 @@ class CropsController < ApplicationController
end end
def show def show
@problems = Problem.joins(plantings: :crop).where(crops: { id: @crop.id }).distinct
respond_to do |format| respond_to do |format|
format.html do format.html do
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
@@ -131,6 +138,7 @@ class CropsController < ApplicationController
if @crop.approval_status_changed?(from: "pending", to: "approved") if @crop.approval_status_changed?(from: "pending", to: "approved")
notifier.deliver_now! notifier.deliver_now!
@crop.update_openfarm_data!
@crop.update_gbif_data! @crop.update_gbif_data!
end end
else else
@@ -159,7 +167,7 @@ class CropsController < ApplicationController
end end
def save_crop_names def save_crop_names
AlternateName.create!(names_params(:alt_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id, language: "EN" } }) AlternateName.create!(names_params(:alt_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
ScientificName.create!(names_params(:sci_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } }) ScientificName.create!(names_params(:sci_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
end end
@@ -174,18 +182,20 @@ class CropsController < ApplicationController
def recreate_names(param_name, name_type) def recreate_names(param_name, name_type)
return if params[param_name].blank? return if params[param_name].blank?
@crop.send("#{name_type}_names").each(&:destroy) destroy_names(name_type)
params[param_name].each_value do |value| params[param_name].each_value do |value|
next if value.empty? create_name!(name_type, value) unless value.empty?
if name_type == 'alternate'
@crop.send("#{name_type}_names").create!(name: value, creator_id: current_member.id, language: "EN")
else
@crop.send("#{name_type}_names").create!(name: value, creator_id: current_member.id)
end
end end
end end
def destroy_names(name_type)
@crop.send("#{name_type}_names").each(&:destroy)
end
def create_name!(name_type, value)
@crop.send("#{name_type}_names").create!(name: value, creator_id: current_member.id)
end
def crop_params def crop_params
params.require(:crop).permit( params.require(:crop).permit(
:name, :en_wikipedia_url, :name, :en_wikipedia_url,
@@ -207,12 +217,12 @@ class CropsController < ApplicationController
def crop_json_fields def crop_json_fields
{ {
include: { include: {
plantings: { plantings: {
include: { include: {
owner: { only: %i(id login_name location latitude longitude) } owner: { only: %i(id login_name location latitude longitude) }
} }
}, },
scientific_names: { only: [:name] }, alternate_names: { only: %i(name language) } scientific_names: { only: [:name] }, alternate_names: { only: [:name] }
} }
} }
end end

View File

@@ -4,7 +4,7 @@ class GardensController < DataController
def index def index
@owner = Member.find_by(slug: params[:member_slug]) @owner = Member.find_by(slug: params[:member_slug])
@show_all = params[:all] == '1' @show_all = params[:all] == '1'
@show_jump_to = params[:member_slug].present? || false @show_jump_to = params[:member_slug].present? ? true : false
@gardens = @gardens.includes(:owner) @gardens = @gardens.includes(:owner)
@gardens = @gardens.active unless @show_all @gardens = @gardens.active unless @show_all
@@ -18,7 +18,7 @@ class GardensController < DataController
end end
def show def show
@current_plantings = @garden.plantings.current.where.not(failed: true).includes(:crop, :owner).order(planted_at: :desc) @current_plantings = @garden.plantings.current.includes(:crop, :owner).order(planted_at: :desc)
@current_activities = @garden.activities.current.includes(:owner).order(created_at: :desc) @current_activities = @garden.activities.current.includes(:owner).order(created_at: :desc)
@finished_plantings = @garden.plantings.finished.includes(:crop) @finished_plantings = @garden.plantings.finished.includes(:crop)
@suggested_companions = Crop.approved.where( @suggested_companions = Crop.approved.where(

View File

@@ -16,6 +16,7 @@ class MembersController < ApplicationController
def show def show
@member = Member.confirmed.kept.find_by!(slug: params[:slug]) @member = Member.confirmed.kept.find_by!(slug: params[:slug])
@twitter_auth = @member.auth('twitter')
@flickr_auth = @member.auth('flickr') @flickr_auth = @member.auth('flickr')
@posts = @member.posts @posts = @member.posts

View File

@@ -28,7 +28,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@authentication = action.establish_authentication(auth, member) @authentication = action.establish_authentication(auth, member)
if action.member_created? if action.member_created?
raise "Invalid provider" unless %w(flickr).index(auth['provider'].to_s) raise "Invalid provider" unless %w(twitter flickr).index(auth['provider'].to_s)
session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"]
sign_in member sign_in member

View File

@@ -21,7 +21,6 @@ class PhotosController < ApplicationController
def show def show
@crops = Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: @photo }) @crops = Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: @photo })
@comment = Comment.new(commentable: @photo)
respond_with(@photo) respond_with(@photo)
end end

View File

@@ -91,32 +91,6 @@ class PlantingsController < DataController
respond_with @planting, location: @planting.garden respond_with @planting, location: @planting.garden
end end
def transplant
# The `load_and_authorize_resource` in DataController will handle finding the
# planting and authorizing the action.
# We still need to authorize the new garden
new_garden = Garden.find(params[:garden_id])
authorize! :update, new_garden
# Mark original planting as finished
@planting.update(finished: true, finished_at: Time.zone.now)
# Create a new planting
new_planting = @planting.dup
new_planting.garden = new_garden
new_planting.slug = nil # let friendly_id generate a new slug
new_planting.finished = false
new_planting.finished_at = nil
if new_planting.save
redirect_to edit_planting_path(new_planting), notice: 'Planting was successfully transplanted.'
else
# if the save fails, we should probably roll back the finishing of the original planting
@planting.update(finished: false, finished_at: nil)
redirect_to @planting, alert: "There was an error transplanting the planting: #{new_planting.errors.full_messages.to_sentence}"
end
end
private private
def update_crop_medians def update_crop_medians
@@ -133,7 +107,7 @@ class PlantingsController < DataController
:crop_id, :description, :garden_id, :planted_at, :crop_id, :description, :garden_id, :planted_at,
:parent_seed_id, :parent_seed_id,
:quantity, :sunniness, :planted_from, :finished, :quantity, :sunniness, :planted_from, :finished,
:finished_at, :failed :finished_at, :failed, problem_ids: []
) )
end end

View File

@@ -0,0 +1,76 @@
# frozen_string_literal: true
class ProblemsController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource id_param: :slug, class: Problem
respond_to :html, :json
def index
@problems = Problem.approved.popular.paginate(page: params[:page])
@num_requested_problems = requested_problems.size if current_member
respond_with @problems
end
def requested
@requested = requested_problems.paginate(page: params[:page])
respond_with @requested
end
def show
@problem = Problem.friendly.find(params[:id])
@plantings = @problem.plantings.paginate(page: params[:page])
respond_with @problem
end
def new
@problem = Problem.new
respond_with @problem
end
def edit; end
def create
@problem = Problem.new(problem_params)
if current_member.role? :problem_wrangler
@problem.creator = current_member
else
@problem.requester = current_member
@problem.approval_status = "pending"
end
@problem.save
respond_with @problem
end
def update
if can?(:wrangle, @problem)
@problem.approval_status = 'rejected' if params.fetch("reject", false)
@problem.approval_status = 'approved' if params.fetch("approve", false)
end
@problem.update(problem_params)
respond_with @problem
end
def wrangle
@approval_status = params[:approval_status]
@problems = case @approval_status
when "pending"
Problem.pending_approval
when "rejected"
Problem.rejected
else
Problem.recent
end.paginate(page: params[:page])
@problem_wranglers = Role.problem_wranglers
respond_with @problems
end
private
def problem_params
params.require(:problem).permit(:name, :reason_for_rejection, :rejection_notes)
end
def requested_problems
current_member.requested_problems.pending_approval
end
end

View File

@@ -6,6 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
prepend_before_action :check_captcha, only: [:create] # Change this to be any actions you want to protect with recaptcha. prepend_before_action :check_captcha, only: [:create] # Change this to be any actions you want to protect with recaptcha.
def edit def edit
@twitter_auth = current_member.auth('twitter')
@flickr_auth = current_member.auth('flickr') @flickr_auth = current_member.auth('flickr')
render "edit" render "edit"
end end

View File

@@ -19,7 +19,9 @@ class SeedsController < DataController
where['parent_planting'] = @planting.id where['parent_planting'] = @planting.id
end end
where['tradeable_to'] = params[:tradeable_to] if params[:tradeable_to].present? if params[:tradeable_to].present?
where['tradeable_to'] = params[:tradeable_to]
end
@show_all = (params[:all] == '1') @show_all = (params[:all] == '1')
where['finished'] = false unless @show_all where['finished'] = false unless @show_all
@@ -56,7 +58,6 @@ class SeedsController < DataController
def create def create
@seed = Seed.new(seed_params) @seed = Seed.new(seed_params)
@seed.finished ||= false
@seed.owner = current_member @seed.owner = current_member
@seed.crop = @seed.parent_planting.crop if @seed.parent_planting @seed.crop = @seed.parent_planting.crop if @seed.parent_planting
flash[:notice] = "Successfully added #{@seed.crop} seed to your stash." if @seed.save flash[:notice] = "Successfully added #{@seed.crop} seed to your stash." if @seed.save

View File

@@ -21,10 +21,6 @@ module ApplicationHelper
classes classes
end end
def count_github_contibutors
File.open(Rails.root.join('CONTRIBUTORS.md')).readlines.grep(/^-/).size
end
# Produces a cache key for uniquely identifying cached fragments. # Produces a cache key for uniquely identifying cached fragments.
def cache_key_for(klass, identifier = "all") def cache_key_for(klass, identifier = "all")
count = klass.count count = klass.count
@@ -36,7 +32,7 @@ module ApplicationHelper
# of HAML, Tilt, and dynamic compilation with interpolated ruby. # of HAML, Tilt, and dynamic compilation with interpolated ruby.
def markdownify(text) def markdownify(text)
translator = Haml::Filters::GrowstuffMarkdown.new translator = Haml::Filters::GrowstuffMarkdown.new
translator.expand_members!(translator.expand_crops!(text.to_s)) translator.expand_members!(translator.expand_problems!(translator.expand_crops!(text.to_s)))
end end
# #
@@ -54,6 +50,7 @@ module ApplicationHelper
uri.query = "&width=#{size}&height=#{size}" if uri.host == 'graph.facebook.com' uri.query = "&width=#{size}&height=#{size}" if uri.host == 'graph.facebook.com'
# TODO: Assess twitter - https://dev.twitter.com/overview/general/user-profile-images-and-banners
# TODO: Assess flickr - https://www.flickr.com/services/api/misc.buddyicons.html # TODO: Assess flickr - https://www.flickr.com/services/api/misc.buddyicons.html
return uri.to_s return uri.to_s

View File

@@ -2,7 +2,6 @@
module ButtonsHelper module ButtonsHelper
include IconsHelper include IconsHelper
def garden_plant_something_button(garden, classes: "btn btn-default") def garden_plant_something_button(garden, classes: "btn btn-default")
return unless can? :edit, garden return unless can? :edit, garden
@@ -53,7 +52,7 @@ module ButtonsHelper
link_to t('buttons.mark_as_inactive'), link_to t('buttons.mark_as_inactive'),
garden_path(garden, garden: { active: 0 }), garden_path(garden, garden: { active: 0 }),
method: :put, class: classes, method: :put, class: classes,
data: { confirm: I18n.t('gardens.confirm_deactivate') } data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' }
end end
def create_button(model_to_create, path, icon, label) def create_button(model_to_create, path, icon, label)
@@ -98,7 +97,7 @@ module ButtonsHelper
end end
def planting_finish_button(planting, classes: 'btn btn-default btn-secondary') def planting_finish_button(planting, classes: 'btn btn-default btn-secondary')
return unless can?(:edit, planting) || planting.finished || planting.failed return unless can?(:edit, planting) || planting.finished
link_to planting_path(slug: planting.slug, planting: { finished: 1 }), link_to planting_path(slug: planting.slug, planting: { finished: 1 }),
method: :put, class: "#{classes} append-date" do method: :put, class: "#{classes} append-date" do
@@ -106,15 +105,6 @@ module ButtonsHelper
end end
end end
def planting_failed_button(planting, classes: 'btn btn-default btn-secondary')
return unless can?(:edit, planting) || planting.finished || planting.failed
link_to planting_path(slug: planting.slug, planting: { failed: 1 }),
method: :put, class: "#{classes}" do
finished_icon + ' ' + t('buttons.mark_as_failed')
end
end
def seed_finish_button(seed, classes: 'btn btn-default') def seed_finish_button(seed, classes: 'btn btn-default')
return unless can?(:create, Planting) && seed.active return unless can?(:create, Planting) && seed.active
@@ -132,7 +122,7 @@ module ButtonsHelper
end end
def planting_save_seeds_button(planting, classes: 'btn btn-default') def planting_save_seeds_button(planting, classes: 'btn btn-default')
return unless can?(:edit, planting) && !planting.failed? return unless can?(:edit, planting)
link_to new_planting_seed_path(planting_slug: planting.slug), class: classes do link_to new_planting_seed_path(planting_slug: planting.slug), class: classes do
seed_icon + ' ' + t('buttons.save_seeds') seed_icon + ' ' + t('buttons.save_seeds')

View File

@@ -43,14 +43,6 @@ module PlantingsHelper
(planting.first_harvest_predicted_at - Time.zone.today).to_i (planting.first_harvest_predicted_at - Time.zone.today).to_i
end end
# Returns a list of gardens the planting can be transplanted to
# based on the planting's owner.
def transplantable_gardens_by_owner(planting)
garden_ids = planting.owner.gardens.select(:id).to_a + GardenCollaborator.where(member_id: planting.owner.id).select(:garden_id).to_a
Garden.active.where.not(id: planting.garden_id).where(id: garden_ids)
end
def days_from_now_to_last_harvest(planting) def days_from_now_to_last_harvest(planting)
return unless planting.planted_at.present? && planting.last_harvest_predicted_at.present? return unless planting.planted_at.present? && planting.last_harvest_predicted_at.present?

View File

@@ -34,6 +34,8 @@ class Ability
# are wranglers or admins # are wranglers or admins
cannot :read, Crop cannot :read, Crop
can :read, Crop, approval_status: "approved" can :read, Crop, approval_status: "approved"
cannot :read, Problem
can :read, Problem, approval_status: "approved"
# scientific names should only be viewable if associated crop is approved # scientific names should only be viewable if associated crop is approved
cannot :read, ScientificName cannot :read, ScientificName
can :read, ScientificName do |sn| can :read, ScientificName do |sn|
@@ -56,6 +58,8 @@ class Ability
# members can see even rejected or pending crops if they requested it # members can see even rejected or pending crops if they requested it
can :read, Crop, requester_id: member.id can :read, Crop, requester_id: member.id
can :requested, Crop # see list of crops they've requested can :requested, Crop # see list of crops they've requested
can :read, Problem, requester_id: member.id
can :requested, Problem
# managing your own user settings # managing your own user settings
can :update, Member, id: member.id can :update, Member, id: member.id
@@ -82,8 +86,14 @@ class Ability
can :gbif, Crop can :gbif, Crop
end end
if member.role? :problem_wrangler
can :wrangle, Problem
can :manage, Problem
end
# any member can create a crop provisionally # any member can create a crop provisionally
can :create, Crop can :create, Crop
can :create, Problem
# can create & destroy their own authentications against other sites. # can create & destroy their own authentications against other sites.
can :create, Authentication can :create, Authentication
@@ -111,10 +121,6 @@ class Ability
can :update, Planting do |planting| can :update, Planting do |planting|
planting.garden.garden_collaborators.where(member_id: member.id).any? planting.garden.garden_collaborators.where(member_id: member.id).any?
end end
can :transplant, Planting, garden: { owner_id: member.id }
can :transplant, Planting do |planting|
planting.garden.garden_collaborators.where(member_id: member.id).any?
end
can :destroy, Planting do |planting| can :destroy, Planting do |planting|
planting.garden.garden_collaborators.where(member_id: member.id).any? planting.garden.garden_collaborators.where(member_id: member.id).any?
end end

View File

@@ -5,7 +5,6 @@ class AlternateName < ApplicationRecord
belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names
validates :name, presence: true validates :name, presence: true
validates :crop, presence: true validates :crop, presence: true
validates :language, presence: true
after_commit :reindex after_commit :reindex

View File

@@ -2,27 +2,26 @@
class Comment < ApplicationRecord class Comment < ApplicationRecord
belongs_to :author, class_name: 'Member', inverse_of: :comments belongs_to :author, class_name: 'Member', inverse_of: :comments
belongs_to :commentable, polymorphic: true, counter_cache: true belongs_to :post, counter_cache: true
# validates :body, presence: true
scope :post_order, -> { order(created_at: :asc) } # for display on post page scope :post_order, -> { order(created_at: :asc) } # for display on post page
after_create do after_create do
recipient = commentable.author.id recipient = post.author.id
sender = author.id sender = author.id
# don't send notifications to yourself # don't send notifications to yourself
if recipient != sender if recipient != sender
Notification.create( Notification.create(
recipient_id: recipient, recipient_id: recipient,
sender_id: sender, sender_id: sender,
subject: "#{author} commented on #{commentable.subject}", subject: "#{author} commented on #{post.subject}",
body:, body:,
notifiable: commentable post_id: post.id
) )
end end
end end
def to_s def to_s
"#{author.login_name} commented on #{commentable.subject}" "#{author.login_name} commented on #{post.subject}"
end end
end end

View File

@@ -8,12 +8,7 @@ module Finishable
scope :current, -> { where.not(finished: true) } scope :current, -> { where.not(finished: true) }
def active def active
# Plantings can fail. At the moment, activities and seeds cannot. !finished
if respond_to?(:failed)
!finished && !failed
else
!finished
end
end end
end end
end end

View File

@@ -4,6 +4,10 @@ module OpenFarmData
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
def update_openfarm_data!
OpenfarmService.new.update_crop(self)
end
def of_photo def of_photo
fetch_attr('main_image_path') fetch_attr('main_image_path')
end end
@@ -39,6 +43,10 @@ module OpenFarmData
fetch_attr('common_names') fetch_attr('common_names')
end end
def guides_count
fetch_attr('guides_count')
end
def binomial_name def binomial_name
fetch_attr('binomial_name') fetch_attr('binomial_name')
end end

View File

@@ -38,7 +38,7 @@ module PredictHarvest
# status # status
def harvest_time? def harvest_time?
return false if crop.perennial || finished || failed return false if crop.perennial || finished
# We have harvests but haven't finished # We have harvests but haven't finished
harvests.size.positive? || harvests.size.positive? ||

View File

@@ -8,12 +8,12 @@ module PredictPlanting
before_save :calculate_lifespan before_save :calculate_lifespan
def calculate_lifespan def calculate_lifespan
self.lifespan = (planted_at.present? && finished_at.present? && !failed? ? finished_at - planted_at : nil) self.lifespan = (planted_at.present? && finished_at.present? ? finished_at - planted_at : nil)
end end
# dates # dates
def finish_predicted_at def finish_predicted_at
if planted_at.blank? || failed? if planted_at.blank?
nil nil
elsif crop.median_lifespan.present? elsif crop.median_lifespan.present?
planted_at + crop.median_lifespan.days planted_at + crop.median_lifespan.days
@@ -34,18 +34,15 @@ module PredictPlanting
end end
def actual_lifespan def actual_lifespan
return unless planted_at.present? && finished_at.present? && !failed? return unless planted_at.present? && finished_at.present?
(finished_at - planted_at).to_i (finished_at - planted_at).to_i
end end
def age_in_days def age_in_days
return if planted_at.blank? return if planted_at.blank?
return if failed?
known_last_day ||= finished_at || Time.zone.today known_last_day ||= finished_at || Time.zone.today
known_last_day = Time.zone.today if known_last_day > Time.zone.today
(known_last_day - planted_at).to_i (known_last_day - planted_at).to_i
end end
@@ -53,9 +50,9 @@ module PredictPlanting
Rails.cache.fetch("#{cache_key_with_version}/percentage_grown", expires_in: 8.hours) do Rails.cache.fetch("#{cache_key_with_version}/percentage_grown", expires_in: 8.hours) do
if finished? if finished?
100 100
elsif !planted? || failed? elsif !planted?
0 0
elsif crop.perennial || (finish_predicted_at.nil? && finished_at.nil?) # This covers future dated finished_at that hasn't occurrred yet. elsif crop.perennial || finish_predicted_at.nil?
nil nil
else else
calculate_percentage_grown calculate_percentage_grown
@@ -74,7 +71,7 @@ module PredictPlanting
end end
def late? def late?
crop.annual? && !finished && !failed && crop.annual? && !finished &&
planted_at.present? && planted_at.present? &&
finish_predicted_at.present? && finish_predicted_at.present? &&
finish_predicted_at <= Time.zone.today finish_predicted_at <= Time.zone.today
@@ -94,9 +91,9 @@ module PredictPlanting
private private
def calculate_percentage_grown def calculate_percentage_grown
return 0 if age_in_days.to_i < 0 return 0 if age_in_days < 0
percent = (age_in_days.to_f / expected_lifespan.to_f) * 100 percent = (age_in_days / expected_lifespan.to_f) * 100
(percent > 100 ? 100 : percent) (percent > 100 ? 100 : percent)
end end
end end

View File

@@ -59,8 +59,7 @@ module SearchSeeds
search('*', limit:, search('*', limit:,
where: { where: {
finished: false, finished: false,
tradable: true, tradable: true
_or: [{ plant_before: nil }, { plant_before: { lt: Date.today } }]
}, },
boost_by: [:created_at], boost_by: [:created_at],
load: false) load: false)

View File

@@ -17,6 +17,7 @@ class Crop < ApplicationRecord
has_many :scientific_names, dependent: :delete_all has_many :scientific_names, dependent: :delete_all
has_many :alternate_names, dependent: :delete_all has_many :alternate_names, dependent: :delete_all
has_many :plantings, dependent: :destroy has_many :plantings, dependent: :destroy
has_many :problems, through: :plantings
has_many :seeds, dependent: :destroy has_many :seeds, dependent: :destroy
has_many :harvests, dependent: :destroy has_many :harvests, dependent: :destroy
has_many :photo_associations, dependent: :delete_all, inverse_of: :crop has_many :photo_associations, dependent: :delete_all, inverse_of: :crop

View File

@@ -59,7 +59,7 @@ class CsvImporter
alternate_names.split(/,\s*/).each do |name| alternate_names.split(/,\s*/).each do |name|
altname = AlternateName.find_by(name:, crop: @crop) altname = AlternateName.find_by(name:, crop: @crop)
altname ||= AlternateName.create! name:, crop: @crop, language: "EN", creator: cropbot altname ||= AlternateName.create! name:, crop: @crop, creator: cropbot
@crop.alternate_names << altname @crop.alternate_names << altname
end end
end end

View File

@@ -10,8 +10,7 @@ class Follow < ApplicationRecord
recipient_id: followed_id, recipient_id: followed_id,
sender_id: follower_id, sender_id: follower_id,
subject: "#{follower.login_name} is now following you", subject: "#{follower.login_name} is now following you",
body: "#{follower.login_name} just followed you on #{ENV.fetch('GROWSTUFF_SITE_NAME', nil)}. ", body: "#{follower.login_name} just followed you on #{ENV.fetch('GROWSTUFF_SITE_NAME', nil)}. "
notifiable: self
) )
end end
end end

View File

@@ -5,7 +5,6 @@ class Garden < ApplicationRecord
include Geocodable include Geocodable
include PhotoCapable include PhotoCapable
include Ownable include Ownable
friendly_id :garden_slug, use: %i(slugged finders) friendly_id :garden_slug, use: %i(slugged finders)
has_many :plantings, dependent: :destroy has_many :plantings, dependent: :destroy
@@ -45,7 +44,6 @@ class Garden < ApplicationRecord
.where.not(gardens: { latitude: nil }) .where.not(gardens: { latitude: nil })
.where.not(gardens: { longitude: nil }) .where.not(gardens: { longitude: nil })
} }
AREA_UNITS_VALUES = { AREA_UNITS_VALUES = {
"square metres" => "square metre", "square metres" => "square metre",
"square feet" => "square foot", "square feet" => "square foot",

View File

@@ -42,6 +42,10 @@ class Member < ApplicationRecord
inverse_of: :requester inverse_of: :requester
has_many :created_crops, class_name: 'Crop', foreign_key: 'creator_id', dependent: :nullify, has_many :created_crops, class_name: 'Crop', foreign_key: 'creator_id', dependent: :nullify,
inverse_of: :creator inverse_of: :creator
has_many :requested_problems, class_name: 'Problem', foreign_key: 'requester_id', dependent: :nullify,
inverse_of: :requester
has_many :created_problems, class_name: 'Problem', foreign_key: 'creator_id', dependent: :nullify,
inverse_of: :creator
has_many :created_alternate_names, class_name: 'AlternateName', foreign_key: 'creator_id', inverse_of: :creator has_many :created_alternate_names, class_name: 'AlternateName', foreign_key: 'creator_id', inverse_of: :creator
has_many :created_scientific_names, class_name: 'ScientificName', foreign_key: 'creator_id', inverse_of: :creator has_many :created_scientific_names, class_name: 'ScientificName', foreign_key: 'creator_id', inverse_of: :creator
@@ -91,9 +95,6 @@ class Member < ApplicationRecord
uniqueness: { uniqueness: {
case_sensitive: false case_sensitive: false
} }
validates :website_url, format: { with: /\Ahttps?:\/\//, message: "must start with http:// or https://" }, allow_blank: true
validates :other_url, format: { with: /\Ahttps?:\/\//, message: "must start with http:// or https://" }, allow_blank: true
validates :instagram_handle, :facebook_handle, :bluesky_handle, format: { without: %r{\Ahttps?:\/\/|\/}, message: "should be a handle, not a URL" }, allow_blank: true
# #
# Triggers # Triggers

View File

@@ -3,7 +3,7 @@
class Notification < ApplicationRecord class Notification < ApplicationRecord
belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications
belongs_to :recipient, class_name: 'Member', inverse_of: :notifications belongs_to :recipient, class_name: 'Member', inverse_of: :notifications
belongs_to :notifiable, polymorphic: true belongs_to :post, optional: true
validates :subject, length: { maximum: 255 } validates :subject, length: { maximum: 255 }

View File

@@ -8,7 +8,6 @@ class Photo < ApplicationRecord
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
has_many :comments, as: :commentable, dependent: :destroy
# This doesn't work, ActiveRecord tries to use the polymoriphic photographable # This doesn't work, ActiveRecord tries to use the polymoriphic photographable
# relationship instead. # relationship instead.
@@ -84,14 +83,6 @@ class Photo < ApplicationRecord
"#{title} by #{owner.login_name}" "#{title} by #{owner.login_name}"
end end
def subject
title
end
def author
owner
end
def flickr_photo_id def flickr_photo_id
source_id if source == 'flickr' source_id if source == 'flickr'
end end

View File

@@ -24,6 +24,8 @@ class Planting < ApplicationRecord
belongs_to :crop, counter_cache: true belongs_to :crop, counter_cache: true
has_many :harvests, dependent: :destroy has_many :harvests, dependent: :destroy
has_many :activities, dependent: :destroy has_many :activities, dependent: :destroy
has_many :planting_problems, dependent: :destroy
has_many :problems, through: :planting_problems
# #
# Ancestry of food # Ancestry of food
@@ -43,8 +45,7 @@ class Planting < ApplicationRecord
.where.not(gardens: { latitude: nil }) .where.not(gardens: { latitude: nil })
.where.not(gardens: { longitude: nil }) .where.not(gardens: { longitude: nil })
} }
scope :active, -> { where(finished: false, failed: false).where('finished_at IS NULL OR finished_at < ?', Time.zone.now) } scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) }
scope :failed, -> { where(failed: true) }
scope :annual, -> { joins(:crop).where(crops: { perennial: false }) } scope :annual, -> { joins(:crop).where(crops: { perennial: false }) }
scope :perennial, -> { joins(:crop).where(crops: { perennial: true }) } scope :perennial, -> { joins(:crop).where(crops: { perennial: true }) }
scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) }
@@ -73,7 +74,6 @@ class Planting < ApplicationRecord
validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validates :crop, presence: true, approved: { message: "must be present and exist in our database" }
validate :finished_must_be_after_planted validate :finished_must_be_after_planted
validate :owner_must_match_garden_owner validate :owner_must_match_garden_owner
validate :cannot_be_finished_and_failed
validates :quantity, allow_nil: true, numericality: { validates :quantity, allow_nil: true, numericality: {
only_integer: true, greater_than_or_equal_to: 0 only_integer: true, greater_than_or_equal_to: 0
} }
@@ -98,11 +98,7 @@ class Planting < ApplicationRecord
end end
def finished? def finished?
(finished || (finished_at.present? && finished_at <= Time.zone.today)) && !failed? finished || (finished_at.present? && finished_at <= Time.zone.today)
end
def failed?
failed
end end
def planted? def planted?
@@ -126,10 +122,6 @@ class Planting < ApplicationRecord
private private
def cannot_be_finished_and_failed
errors.add(:failed, "can't be true if planting is also finished") if finished && failed
end
# check that any finished_at date occurs after planted_at # check that any finished_at date occurs after planted_at
def finished_must_be_after_planted def finished_must_be_after_planted
return unless planted_at && finished_at # only check if we have both return unless planted_at && finished_at # only check if we have both

View File

@@ -0,0 +1,8 @@
# frozen_string_literal: true
class PlantingProblem < ApplicationRecord
include PhotoCapable
belongs_to :planting
belongs_to :problem
end

View File

@@ -3,7 +3,6 @@
class Post < ApplicationRecord class Post < ApplicationRecord
extend FriendlyId extend FriendlyId
include Likeable include Likeable
friendly_id :author_date_subject, use: %i(slugged finders) friendly_id :author_date_subject, use: %i(slugged finders)
include PhotoCapable include PhotoCapable
@@ -11,15 +10,17 @@ class Post < ApplicationRecord
# Relationships # Relationships
belongs_to :author, class_name: 'Member', inverse_of: :posts belongs_to :author, class_name: 'Member', inverse_of: :posts
belongs_to :forum, optional: true belongs_to :forum, optional: true
has_many :comments, as: :commentable, dependent: :destroy has_many :comments, dependent: :destroy
has_many :crop_posts, dependent: :delete_all has_many :crop_posts, dependent: :delete_all
has_many :crops, through: :crop_posts has_many :crops, through: :crop_posts
has_many :notifications, as: :notifiable, dependent: :destroy has_many :problem_posts, dependent: :delete_all
has_many :problems, through: :problem_posts
after_create :send_notification after_create :send_notification
# #
# Triggers # Triggers
after_save :update_crop_posts_association after_save :update_crop_posts_association
after_save :update_problem_posts_association
default_scope { joins(:author).merge(Member.kept) } # Ensures the owner still exists default_scope { joins(:author).merge(Member.kept) } # Ensures the owner still exists
@@ -77,6 +78,17 @@ class Post < ApplicationRecord
end end
end end
def update_problem_posts_association
problems.clear
# look for problems mentioned in the post. eg. [aphids](problem)
body.scan(Haml::Filters::GrowstuffMarkdown::PROBLEM_REGEX) do |_m|
problem_name = Regexp.last_match(1)
problem = Problem.case_insensitive_name(problem_name).first
# create association
problems << problem if problem && problems.exclude?(problem)
end
end
def send_notification def send_notification
recipients = [] recipients = []
sender = author.id sender = author.id
@@ -97,7 +109,6 @@ class Post < ApplicationRecord
Notification.create( Notification.create(
recipient_id:, recipient_id:,
sender_id: sender, sender_id: sender,
notifiable: self,
subject: "#{author} mentioned you in their post #{subject}", subject: "#{author} mentioned you in their post #{subject}",
body: body:
) )

88
app/models/problem.rb Normal file
View File

@@ -0,0 +1,88 @@
# frozen_string_literal: true
class Problem < ApplicationRecord
extend FriendlyId
include PhotoCapable
include SearchCrops # Note: This might need to be adapted to SearchProblems
friendly_id :name, use: %i(slugged finders)
##
## Relationships
belongs_to :creator, class_name: 'Member', optional: true, inverse_of: :created_problems
belongs_to :requester, class_name: 'Member', optional: true, inverse_of: :requested_problems
has_many :planting_problems, dependent: :delete_all
has_many :plantings, through: :planting_problems
has_many :problem_posts, dependent: :delete_all
has_many :posts, through: :problem_posts, dependent: :delete_all
##
## Scopes
scope :recent, -> { approved.order(created_at: :desc) }
scope :popular, -> { approved.order(Arel.sql("plantings_count desc, lower(name) asc")) }
scope :pending_approval, -> { where(approval_status: "pending") }
scope :approved, -> { where(approval_status: "approved") }
scope :rejected, -> { where(approval_status: "rejected") }
scope :interesting, -> { approved.has_photos }
scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) }
##
## Validations
validates :reason_for_rejection, presence: true, if: :rejected?
validate :must_be_rejected_if_rejected_reasons_present
validate :must_have_meaningful_reason_for_rejection
validates :name, uniqueness: { scope: :approval_status }, if: :pending?
def to_s
name
end
def to_param
slug
end
def pending?
approval_status == "pending"
end
def approved?
approval_status == "approved"
end
def rejected?
approval_status == "rejected"
end
def approval_statuses
%w(rejected pending approved)
end
def reasons_for_rejection
["already in database", "not a pest or disease", "not enough information", "other"]
end
def rejection_explanation
return rejection_notes if reason_for_rejection == "other"
reason_for_rejection
end
def self.case_insensitive_name(name)
where(["lower(problems.name) = :value", { value: name.downcase }])
end
private
def must_be_rejected_if_rejected_reasons_present
return if rejected?
return unless reason_for_rejection.present? || rejection_notes.present?
errors.add(:approval_status, "must be rejected if a reason for rejection is present")
end
def must_have_meaningful_reason_for_rejection
return unless reason_for_rejection == "other" && rejection_notes.blank?
errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"")
end
end

View File

@@ -0,0 +1,6 @@
# frozen_string_literal: true
class ProblemPost < ApplicationRecord
belongs_to :problem
belongs_to :post
end

View File

@@ -8,7 +8,7 @@ class Role < ApplicationRecord
has_and_belongs_to_many :members has_and_belongs_to_many :members
class << self class << self
%i(crop_wranglers admins).each do |method| %i(crop_wranglers admins problem_wranglers).each do |method|
define_method method do define_method method do
slug = method.to_s.singularize.dasherize slug = method.to_s.singularize.dasherize
Role.where(slug:).try(:first).try(:members) Role.where(slug:).try(:first).try(:members)

View File

@@ -59,7 +59,6 @@ class Seed < ApplicationRecord
scope :has_location, -> { joins(:owner).where.not('members.location': nil) } scope :has_location, -> { joins(:owner).where.not('members.location': nil) }
scope :recent, -> { order(created_at: :desc) } scope :recent, -> { order(created_at: :desc) }
scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) } scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) }
scope :expired, -> { active.where('plant_before < ?', Time.zone.today) }
def tradable def tradable
tradable_to != 'nowhere' tradable_to != 'nowhere'

View File

@@ -13,7 +13,6 @@ module Api
attribute :slug attribute :slug
attribute :planted_at attribute :planted_at
attribute :failed
attribute :finished attribute :finished
attribute :finished_at attribute :finished_at
attribute :quantity attribute :quantity
@@ -38,7 +37,9 @@ module Api
filter :finished filter :finished
attribute :percentage_grown attribute :percentage_grown
delegate :percentage_grown, to: :@model def percentage_grown
@model.percentage_grown
end
attribute :crop_name attribute :crop_name
attribute :crop_slug attribute :crop_slug

View File

@@ -47,7 +47,7 @@
.row .row
.col-md-6 .col-md-6
= f.check_box :finished, label: t('buttons.mark_as_finished') = f.check_box :finished, label: 'Mark as finished'
%span.help-block= t('.finish_helper') %span.help-block= t('.finish_helper')
.card-footer .card-footer

View File

@@ -31,8 +31,7 @@
= f.label :name, class: 'control-label col-md-2' = f.label :name, class: 'control-label col-md-2'
.col-md-8 .col-md-8
= f.text_field :name, class: 'form-control' = f.text_field :name, class: 'form-control'
.col-md-8
= f.select :language, I18nData.languages.map {|code, name| [name.split(";").first, code] }, class: 'form-control'
.form-group .form-group
.form-actions.col-md-offset-2.col-md-8 .form-actions.col-md-offset-2.col-md-8
= f.submit 'Save', class: 'btn btn-primary' = f.submit 'Save', class: 'btn btn-primary'

View File

@@ -1 +1 @@
#{link_to 'commented', event_model} on #{link_to event_model.commentable, event_model.commentable} #{link_to 'commented', event_model} on #{link_to event_model.post, event_model.post}

View File

@@ -1,4 +1,3 @@
- @comment ||= Comment.new(commentable: @commentable)
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
.card-body .card-body
- if content_for? :title - if content_for? :title
@@ -15,13 +14,13 @@
%li= msg %li= msg
.md-form .md-form
= f.text_area :body, rows: 6, class: 'form-control md-textarea', autofocus: 'autofocus', required: true, pattern: '\w+' = f.text_area :body, rows: 6, class: 'form-control md-textarea', autofocus: 'autofocus'
= f.label :body, "Your comment:" = f.label :body, "Your comment:"
%span.help-block %span.help-block
= render partial: "shared/markdown_help" = render partial: "shared/markdown_help"
.actions.text-right .actions.text-right
= f.submit 'Post comment', class: 'btn btn-primary' = f.submit 'Post comment', class: 'btn btn-primary'
.field - if defined?(@post)
= f.hidden_field :commentable_id, value: @commentable.id .field
= f.hidden_field :commentable_type, value: @commentable.class.name = f.hidden_field :post_id, value: @post.id

View File

@@ -2,6 +2,6 @@
%p %p
Editing comment on Editing comment on
= link_to @comment.commentable.subject, @comment.commentable = link_to @comment.post.subject, @comment.post
= render 'form', locals: { comment: @comment, commentable: @comment.commentable } = render 'form'

View File

@@ -5,18 +5,17 @@
%link= comments_url %link= comments_url
- @comments.each do |comment| - @comments.each do |comment|
%item %item
%title Comment by #{comment.author.login_name} on #{comment.commentable.subject} %title Comment by #{comment.author.login_name} on #{comment.post.subject}
%description %description
:escaped_markdown :escaped_markdown
<p> <p>
Comment on Comment on
#{ link_to comment.commentable.subject, polymorphic_url(comment.commentable) } #{ link_to comment.post.subject, post_url(comment.post) }
</p> </p>
:escaped_markdown :escaped_markdown
#{ strip_tags markdownify(comment.body) } #{ strip_tags markdownify(comment.body) }
%pubdate= comment.created_at.to_fs(:rfc822) %pubdate= comment.created_at.to_fs(:rfc822)
%link= polymorphic_url(comment.commentable) %link= post_url(comment.post)
%guid= comment_url(comment) %guid= comment_url(comment)

View File

@@ -1,17 +1,11 @@
= content_for :title, "New comment" = content_for :title, "New comment"
- if @commentable.is_a?(Post)
%section.blog-post
.card.post{ id: "post-#{@commentable.id}" }
.card-header
%h2.display-3= @commentable.subject
.card-body= render "posts/single", post: @commentable || @comment.commentable, subject: true
- elsif @commentable.is_a?(Photo)
%section.blog-post
.card.photo{ id: "photo-#{@commentable.id}" }
.card-header
%h2.display-3= @commentable.subject
.card-body= render "photos/card", photo: @commentable || @comment.commentable, subject: true
= render partial: "comments/comments", locals: { commentable: @commentable || @comment.commentable } %section.blog-post
.card.post{ id: "post-#{@post.id}" }
.card-header
%h2.display-3= @post.subject
.card-body= render "posts/single", post: @post || @comment.post, subject: true
= render 'form', locals: { comment: @comment, commentable: @commentable || @comment.commentable } = render partial: "posts/comments", locals: { post: @post || @comment.post }
= render 'form'

View File

@@ -1,6 +1,6 @@
- if crop.approved? && signed_in? - if crop.approved? && signed_in?
.btn-group.crop-actions{"aria-label" => "Crop Actions", role: "group"} .btn-group{"aria-label" => "Crop Actions", role: "group"}
= render 'plantings/modal', planting: Planting.new(crop: crop, owner: current_member) = render 'plantings/modal', planting: Planting.new(crop: crop, owner: current_member)
= render 'harvests/modal', harvest: Harvest.new(crop: @crop, owner: current_member) = render 'harvests/modal', harvest: Harvest.new(crop: @crop, owner: current_member)
= render 'seeds/modal', seed: Seed.new(crop: @crop, owner: current_member) = render 'seeds/modal', seed: Seed.new(crop: @crop, owner: current_member)

View File

@@ -5,7 +5,7 @@
- if can? :edit, an - if can? :edit, an
.dropdown.planting-actions .dropdown.planting-actions
%a#crop-actions-altnames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", :type => "button", :href => '#'} %a#crop-actions-altnames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", :type => "button", :href => '#'}
= "#{an.name} (#{an.language})" = an.name
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-altnames"} .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-altnames"}
- if can? :edit, an - if can? :edit, an
= link_to edit_alternate_name_path(an), class: 'dropdown-item' do = link_to edit_alternate_name_path(an), class: 'dropdown-item' do
@@ -16,7 +16,7 @@
= delete_icon = delete_icon
= t('.delete') = t('.delete')
- else - else
.badge= "#{an.name} (#{an.language})" .badge= an.name
%p.text-right %p.text-right

View File

@@ -25,9 +25,9 @@
Last harvest expected Last harvest expected
%strong= crop.median_days_to_last_harvest %strong= crop.median_days_to_last_harvest
days after planting days after planting
- if member_signed_in? - if member_signed_in?
.card-footer .card-footer
.d-flex.btn-group-vertical .d-flex.justify-content-between
= render 'plantings/modal', planting: Planting.new(crop: crop, owner: current_member) = render 'plantings/modal', planting: Planting.new(crop: crop, owner: current_member)
- #= render 'harvests/modal', harvest: Harvest.new(crop: crop, owner: current_member) - #= render 'harvests/modal', harvest: Harvest.new(crop: crop, owner: current_member)
= render 'seeds/modal', seed: Seed.new(crop: crop, owner: current_member) = render 'seeds/modal', seed: Seed.new(crop: crop, owner: current_member)

View File

@@ -0,0 +1,5 @@
- if crop.guides_count.present? && crop.guides_count.positive?
%p
There are
= link_to "https://openfarm.cc/en/crops/#{CGI.escape @crop.name.gsub(' ', '-').downcase}" do
#{crop.guides_count} growing guides on Open Farm

View File

@@ -10,6 +10,10 @@
= edit_icon = edit_icon
= t('.edit') = t('.edit')
= link_to crop_openfarm_path(crop), method: :post, class: 'dropdown-item' do
= icon 'far', 'update'
Fetch data from OpenFarm
= link_to crop_gbif_path(crop), method: :post, class: 'dropdown-item' do = link_to crop_gbif_path(crop), method: :post, class: 'dropdown-item' do
= icon 'far', 'update' = icon 'far', 'update'
Fetch data from GBIF Fetch data from GBIF

View File

@@ -30,6 +30,15 @@
- @crop.companions.each do |companion| - @crop.companions.each do |companion|
= render 'crops/tiny', crop: companion = render 'crops/tiny', crop: companion
- if @problems.any?
%section.problems
%h2 Problems
- @problems.group_by(&:name).each do |problem_name, problems|
- problem = problems.first
= link_to problem_path(problem) do
= problem_name
%span.badge.badge-secondary= problems.size
%section.photos %section.photos
= cute_icon = cute_icon
= render 'crops/photos', crop: @crop = render 'crops/photos', crop: @crop
@@ -74,6 +83,7 @@
.card-body .card-body
%h4 How to grow #{@crop.name.pluralize} %h4 How to grow #{@crop.name.pluralize}
= render 'grown_for', crop: @crop = render 'grown_for', crop: @crop
= render 'planting_advice', crop: @crop
- if @crop.parent - if @crop.parent
%hr/ %hr/
%p.parent-crop %p.parent-crop
@@ -123,6 +133,13 @@
= icon 'fas', 'external-link-alt' = icon 'fas', 'external-link-alt'
Wikipedia (English) Wikipedia (English)
%li.list-group-item
= link_to "https://openfarm.cc/en/crops/#{CGI.escape @crop.name.gsub(' ', '-')}",
class: 'card-link',
target: "_blank",
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
OpenFarm - Growing guide
%li.list-group-item %li.list-group-item
= link_to "https://www.gardenate.com/plant/#{CGI.escape @crop.name}", = link_to "https://www.gardenate.com/plant/#{CGI.escape @crop.name}",
target: "_blank", target: "_blank",
@@ -139,14 +156,6 @@
= icon 'fas', 'external-link-alt' = icon 'fas', 'external-link-alt'
Google Google
%li.list-group-item
= link_to 'https://chat.openai.com/?model=gpt-4o&prompt=' + CGI.escape(['How do I grow', @crop.name, "and what grows well with it? What should I plant the next season if practicing crop rotation? Explain why and add links to your sources"].join(' ')),
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
ChatGPT
%li.list-group-item %li.list-group-item
= link_to "https://wikihow.com/wikiHowTo?search=#{CGI.escape "grow #{@crop.name}" }", = link_to "https://wikihow.com/wikiHowTo?search=#{CGI.escape "grow #{@crop.name}" }",
target: "_blank", target: "_blank",

View File

@@ -3,6 +3,19 @@
html: { method: :put, class: 'form-horizontal' }) do |_f| html: { method: :put, class: 'form-horizontal' }) do |_f|
%br/ %br/
= render 'devise/shared/error_messages', resource: resource = render 'devise/shared/error_messages', resource: resource
.row
.col-md-12
%p
= image_tag "twitter_32.png", size: "32x32", alt: 'Twitter logo'
- if @twitter_auth
You are connected to Twitter as
= link_to @twitter_auth.name, "https://twitter.com/#{@twitter_auth.name}"
= link_to "Disconnect", @twitter_auth,
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove btn btn-danger"
- else
= link_to 'Connect to Twitter', '/members/auth/twitter', class: 'btn'
.row .row
.col-md-12 .col-md-12
%p %p

View File

@@ -13,32 +13,7 @@
.form-group .form-group
= f.label :bio, class: 'control-label col-md-2' = f.label :bio, class: 'control-label col-md-2'
.col-md-8 .col-md-8
= f.text_area :bio, rows: 6, class: 'form-control', placeholder: "I'm am XYZ gardener interested in A, B, C" = f.text_area :bio, rows: 6, class: 'form-control'
.form-group
= f.label :website_url, 'Website', class: 'control-label col-md-2'
.col-md-8
= f.url_field :website_url, class: 'form-control', placeholder: "https://you.example.com/"
.form-group
= f.label :instagram_handle, 'Instagram', class: 'control-label col-md-2'
.col-md-8
= f.text_field :instagram_handle, class: 'form-control', placeholder: 'your_handle'
.form-group
= f.label :facebook_handle, 'Facebook', class: 'control-label col-md-2'
.col-md-8
= f.text_field :facebook_handle, class: 'form-control', placeholder: 'your_handle'
.form-group
= f.label :bluesky_handle, 'Bluesky', class: 'control-label col-md-2'
.col-md-8
= f.text_field :bluesky_handle, class: 'form-control', placeholder: 'your_handle'
.form-group
= f.label :other_url, 'Other URL', class: 'control-label col-md-2'
.col-md-8
= f.url_field :other_url, class: 'form-control', placeholder: "https://you.example.com/"
.form-group .form-group
%label.control-label.col-md-2 %label.control-label.col-md-2

View File

@@ -15,4 +15,5 @@
- if can?(:destroy, garden) - if can?(:destroy, garden)
.dropdown-divider .dropdown-divider
= delete_button(garden, classes: 'dropdown-item text-danger', message: 'gardens.confirm_delete') = delete_button(garden, classes: 'dropdown-item text-danger',
message: 'All plantings associated with this garden will also be deleted. Are you sure?')

View File

@@ -66,7 +66,8 @@
- if can?(:destroy, @garden) - if can?(:destroy, @garden)
.dropdown-divider .dropdown-divider
= delete_button(@garden, classes: 'dropdown-item text-danger', message: 'gardens.confirm_delete') = delete_button(@garden, classes: 'dropdown-item text-danger',
message: 'All plantings associated with this garden will also be deleted. Are you sure?')
%section %section
%h2 Current activities in garden %h2 Current activities in garden

View File

@@ -4,6 +4,4 @@
member: link_to(t('.member_linktext', count: Member.confirmed.size.to_i), members_path), member: link_to(t('.member_linktext', count: Member.confirmed.size.to_i), members_path),
number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path), number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path),
number_plantings: link_to(t('.number_plantings_linktext', count: Planting.count.to_i), plantings_path), number_plantings: link_to(t('.number_plantings_linktext', count: Planting.count.to_i), plantings_path),
number_gardens: link_to(t('.number_gardens_linktext', count: Garden.count.to_i), gardens_path), number_gardens: link_to(t('.number_gardens_linktext', count: Garden.count.to_i), gardens_path))
contributors: link_to(count_github_contibutors, 'https://github.com/Growstuff/growstuff/blob/dev/CONTRIBUTORS.md', target: '_blank', rel: 'noopener'),
github: link_to('GitHub', 'http://github.com/Growstuff/growstuff', target: '_blank', rel: 'noopener'))

View File

@@ -8,7 +8,6 @@
%p= render 'stats', cached: true %p= render 'stats', cached: true
.col .col
%br
%p %p
- if current_member.plantings.active.any? - if current_member.plantings.active.any?
= link_to member_path(current_member, anchor: "#content"), class: 'btn btn-dark' do = link_to member_path(current_member, anchor: "#content"), class: 'btn btn-dark' do
@@ -62,16 +61,3 @@
%section.members %section.members
= cute_icon = cute_icon
= render 'members', cached: true = render 'members', cached: true
.col-12.col-lg-6
%section.pwa-install
= cute_icon
%h2.text-center= t('home.pwa_title')
.index-cards
.card
.card-body
%h3= t('home.pwa_ios_title')
%p= t('home.pwa_ios_steps_html')
.card
.card-body
%h3= t('home.pwa_android_title')
%p= t('home.pwa_android_steps_html')

View File

@@ -6,6 +6,6 @@
%span.site-name Growstuff %span.site-name Growstuff
.nav= render 'crops/search_bar' .nav= render 'crops/search_bar'
.nav .nav
%button.navbar-toggler.ml-auto{ "aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-bs-target" => "#navbarSupportedContent", "data-bs-toggle" => "collapse", type: "button" } %button.navbar-toggler{ "aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-bs-target" => "#navbarSupportedContent", "data-bs-toggle" => "collapse", type: "button" }
%span.navbar-toggler-icon %i.fas.fa-ellipsis-v.navbar-toggler-icon
= render 'layouts/menu' = render 'layouts/menu'

View File

@@ -1,5 +1,5 @@
#navbarSupportedContent.collapse.navbar-collapse #navbarSupportedContent.collapse.navbar-collapse
%ul.navbar-nav.mr-auto.bg-dark %ul.navbar-nav.mr-auto
- if signed_in? - if signed_in?
%li.nav-item %li.nav-item
= link_to timeline_index_path, method: :get, class: 'nav-link text-white' do = link_to timeline_index_path, method: :get, class: 'nav-link text-white' do
@@ -30,9 +30,7 @@
- cache("everyone-menu", expires_in: 1.week) do - cache("everyone-menu", expires_in: 1.week) do
%li.nav-item.dropdown %li.nav-item.dropdown
%a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"} %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"}= t('.crops')
%span
= t('.crops')
.dropdown-menu .dropdown-menu
= link_to crops_path, class: 'dropdown-item' do = link_to crops_path, class: 'dropdown-item' do
= t('.browse_crops') = t('.browse_crops')
@@ -46,9 +44,7 @@
= harvest_icon = harvest_icon
= t('.harvests') = t('.harvests')
%li.nav-item.dropdown %li.nav-item.dropdown
%a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"} %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"}= t('.community')
%span
= t('.community')
.dropdown-menu{"aria-labelledby" => "navbarDropdown"} .dropdown-menu{"aria-labelledby" => "navbarDropdown"}
= link_to t('.community_map'), places_path, class: 'dropdown-item' = link_to t('.community_map'), places_path, class: 'dropdown-item'
= link_to t('.browse_members'), members_path, class: 'dropdown-item' = link_to t('.browse_members'), members_path, class: 'dropdown-item'
@@ -58,9 +54,7 @@
- if member_signed_in? - if member_signed_in?
- if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - if current_member.role?(:crop_wrangler) || current_member.role?(:admin)
%li.nav-item.dropdown %li.nav-item.dropdown
%a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"} %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", href: "#", role: "button"}= t('.admin')
%span
= t('.admin')
.dropdown-menu{"aria-labelledby" => "navbarDropdown"} .dropdown-menu{"aria-labelledby" => "navbarDropdown"}
- if current_member.role?(:crop_wrangler) - if current_member.role?(:crop_wrangler)
= link_to t('.crop_wrangling'), wrangle_crops_path, class: 'dropdown-item' = link_to t('.crop_wrangling'), wrangle_crops_path, class: 'dropdown-item'

View File

@@ -1 +1,13 @@
%h2 All about #{member.login_name} %h2 All about #{member.login_name}
%p
%small
%a{href: "#content"}
Skip to main content
- if member.bio.blank?
- if can? :edit, member
= link_to "Add a bio to complete your profile.", edit_member_registration_path
- else
#{member.login_name} hasn't written a bio yet.
- else
:markdown
#{ strip_tags markdownify(member.bio) }

View File

@@ -1,37 +1,17 @@
- if member.website_url.present? || member.instagram_handle.present? || member.facebook_handle.present? || member.bluesky_handle.present? || member.other_url.present? || flickr_auth || member.show_email - if twitter_auth || flickr_auth || member.show_email
%h4 Contact %h4 Contact
- if member.website_url.present? - if twitter_auth
%p %p
= icon 'fas', 'globe', class: 'fa-fw' = image_tag "twitter_32.png", size: "32x32", alt: 'Twitter logo'
= link_to "Website", member.website_url, target: '_blank', rel: 'noopener noreferrer' = link_to twitter_auth.name, "https://twitter.com/#{twitter_auth.name}"
- if member.instagram_handle.present?
%p
= icon 'fab', 'instagram', class: 'fa-fw'
= link_to member.instagram_handle, "https://instagram.com/#{member.instagram_handle}", target: '_blank', rel: 'noopener noreferrer'
- if member.facebook_handle.present?
%p
= icon 'fab', 'facebook', class: 'fa-fw'
= link_to member.facebook_handle, "https://facebook.com/#{member.facebook_handle}", target: '_blank', rel: 'noopener noreferrer'
- if member.bluesky_handle.present?
%p
= icon 'fas', 'comment-dots', class: 'fa-fw'
= link_to member.bluesky_handle, "https://bsky.app/profile/#{member.bluesky_handle}", target: '_blank', rel: 'noopener noreferrer'
- if member.other_url.present?
%p
= icon 'fas', 'link', class: 'fa-fw'
= link_to "More...", member.other_url, target: '_blank', rel: 'noopener noreferrer'
- if flickr_auth - if flickr_auth
%p %p
= image_tag "flickr_32.png", size: "32x32", alt: 'Flickr logo' = image_tag "flickr_32.png", size: "32x32", alt: 'Flickr logo'
= link_to flickr_auth.name, "https://flickr.com/photos/#{flickr_auth.uid}", target: '_blank', rel: 'noopener noreferrer' = link_to flickr_auth.name, "https://flickr.com/photos/#{flickr_auth.uid}"
- if member.show_email - if member.show_email
%p %p
= icon 'fas', 'envelope', class: 'fa-fw' Email:
= mail_to member.email = mail_to member.email

View File

@@ -5,5 +5,5 @@
= link_to member.location, place_path(member.location, anchor: "members") = link_to member.location, place_path(member.location, anchor: "members")
- else - else
.location-not-set .location-not-set
%h1 Location not known or geocodable .sr-only Location not known
%p We can't show you what's nearby .sr-only We can't show you what's nearby

View File

@@ -1,5 +1,5 @@
- cache member do - cache member do
.card .card.card-double
.card-body .card-body
%h4.login-name= link_to member, member %h4.login-name= link_to member, member
%div %div

View File

@@ -21,21 +21,6 @@
.row .row
.col= render "bio", member: @member .col= render "bio", member: @member
.col= render "avatar", member: @member .col= render "avatar", member: @member
.row
.col
%p
%small
%a{href: "#content"}
Skip to main content
- if @member.bio.blank?
- if member_signed_in? && current_member == @member
= link_to "Add a bio to complete your profile.", edit_member_registration_path
- else
#{@member.login_name} hasn't written a bio yet.
- else
:markdown
#{ strip_tags markdownify(@member.bio) }
- if @member.roles.any? - if @member.roles.any?
%p %p
- @member.roles.each do |role| - @member.roles.each do |role|
@@ -45,16 +30,12 @@
= icon 'fas', 'map-marker' = icon 'fas', 'map-marker'
= truncate(@member.location, length: 15, separator: ' ', omission: '... ') = truncate(@member.location, length: 15, separator: ' ', omission: '... ')
%p %p
%small %strong Member since
%strong Member since = @member.created_at.to_fs(:date)
%br
= @member.created_at.to_fs(:date)
- if @member.last_sign_in_at - if @member.last_sign_in_at
%p %p
%small %strong Last Login
%strong Last Login = @member.last_sign_in_at&.to_fs(:default)
%br
= @member.last_sign_in_at&.to_fs(:default)
- if can? :update, @member - if can? :update, @member
= link_to edit_member_registration_path, class: 'btn btn-block' do = link_to edit_member_registration_path, class: 'btn btn-block' do
@@ -77,13 +58,14 @@
= render "stats", member: @member = render "stats", member: @member
.card-footer .card-footer
= render "contact", member: @member, flickr_auth: @flickr_auth = render "contact", member: @member, twitter_auth: @twitter_auth,
flickr_auth: @flickr_auth
.col-md-10#content .col-md-10#content
.row .row
%section.order-3.order-md-1.col-12= render "map", member: @member %section.order-3.order-md-1.col-12= render "map", member: @member
- if @harvesting.size.positive? - if @harvesting.size.positive?
%section.harvests.order-2.order-md-1.col-12 %section.harvests.order-2.order-md-1
%h2 Ready to harvest %h2 Ready to harvest
.index-cards .index-cards
- @harvesting.each do |planting| - @harvesting.each do |planting|

View File

@@ -46,12 +46,4 @@
- else - else
= @photo.license_name = @photo.license_name
= render "associations", photo: @photo = render "associations", photo: @photo
.row
- if can? :create, Comment
= link_to new_comment_path(comment: { commentable_type: 'Photo', commentable_id: @photo.id }), class: 'btn' do
= icon 'fas', 'comment'
Comment
.row
.col-md-9
= render 'comments/comments', commentable: @photo

View File

@@ -7,16 +7,7 @@
- if planting.active - if planting.active
= planting_plan_something_button(planting, classes: 'dropdown-item') = planting_plan_something_button(planting, classes: 'dropdown-item')
= planting_finish_button(planting, classes: 'dropdown-item') = planting_finish_button(planting, classes: 'dropdown-item')
= planting_failed_button(planting, classes: 'dropdown-item')
= planting_harvest_button(planting, classes: 'dropdown-item') = planting_harvest_button(planting, classes: 'dropdown-item')
= planting_save_seeds_button(planting, classes: 'dropdown-item') = planting_save_seeds_button(planting, classes: 'dropdown-item')
- if can?(:transplant, planting) && planting.active && transplantable_gardens_by_owner(planting).any?
.dropdown-divider
.px-2
= form_tag transplant_planting_path(planting), method: :post do
.form-group
= label_tag :garden_id, 'Transplant to:'
= select_tag :garden_id, options_from_collection_for_select(transplantable_gardens_by_owner(planting), :id, :name), class: 'form-control form-control-sm'
= submit_tag 'Transplant', class: 'btn btn-sm btn-primary mt-2'
.dropdown-divider .dropdown-divider
= delete_button(planting, classes: 'dropdown-item text-danger') = delete_button(planting, classes: 'dropdown-item text-danger')

View File

@@ -19,7 +19,6 @@
- if planting.active - if planting.active
= planting_finish_button(planting, classes: 'dropdown-item') = planting_finish_button(planting, classes: 'dropdown-item')
= planting_failed_button(planting, classes: 'dropdown-item')
= planting_harvest_button(planting, classes: 'dropdown-item') = planting_harvest_button(planting, classes: 'dropdown-item')
= planting_save_seeds_button(planting, classes: 'dropdown-item') = planting_save_seeds_button(planting, classes: 'dropdown-item')

View File

@@ -1,14 +1,13 @@
%h2 Seeds saved %h2 Seeds saved
- if can?(:edit, planting) && !planting.failed? %a.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", role: "button"}
%a.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", role: "button"} = seed_icon
= seed_icon = t('buttons.save_seeds')
= t('buttons.save_seeds') .dropdown-menu.dropdown-secondary
.dropdown-menu.dropdown-secondary - Seed::TRADABLE_TO_VALUES.each do |trade|
- Seed::TRADABLE_TO_VALUES.each do |trade| = link_to seeds_path(return: 'planting', seed: {crop_id: planting.crop.id, parent_planting_id: planting.id, tradable_to: trade}), method: :post, class: 'dropdown-item' do
= link_to seeds_path(return: 'planting', seed: {crop_id: planting.crop.id, parent_planting_id: planting.id, tradable_to: trade}), method: :post, class: 'dropdown-item' do Will trade:
Will trade: = trade
= trade
- if planting.child_seeds.size.positive? - if planting.child_seeds.size.positive?
.index-cards .index-cards

View File

@@ -21,7 +21,7 @@
- if planting.finish_is_predicatable? - if planting.finish_is_predicatable?
.card.fact-card .card.fact-card
%h3 Progress %h3 Progress
- if planting.age_in_days.to_i < 0 - if planting.age_in_days < 0
%strong Planned %strong Planned
- else - else
%strong #{planting.age_in_days}/#{planting.expected_lifespan} %strong #{planting.age_in_days}/#{planting.expected_lifespan}
@@ -40,12 +40,12 @@
- if planting.quantity.to_i.positive? && planting.planted_from.present? - if planting.quantity.to_i.positive? && planting.planted_from.present?
= planting.planted_from.pluralize(planting.quantity.to_i) = planting.planted_from.pluralize(planting.quantity.to_i)
- unless planting.finished? || planting.failed? - unless planting.finished?
.card.fact-card.grid-sizer .card.fact-card.grid-sizer
%h3 Growing %h3 Growing
%strong= seedling_icon %strong= seedling_icon
%span %span
- if planting.age_in_days.to_i < 0 - if planting.age_in_days < 0
Planting planned Planting planned
- else - else
Planting is still growing today Planting is still growing today

View File

@@ -34,7 +34,9 @@
.col-md-4 .col-md-4
= f.text_field :planted_at, = f.text_field :planted_at,
value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '', value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?', title: "Plan out your future plantings by forward dating, and subscribe to your iCalendar feed for reminders to plant" class: 'add-datepicker', label: 'When?'
%span.help-inline
Tip: Plan our your future plantings by forward dating, and subscribe to your iCalendar feed for reminders to plant
.row .row
.col-md-4 .col-md-4
@@ -45,19 +47,21 @@
= f.number_field :quantity, label: 'How many?', min: 1 = f.number_field :quantity, label: 'How many?', min: 1
= f.text_area :description, rows: 6, label: 'Tell us more about it' = f.text_area :description, rows: 6, label: 'Tell us more about it'
= f.collection_check_boxes :problem_ids, Problem.approved.order(:name), :id, :name do |b|
.form-check
= b.check_box
= b.label
.row .row
.col-md-6 .col-md-6
= f.check_box :finished, label: t('buttons.mark_as_finished'), title: t('.finish_helper') = f.check_box :finished, label: 'Mark as finished'
%span.help-block= t('.finish_helper')
.col-md-6 .col-md-6
= f.text_field :finished_at, = f.text_field :finished_at,
value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '', value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '',
class: 'add-datepicker', class: 'add-datepicker',
label: 'Finished date', label: 'Finished date',
placeholder: 'optional' placeholder: 'optional'
.row
.col-md-6
= f.check_box :failed, label: t('buttons.mark_as_failed'), title: t('.failed_helper')
.card-footer .card-footer
.text-right= f.submit 'Save' .text-right= f.submit 'Save'

View File

@@ -1,9 +1,10 @@
%h2 Harvests %h2 Harvests
- if can?(:edit, planting) && !planting.failed
- if can? :edit, planting
= render 'harvests/modal', harvest: Harvest.new(crop: planting.crop, planting: planting) = render 'harvests/modal', harvest: Harvest.new(crop: planting.crop, planting: planting)
- if planting.harvests.empty? - if planting.harvests.empty?
%p No harvests recorded %p No harvests recorded
- if planting.finished? && can?(:edit, planting) && can?(:create, Harvest) - if !planting.finished? && can?(:edit, planting) && can?(:create, Harvest)
%p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season. %p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season.
- else - else
.index-cards .index-cards

View File

@@ -8,8 +8,6 @@
%p.small #{harvest_icon} First harvest expected #{I18n.l planting.first_harvest_predicted_at} %p.small #{harvest_icon} First harvest expected #{I18n.l planting.first_harvest_predicted_at}
- if planting.finished_at.present? - if planting.finished_at.present?
%p.small #{finished_icon} Finished #{I18n.l planting.finished_at} %p.small #{finished_icon} Finished #{I18n.l planting.finished_at}
- elsif planting.failed?
%p.small #{finished_icon} Failed
- elsif planting.finish_predicted_at.present? - elsif planting.finish_predicted_at.present?
%p.small #{finished_icon} Finish expected #{I18n.l planting.finish_predicted_at} %p.small #{finished_icon} Finish expected #{I18n.l planting.finish_predicted_at}
- if planting.planted_at.present? && planting.expected_lifespan.present? - if planting.planted_at.present? && planting.expected_lifespan.present?

View File

@@ -32,17 +32,15 @@
%strong= @planting.crop.name.titleize %strong= @planting.crop.name.titleize
%small.text-muted= @planting.crop.default_scientific_name %small.text-muted= @planting.crop.default_scientific_name
%tt %tt
- if @planting.failed? - if @planting.finished?
%span.badge.badge-danger Failed Finished
- elsif @planting.finished?
%span.badge.badge-success Finished
- elsif @planting.percentage_grown.present? - elsif @planting.percentage_grown.present?
#{@planting.percentage_grown.to_i}% #{@planting.percentage_grown.to_i}%
- if @planting.finish_is_predicatable? - if @planting.finish_is_predicatable?
- if @planting.age_in_days.to_i < 0 - if @planting.age_in_days < 0
%strong Planned %strong Planned
- else - else
%strong #{@planting.age_in_days.to_i}/#{@planting.expected_lifespan} days %strong #{@planting.age_in_days}/#{@planting.expected_lifespan} days
= render 'timeline', planting: @planting = render 'timeline', planting: @planting
= render 'likes/likes', object: @planting = render 'likes/likes', object: @planting
@@ -53,6 +51,23 @@
.col-md-8.col-xs-12 .col-md-8.col-xs-12
%section= render 'facts', planting: @planting %section= render 'facts', planting: @planting
- if @planting.problems.any?
%section.problems
%h2 Problems
- @planting.planting_problems.each do |planting_problem|
.card
.card-header
%h3= planting_problem.problem.name
.card-body
- if planting_problem.photos.any?
.row
- planting_problem.photos.each do |photo|
.col-md-4
= image_tag photo.thumbnail_url, class: 'img-fluid'
- else
%p No photos of this problem for this planting yet.
- if @planting.description.present? - if @planting.description.present?
= cute_icon = cute_icon
.card .card

View File

@@ -1,10 +1,10 @@
%a{ name: "comments" } %a{ name: "comments" }
- if commentable.comments - if post.comments
%hr/ %hr/
%h2 %h2
= comment_icon = comment_icon
= localize_plural(commentable.comments, Comment) = localize_plural(post.comments, Comment)
- commentable.comments.post_order.each do |comment| - post.comments.post_order.each do |comment|
= render "comments/single", comment: comment = render "comments/single", comment: comment
- else - else

Some files were not shown because too many files have changed in this diff Show More