forked from OpenNeo/impress
improved donation campaign nav
This commit is contained in:
parent
6a331bf79b
commit
f5fb8711fc
5 changed files with 44 additions and 9 deletions
|
@ -143,6 +143,15 @@ body.campaigns-show, body.campaigns-current
|
||||||
margin-top: 1em
|
margin-top: 1em
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
|
#outfits-header > *
|
||||||
|
display: inline-block
|
||||||
|
|
||||||
|
#all-campaigns-list
|
||||||
|
li
|
||||||
|
display: inline-block
|
||||||
|
list-style: none
|
||||||
|
margin-left: 1em
|
||||||
|
|
||||||
#fine-print
|
#fine-print
|
||||||
font-size: 85%
|
font-size: 85%
|
||||||
margin-top: 2em
|
margin-top: 2em
|
||||||
|
|
|
@ -3,18 +3,23 @@ class CampaignsController < ApplicationController
|
||||||
@campaign = Campaign.find(params[:id])
|
@campaign = Campaign.find(params[:id])
|
||||||
redirect_to(action: :current) if @campaign.active?
|
redirect_to(action: :current) if @campaign.active?
|
||||||
@donations = find_donations
|
@donations = find_donations
|
||||||
|
@all_campaigns = find_all_campaigns
|
||||||
end
|
end
|
||||||
|
|
||||||
def current
|
def current
|
||||||
@campaign = Campaign.current
|
@campaign = Campaign.current
|
||||||
@donations = find_donations
|
@donations = find_donations
|
||||||
|
@all_campaigns = find_all_campaigns
|
||||||
render action: :show
|
render action: :show
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def find_all_campaigns
|
||||||
|
@all_campaigns = Campaign.order('created_at DESC').all
|
||||||
|
end
|
||||||
|
|
||||||
def find_donations
|
def find_donations
|
||||||
@donations = @campaign.donations.includes(features: :outfit).
|
@campaign.donations.includes(features: :outfit).order('created_at DESC')
|
||||||
order('created_at DESC')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- if @campaign.progress > 0
|
- if @campaign.progress > 0
|
||||||
= campaign_progress(@campaign) do
|
= campaign_progress(@campaign) do
|
||||||
We've received #{cents_to_currency(@campaign.progress)}
|
We've received #{cents_to_currency(@campaign.progress)}
|
||||||
toward #{@campaign.name}.
|
toward #{@campaign.purpose}.
|
||||||
Thanks so much!
|
Thanks so much!
|
||||||
|
|
||||||
= form_tag donations_path, method: 'POST', id: 'donation-form',
|
= form_tag donations_path, method: 'POST', id: 'donation-form',
|
||||||
|
@ -34,7 +34,16 @@
|
||||||
#description= emote_md @campaign.description
|
#description= emote_md @campaign.description
|
||||||
|
|
||||||
- if @donations.present?
|
- if @donations.present?
|
||||||
|
#outfits-header
|
||||||
%h2 Thanks to our lovely donors!
|
%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
|
%ul#outfits
|
||||||
- @donations.each do |donation|
|
- @donations.each do |donation|
|
||||||
-# if large_donation?(donation.amount)
|
-# if large_donation?(donation.amount)
|
||||||
|
@ -51,9 +60,11 @@
|
||||||
= image_tag 'default_preview.png'
|
= image_tag 'default_preview.png'
|
||||||
|
|
||||||
%header Thanks, #{donation.donor_name.presence || 'Anonymous'}!
|
%header Thanks, #{donation.donor_name.presence || 'Anonymous'}!
|
||||||
|
- else
|
||||||
- if @campaign.active?
|
- current_index = @all_campaigns.index(@campaign)
|
||||||
%p#last-years-donors= link_to "Don't forget to check out last year's donors, too!", Campaign.first
|
- 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
|
#fine-print
|
||||||
%h2 Other ways to donate
|
%h2 Other ways to donate
|
||||||
|
|
9
db/migrate/20170105205222_add_purpose_to_campaigns.rb
Normal file
9
db/migrate/20170105205222_add_purpose_to_campaigns.rb
Normal 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
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "auth_servers", :force => true do |t|
|
||||||
t.string "short_name", :limit => 10, :null => false
|
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.datetime "updated_at", :null => false
|
||||||
t.boolean "advertised", :default => true, :null => false
|
t.boolean "advertised", :default => true, :null => false
|
||||||
t.text "description", :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.string "theme_id", :default => "hug", :null => false
|
||||||
t.text "thanks"
|
t.text "thanks"
|
||||||
|
t.string "name"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "campaigns_old", :force => true do |t|
|
create_table "campaigns_old", :force => true do |t|
|
||||||
|
|
Loading…
Reference in a new issue