diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml
index 7809ed493..7231137d6 100644
--- a/app/views/crops/_thumbnail.html.haml
+++ b/app/views/crops/_thumbnail.html.haml
@@ -2,9 +2,10 @@
.thumbnail(style='height: 200px')
= image_tag('http://placehold.it/150x150', :alt => '', :class => 'img-rounded')
- if crop
- %p= link_to crop.system_name, crop
- - if crop.scientific_names.count > 0
- %p
+ %p
+ = link_to crop.system_name, crop
+ - if crop.scientific_names.count > 0
+ %br/
%i
%small
= crop.scientific_names.first.scientific_name
diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml
index 02ab2079e..a05981d55 100644
--- a/app/views/crops/show.html.haml
+++ b/app/views/crops/show.html.haml
@@ -1,33 +1,25 @@
- content_for :title, @crop.system_name
-.row-fluid
- .span9
- %ul.thumbnails
- - (1..4).each do
- %li.span3
- .thumbnail
- = image_tag('http://placehold.it/200x200', :alt => '', :class => 'img-rounded')
+.container-fluid
+ .row-fluid
+ .span9
+ %h2 Who's growing this?
+ - @crop.plantings.each do |p|
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p, :title => 'owner'}
- =link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-large btn-primary'
+ .span3
+ %h4 Scientific names:
+ %ul
+ - @crop.scientific_names.each do |sn|
+ %li= sn.scientific_name
+ %h4 More information:
+ %ul
+ %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url
- %h2 Who's growing this?
- - @crop.plantings.each do |p|
- %p
- = p.quantity ? p.quantity : nil
- = link_to p.crop.system_name, p.crop
- in
- = link_to p.location, p.garden
- = p.planted_at ? "planted at #{p.planted_at}" : nil
-
- .span3
- %h3 Scientific names:
- %ul
- - @crop.scientific_names.each do |sn|
- %li= sn.scientific_name
- %h3 More information:
- %ul
- %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url
- %p
- if member_signed_in?
- = link_to 'Edit', edit_crop_path(@crop), { :class => 'btn' }
- = link_to 'Destroy', @crop, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn'
+ %p
+ = link_to 'Edit', edit_crop_path(@crop), { :class => 'btn' }
+ = link_to 'Destroy', @crop, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn'
+ %p
+ =link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-large btn-primary'
+
diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml
index 083ac1622..3f55f24e2 100644
--- a/app/views/gardens/show.html.haml
+++ b/app/views/gardens/show.html.haml
@@ -18,25 +18,9 @@
= link_to 'New', new_garden_path, :class => 'btn'
.span9
- .tabbable
- %ul.nav.nav-tabs
- %li.active
- = link_to 'Plantings', '#tab1', 'data-toggle' => 'tab'
- %li
- = link_to 'Updates', '#tab2', 'data-toggle' => 'tab'
- .tab-content
- .tab-pane.active#tab1
- - if current_member == @garden.owner
- %p= link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-large btn-primary'
+ - if current_member == @garden.owner
+ %p= link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-large btn-primary'
- %ul.thumbnails
- - @garden.plantings.each do |p|
- %li.span2
- = render :partial => "crops/thumbnail", :locals => { :crop => p.crop }
- .tab-pane.active#tab2
- .alert
- %button.close{:type => 'button', 'data-dismiss' => 'alert'} ×
- Note: in due these will be limited to only those posts that apply to this particular garden!
+ - @garden.plantings.each do |p|
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p }
- - @garden.owner.posts.each do |post|
- = render :partial => "posts/single", :locals => { :post => post, :subject => true }
diff --git a/app/views/layouts/_meta.html.haml b/app/views/layouts/_meta.html.haml
index da5c20e80..679edc2d6 100644
--- a/app/views/layouts/_meta.html.haml
+++ b/app/views/layouts/_meta.html.haml
@@ -1,7 +1,6 @@
%head
-
- if (content_for?(:member_rss_login_name) && content_for(:member_rss_slug))
= auto_discovery_link_tag(:rss, { :controller => "/members", :action => 'show', :format => "rss", :id => yield(:member_rss_slug) }, { :title => "Growstuff - #{yield(:member_rss_login_name)}'s posts" })
diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml
index 6be0e1224..1f88fd10a 100644
--- a/app/views/members/show.html.haml
+++ b/app/views/members/show.html.haml
@@ -26,12 +26,13 @@
%div{:class => ['tab-pane', first_garden ? 'active' : ''], :id => "garden#{g.id}"}
- first_garden = false
- %ul.thumbnails
- - g.featured_plantings.each do |p|
- %li.span2
- = render :partial => "crops/thumbnail", :locals => { :crop => p.crop }
+ %h3 What's planted here?
+ - g.featured_plantings.each do |p|
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p }
+
+ %p
+ = link_to "More about this garden...", url_for(g)
- %p= link_to "More about this garden...", url_for(g)
%div{:class => 'tab-pane', :id => "garden_new"}
%h3 Create a new garden
= render 'gardens/form'
diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml
new file mode 100644
index 000000000..2baa37fe7
--- /dev/null
+++ b/app/views/plantings/_thumbnail.html.haml
@@ -0,0 +1,19 @@
+%h4
+ - if defined?(title) && title == 'owner'
+ = link_to planting.owner, planting.owner
+ - else
+ = link_to planting.crop.system_name, planting.crop
+
+%p
+ Planted
+ - if planting.planted_at
+ = planting.planted_at.to_s(:date)
+ in
+ = link_to planting.location, planting.garden
+
+%p
+ - if planting.quantity
+ Quantity:
+ = planting.quantity
+ - else
+
diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb
new file mode 100644
index 000000000..63c12499e
--- /dev/null
+++ b/config/initializers/time_formats.rb
@@ -0,0 +1 @@
+Time::DATE_FORMATS[:date] = "%B %d, %Y"
diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb
index f8fb5e4b0..6cda6ab21 100644
--- a/spec/factories/planting.rb
+++ b/spec/factories/planting.rb
@@ -3,7 +3,7 @@ FactoryGirl.define do
garden
crop
planted_at Time.now
- quantity 3
+ quantity 33
description "This is a *really* good plant."
end
end
diff --git a/spec/views/crops/show.html.haml_spec.rb b/spec/views/crops/show.html.haml_spec.rb
index aad4f3b95..81dcf4e1f 100644
--- a/spec/views/crops/show.html.haml_spec.rb
+++ b/spec/views/crops/show.html.haml_spec.rb
@@ -2,15 +2,18 @@ require 'spec_helper'
describe "crops/show" do
before(:each) do
- @crop = assign(:crop, FactoryGirl.create(:maize,
+ @crop = FactoryGirl.create(:maize,
:scientific_names => [ FactoryGirl.create(:zea_mays) ]
- ))
+ )
@owner = FactoryGirl.create(:member)
@garden = FactoryGirl.create(:garden, :owner => @owner)
@planting = FactoryGirl.create(:planting,
:garden => @garden,
:crop => @crop
)
+
+ assign(:crop, @crop)
+
end
it "shows the wikipedia URL" do
@@ -35,7 +38,9 @@ describe "crops/show" do
end
it "links to people who are growing this crop" do
+ render
rendered.should contain "member1"
+ rendered.should contain "Springfield Community Garden"
end
context "logged out" do
diff --git a/spec/views/plantings/_thumbnail.html.haml_spec.rb b/spec/views/plantings/_thumbnail.html.haml_spec.rb
new file mode 100644
index 000000000..405bdf5f8
--- /dev/null
+++ b/spec/views/plantings/_thumbnail.html.haml_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe "plantings/_thumbnail" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ @garden = FactoryGirl.create(:garden, :owner => @member)
+ @crop = FactoryGirl.create(:tomato)
+
+ @planting = FactoryGirl.create(:planting,
+ :garden => @garden,
+ :crop => @crop
+ )
+
+ render :partial => "thumbnail", :locals => {
+ :planting => @planting,
+ :show_crop => true,
+ :show_location => true
+ }
+ end
+
+ it "renders the quantity planted" do
+ rendered.should contain "33"
+ end
+
+ it "renders the date planted" do
+ rendered.should contain @planting.planted_at.to_s(:date)
+ end
+
+ it "shows the name of the crop" do
+ rendered.should contain "Tomato"
+ end
+
+end