mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-14 03:05:59 -04:00
Merge pull request #1279 from Br3nda/plantings-harvests
View harvests for a planting
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
15
app/views/harvests/_nav.haml
Normal file
15
app/views/harvests/_nav.haml
Normal file
@@ -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' }
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user