Permalink
Browse files

improved donation campaign nav

  • Loading branch information...
1 parent 6a331bf commit f5fb8711fcff2cd090b5b95eb0b40c89dc68d44e @matchu matchu committed Jan 5, 2017
@@ -143,6 +143,15 @@ body.campaigns-show, body.campaigns-current
margin-top: 1em
text-align: center
+ #outfits-header > *
+ display: inline-block
+
+ #all-campaigns-list
+ li
+ display: inline-block
+ list-style: none
+ margin-left: 1em
+
#fine-print
font-size: 85%
margin-top: 2em
@@ -3,18 +3,23 @@ def show
@campaign = Campaign.find(params[:id])
redirect_to(action: :current) if @campaign.active?
@donations = find_donations
+ @all_campaigns = find_all_campaigns
end
def current
@campaign = Campaign.current
@donations = find_donations
+ @all_campaigns = find_all_campaigns
render action: :show
end
private
+ def find_all_campaigns
+ @all_campaigns = Campaign.order('created_at DESC').all
+ end
+
def find_donations
- @donations = @campaign.donations.includes(features: :outfit).
- order('created_at DESC')
+ @campaign.donations.includes(features: :outfit).order('created_at DESC')
end
end
@@ -3,7 +3,7 @@
- if @campaign.progress > 0
= campaign_progress(@campaign) do
We've received #{cents_to_currency(@campaign.progress)}
- toward #{@campaign.name}.
+ toward #{@campaign.purpose}.
Thanks so much!
= form_tag donations_path, method: 'POST', id: 'donation-form',
@@ -34,7 +34,16 @@
#description= emote_md @campaign.description
- if @donations.present?
- %h2 Thanks to our lovely donors!
+ #outfits-header
+ %h2 Thanks to our lovely donors!
+ - if @all_campaigns.length > 1
+ %ul#all-campaigns-list
+ - @all_campaigns.each do |campaign|
+ %li
+ - if campaign == @campaign
+ %strong= campaign.name
+ - else
+ = link_to campaign.name, campaign
%ul#outfits
- @donations.each do |donation|
-# if large_donation?(donation.amount)
@@ -51,9 +60,11 @@
= image_tag 'default_preview.png'
%header Thanks, #{donation.donor_name.presence || 'Anonymous'}!
-
-- if @campaign.active?
- %p#last-years-donors= link_to "Don't forget to check out last year's donors, too!", Campaign.first
+- else
+ - current_index = @all_campaigns.index(@campaign)
+ - prev_campaign = @all_campaigns[current_index + 1]
+ - if prev_campaign
+ %p#last-years-donors= link_to "Don't forget to check out last year's donors, too!", prev_campaign
#fine-print
%h2 Other ways to donate
@@ -0,0 +1,9 @@
+class AddPurposeToCampaigns < ActiveRecord::Migration
+ def change
+ # We're using the "name" column as a short campaign purpose phrase.
+ # Let's name that "purpose" instead, and create a "name" column that we can
+ # use to reference the campaign, e.g. "2016".
+ rename_column :campaigns, :name, :purpose
+ add_column :campaigns, :name, :string
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20150927033046) do
+ActiveRecord::Schema.define(:version => 20170105205222) do
create_table "auth_servers", :force => true do |t|
t.string "short_name", :limit => 10, :null => false
@@ -40,9 +40,10 @@
t.datetime "updated_at", :null => false
t.boolean "advertised", :default => true, :null => false
t.text "description", :null => false
- t.string "name", :default => "our hosting costs this year", :null => false
+ t.string "purpose", :default => "our hosting costs this year", :null => false
t.string "theme_id", :default => "hug", :null => false
t.text "thanks"
+ t.string "name"
end
create_table "campaigns_old", :force => true do |t|

0 comments on commit f5fb871

Please sign in to comment.