mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-27 03:02:43 -04:00
Refactored further on plantings/show page
This commit is contained in:
@@ -13,19 +13,11 @@ module PlantingsHelper
|
||||
if planting.finished?
|
||||
0
|
||||
elsif !planting.finished_at.nil?
|
||||
if ((p = planting.finished_at - DateTime.now).to_i) <= 0
|
||||
0
|
||||
else
|
||||
p.to_i
|
||||
end
|
||||
((p = planting.finished_at - DateTime.now).to_i) <= 0 ? 0 : p.to_i
|
||||
elsif planting.days_before_maturity.nil?
|
||||
"unknown"
|
||||
else
|
||||
if ((p = (planting.planted_at + planting.days_before_maturity) - DateTime.now).to_i) <= 0
|
||||
0
|
||||
else
|
||||
p.to_i
|
||||
end
|
||||
((p = (planting.planted_at + planting.days_before_maturity) - DateTime.now).to_i <= 0) ? 0 : p.to_i
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,18 +32,14 @@ module PlantingsHelper
|
||||
end
|
||||
|
||||
def display_sunniness(planting)
|
||||
if !planting.sunniness.blank?
|
||||
planting.sunniness
|
||||
else
|
||||
"n/a"
|
||||
end
|
||||
!planting.sunniness.blank? ? planting.sunniness : "not specified"
|
||||
end
|
||||
|
||||
def display_planted_from(planting)
|
||||
if !planting.planted_from.blank?
|
||||
planting.planted_from
|
||||
else
|
||||
"n/a"
|
||||
end
|
||||
!planting.planted_from.blank? ? planting.planted_from : "not specified"
|
||||
end
|
||||
|
||||
def display_planting_quantity(planting)
|
||||
!planting.quantity.blank? ? planting.quantity : "not specified"
|
||||
end
|
||||
end
|
||||
@@ -9,17 +9,19 @@
|
||||
%td= link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => planting.crop_id, :class => 'img'), planting
|
||||
%td
|
||||
%ul{:style => "list-style-type:none"}
|
||||
%li Owner :
|
||||
%li Garden :
|
||||
%li Planted on :
|
||||
%li Finished on :
|
||||
%li Sun/shade? :
|
||||
%li Planted from :
|
||||
%li Owner:
|
||||
%li Garden:
|
||||
%li Planted on:
|
||||
%li Quantity:
|
||||
%li Finished on:
|
||||
%li Sun/shade?:
|
||||
%li Planted from:
|
||||
%td
|
||||
%ul{:style => "list-style-type:none"}
|
||||
%li= link_to planting.owner.login_name, planting.owner
|
||||
%li= link_to planting.garden.name, planting.garden
|
||||
%li= planting.planted_at
|
||||
%li= "#{display_planting_quantity(planting)}"
|
||||
%li= "#{display_finished(planting)}"
|
||||
%li= "#{display_sunniness(planting)}"
|
||||
%li= "#{display_planted_from(planting)}"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
—
|
||||
= link_to "view all #{@planting.owner}'s plantings", plantings_by_owner_path(:owner => @planting.owner.slug)
|
||||
%p
|
||||
%b Planted:
|
||||
%b Planted on:
|
||||
= @planting.planted_at ? @planting.planted_at : "not specified"
|
||||
|
||||
%p
|
||||
@@ -18,44 +18,30 @@
|
||||
- if ! @planting.owner.location.blank?
|
||||
= "(#{@planting.owner.location})"
|
||||
%p
|
||||
%b Quantity:
|
||||
= @planting.quantity.blank? ? "not specified" : @planting.quantity
|
||||
|
||||
- if ! @planting.planted_from.blank?
|
||||
%b
|
||||
= "Quantity: "
|
||||
= "#{display_planting_quantity(@planting)}"
|
||||
|
||||
- if !@planting.planted_from.blank?
|
||||
%p
|
||||
%b Planted from:
|
||||
= @planting.planted_from
|
||||
|
||||
- if ! @planting.sunniness.blank?
|
||||
%b
|
||||
= "Planted from: "
|
||||
= "#{display_planted_from(@planting)}"
|
||||
|
||||
- if !@planting.sunniness.blank?
|
||||
%p
|
||||
%b Sun or shade?
|
||||
= @planting.sunniness
|
||||
|
||||
- if @planting.finished
|
||||
%p
|
||||
%b Finished:
|
||||
- if @planting.finished_at
|
||||
= @planting.finished_at
|
||||
- else
|
||||
Yes (no date specified)
|
||||
%b
|
||||
= "Sun or shade?: "
|
||||
= "#{display_sunniness(@planting)}"
|
||||
%p
|
||||
%b Days until maturity:
|
||||
- if @planting.finished?
|
||||
%b
|
||||
= " 0"
|
||||
- elsif !@planting.finished_at.nil?
|
||||
- if ((p = @planting.finished_at - DateTime.now).to_i) <= 0
|
||||
- p = 0
|
||||
%b
|
||||
= " #{p.to_i}"
|
||||
- elsif @planting.days_before_maturity.nil?
|
||||
%b
|
||||
= " unknown"
|
||||
- else
|
||||
- if ((p = (@planting.planted_at + @planting.days_before_maturity) - DateTime.now).to_i) <= 0
|
||||
- p = 0
|
||||
%b
|
||||
= " #{p.to_i}"
|
||||
%b
|
||||
= "Days until maturity: "
|
||||
= "#{display_days_before_maturity(@planting)}"
|
||||
%p
|
||||
%b
|
||||
= "Finished: "
|
||||
= "#{display_finished(@planting)}"
|
||||
|
||||
%p
|
||||
%b= render 'planting_progress', planting: @planting
|
||||
|
||||
|
||||
Reference in New Issue
Block a user