improved donation campaign nav

This commit is contained in:
Matt Dunn-Rankin 2017-01-05 13:06:50 -08:00
parent 6a331bf79b
commit f5fb8711fc
5 changed files with 44 additions and 9 deletions

View file

@ -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

View file

@ -3,18 +3,23 @@ class CampaignsController < ApplicationController
@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

View file

@ -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?
#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

View file

@ -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 file

@ -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 @@ ActiveRecord::Schema.define(:version => 20150927033046) do
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|