From c89c20e8429ce932fe177fe75b907cfa08574439 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Mar 2017 13:40:03 +1300 Subject: [PATCH 1/2] View harvests for a planting --- app/controllers/harvests_controller.rb | 4 ++++ app/helpers/application_helper.rb | 4 +++- app/views/harvests/_nav.haml | 15 +++++++++++++++ app/views/harvests/index.html.haml | 17 ++--------------- app/views/plantings/_planting_harvest.html.haml | 5 ++--- app/views/plantings/index.html.haml | 2 +- app/views/seeds/index.html.haml | 2 +- config/locales/en.yml | 1 + 8 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 app/views/harvests/_nav.haml diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index b1824ef2b..c940ecbd2 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -9,6 +9,8 @@ class HarvestsController < ApplicationController def index @owner = Member.find_by(slug: params[:owner]) @crop = Crop.find_by(slug: params[:crop]) + @planting = Planting.find_by(slug: params['planting_id']) + @harvests = harvests @filename = csv_filename respond_with(@harvests) @@ -79,6 +81,8 @@ class HarvestsController < ApplicationController @owner.harvests elsif @crop @crop.harvests + elsif @planting_id + @planting.harvests else Harvest end.includes(:owner, :crop).paginate(page: params[:page]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5e3c621dd..c0206f90b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -93,11 +93,13 @@ module ApplicationHelper end end - def title(type, owner, crop) + def title(type, owner, crop, planting) if owner t(".title.owner_#{type}", owner: owner.login_name) elsif crop t(".title.crop_#{type}", crop: crop.name) + elsif planting + t(".title.planting_#{type}", planting: planting.to_s) else t(".title.default") end diff --git a/app/views/harvests/_nav.haml b/app/views/harvests/_nav.haml new file mode 100644 index 000000000..af79e49fd --- /dev/null +++ b/app/views/harvests/_nav.haml @@ -0,0 +1,15 @@ +%p + - if can? :create, Harvest + - if @planting && @planting.owner == current_member + = link_to 'Add harvest', new_planting_harvest_path(planting: @planting), class: 'btn btn-primary' + - elsif @owner + %p + - if @owner == current_member + = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' + = link_to "View everyone's harvests", harvests_path, class: 'btn btn-default' + - else # everyone's harvests + = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' + - if current_member + = link_to 'View your harvests', harvests_by_owner_path(owner: current_member.slug), class: 'btn btn-default' + - else + = render partial: 'shared/signin_signup', locals: { to: 'track your harvests' } diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 24f6a139b..fa0be4ed3 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, title('harvests', @owner, @crop) +- content_for :title, title('harvests', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) @@ -7,20 +7,7 @@ #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're harvesting from your home garden and see how productive it is. -%p - - if can? :create, Harvest - - if @owner - %p - - if @owner == current_member - = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - = link_to "View everyone's harvests", harvests_path, class: 'btn btn-default' - - else # everyone's harvests - = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - - if current_member - = link_to 'View your harvests', harvests_by_owner_path(owner: current_member.slug), class: 'btn btn-default' - - else - = render partial: 'shared/signin_signup', locals: { to: 'track your harvests' } - += render "nav" .pagination = page_entries_info @harvests = will_paginate @harvests diff --git a/app/views/plantings/_planting_harvest.html.haml b/app/views/plantings/_planting_harvest.html.haml index ebb4f1e78..eef095d8c 100644 --- a/app/views/plantings/_planting_harvest.html.haml +++ b/app/views/plantings/_planting_harvest.html.haml @@ -1,9 +1,8 @@ -Harvests: - if planting.harvests + Harvests: %ul - planting.harvests.each do |harvest| %li = harvest.harvested_at ? harvest.harvested_at : "undated" = link_to harvest, harvest_path(harvest) -- else - none + = link_to "more harvests from this planting", planting_harvests_path(planting) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index eafa785bd..d0b664248 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, title('plantings', @owner, @crop) +- content_for :title, title('plantings', @owner, @crop, @planting) = render 'nav', owner: @owner, show_all: @show_all diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 2887b69e1..3108bfc56 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, title('seeds', @owner, @crop) +- content_for :title, title('seeds', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) diff --git a/config/locales/en.yml b/config/locales/en.yml index de19ae646..92ae461d9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,6 +63,7 @@ en: index: title: crop_harvests: Everyone's %{crop} harvests + planting_harvests: Harvests from %{planting} default: Everyone's harvests owner_harvests: "%{owner} harvests" updated: Harvest was successfully updated. From 20cfa0c5b2f60644a3b9f7b5deafdc9ce9caa106 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sun, 19 Mar 2017 16:11:22 +0800 Subject: [PATCH 2/2] Bundle Update on 2017-03-19 --- Gemfile.lock | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e84b55655..60d7b4ae6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,8 +20,9 @@ GEM erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.3) - active_link_to (1.0.3) + active_link_to (1.0.4) actionpack + addressable active_merchant-paypal-bogus-gateway (0.1.0) activemerchant active_utils (3.3.0) @@ -76,7 +77,7 @@ GEM builder (3.2.3) byebug (9.0.6) cancancan (1.16.0) - capybara (2.12.1) + capybara (2.13.0) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -296,7 +297,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (3.18.1.330) + newrelic_rpm (4.0.0.332) nokogiri (1.7.0.1) mini_portile2 (~> 2.1.0) notiffany (0.1.1) @@ -339,7 +340,7 @@ GEM phantomjs (2.1.1.0) plupload-rails (1.2.1) rails (>= 3.1) - poltergeist (1.13.0) + poltergeist (1.14.0) capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) @@ -447,7 +448,7 @@ GEM websocket (~> 1.0) sexp_processor (4.8.0) shellany (0.0.1) - sidekiq (4.2.9) + sidekiq (4.2.10) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0)