forked from OpenNeo/impress
when remaining costs < $200, pitch harder
This commit is contained in:
parent
d8038f2fbf
commit
5466cc9301
3 changed files with 18 additions and 3 deletions
|
@ -26,14 +26,25 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cents_to_currency(cents)
|
||||||
|
number_to_currency(cents / 100.0)
|
||||||
|
end
|
||||||
|
|
||||||
def campaign_progress(campaign, &block)
|
def campaign_progress(campaign, &block)
|
||||||
if campaign
|
if campaign
|
||||||
if block_given?
|
if block_given?
|
||||||
content = capture(&block)
|
content = capture(&block)
|
||||||
else
|
else
|
||||||
|
if campaign.remaining < 200_00
|
||||||
|
pitch = "We only need #{cents_to_currency(campaign.remaining)} more for #{campaign.name}!"
|
||||||
|
prompt = "Donate now"
|
||||||
|
else
|
||||||
|
pitch = "Help Dress to Impress stay online!"
|
||||||
|
prompt = "Learn more"
|
||||||
|
end
|
||||||
content = link_to(
|
content = link_to(
|
||||||
content_tag(:span, 'Help Dress to Impress stay online!') +
|
content_tag(:span, pitch) +
|
||||||
content_tag(:span, 'Learn more', :class => 'button'), donate_path)
|
content_tag(:span, prompt, :class => 'button'), donate_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
meter = content_tag(:div, nil, :class => 'campaign-progress',
|
meter = content_tag(:div, nil, :class => 'campaign-progress',
|
||||||
|
|
|
@ -7,6 +7,10 @@ class Campaign < ActiveRecord::Base
|
||||||
[(progress.to_f / goal) * 100, 100].min
|
[(progress.to_f / goal) * 100, 100].min
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remaining
|
||||||
|
goal - progress
|
||||||
|
end
|
||||||
|
|
||||||
def self.current
|
def self.current
|
||||||
self.where(active: true).first or
|
self.where(active: true).first or
|
||||||
raise ActiveRecord::RecordNotFound.new("no current campaign")
|
raise ActiveRecord::RecordNotFound.new("no current campaign")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
- if @campaign.progress > 0
|
- if @campaign.progress > 0
|
||||||
= campaign_progress(@campaign) do
|
= campaign_progress(@campaign) do
|
||||||
We've received #{number_to_currency(@campaign.progress / 100.0)}
|
We've received #{cents_to_currency(@campaign.progress)}
|
||||||
toward #{@campaign.name}.
|
toward #{@campaign.name}.
|
||||||
Thanks so much!
|
Thanks so much!
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue