mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-24 07:48:26 -04:00
display plantings in table form, like seeds
This commit is contained in:
1 parent
955975a115
commit
1ac5683557
4 files changed
+57
-16
No files matched your search
@@ -7,6 +7,10 @@ class PlantingsController < ApplicationController
|
||||
# GET /plantings.json
|
||||
def index
|
||||
@plantings = Planting.paginate(:page => params[:page])
|
||||
@owner = Member.find_by_id(params[:owner_id])
|
||||
if @owner
|
||||
@plantings = @owner.plantings.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -1,14 +1,46 @@
|
||||
=content_for :title, "What's been planted recently?"
|
||||
- content_for :title, @owner ? "#{@owner}'s plantings" : "Everyone's plantings"
|
||||
|
||||
%p Here are the latest things planted by #{Growstuff::Application.config.site_name} members.
|
||||
%p
|
||||
- if can? :create, Planting
|
||||
- if @owner
|
||||
%p
|
||||
- if @owner == current_member
|
||||
= link_to 'Plant something', new_planting_path, :class => 'btn btn-primary'
|
||||
= link_to "View everyone's plantings", plantings_path, :class => 'btn'
|
||||
- else # everyone's plantings
|
||||
= link_to 'Plant something', new_planting_path, :class => 'btn btn-primary'
|
||||
- if current_member
|
||||
= link_to 'View your plantings', plantings_path(:owner_id => current_member.id), :class => 'btn'
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => "track what you've planted" }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
- if @plantings.length > 0
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Crop
|
||||
%th Garden
|
||||
%th Description
|
||||
%th Quantity
|
||||
%th Planted on
|
||||
%th Sun/shade?
|
||||
%th Planted from
|
||||
%th
|
||||
|
||||
- @plantings.each do |p|
|
||||
= render :partial => "plantings/thumbnail", :locals => { :planting => p }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
- @plantings.each do |planting|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to planting.owner.login_name, planting.owner
|
||||
%td= link_to planting.crop.system_name, planting.crop
|
||||
%td= link_to planting.garden.name, planting.garden
|
||||
%td
|
||||
:markdown
|
||||
#{ strip_tags planting.description }
|
||||
%td= planting.quantity
|
||||
%td= planting.planted_at
|
||||
%td= planting.sunniness
|
||||
%td= planting.planted_from
|
||||
%td= link_to 'Details', planting, :class => 'btn btn-mini'
|
||||
- else
|
||||
%p There are no plantings to display.
|
||||
@@ -11,6 +11,14 @@ describe PlantingsController do
|
||||
}
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "picks up owner from params" do
|
||||
owner = FactoryGirl.create(:member)
|
||||
get :index, {:owner_id => owner.id}
|
||||
assigns(:owner).should eq(owner)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
|
||||
it "picks up crop from params" do
|
||||
|
||||
@@ -31,7 +31,8 @@ describe "plantings/index" do
|
||||
it "renders a list of plantings" do
|
||||
rendered.should contain 'Tomato'
|
||||
rendered.should contain 'Maize'
|
||||
rendered.should contain /member\d+'s Springfield Community Garden/
|
||||
rendered.should contain @member.login_name
|
||||
rendered.should contain @garden.name
|
||||
end
|
||||
|
||||
it "shows descriptions where they exist" do
|
||||
@@ -42,8 +43,4 @@ describe "plantings/index" do
|
||||
rendered.should contain 'January 13, 2013'
|
||||
end
|
||||
|
||||
it "renders markdown in the description" do
|
||||
assert_select "em", "really"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user