Skip to content

Commit

Permalink
Merge branch 'master' into stable/1.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhenry committed Nov 28, 2013
2 parents e630c5a + d8e0ce1 commit a916335
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gem 'active_model_serializers'

group :production do
gem 'newrelic_rpm'
gem 'lograge'
end

# Gems used only for assets and not required
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ GEM
kgio (2.8.0)
launchy (2.3.0)
addressable (~> 2.3)
lograge (0.2.2)
actionpack (>= 3)
activesupport (>= 3)
railties (>= 3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand Down Expand Up @@ -251,6 +255,7 @@ DEPENDENCIES
iso_country_codes
jquery-rails
jquery-ui-rails
lograge
newrelic_rpm
nokogiri
paperclip (~> 3.0)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/campaigns.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Crowdhoster.campaigns =
form.appendChild(input[0])
form.submit()
else
$('#errors').append('<p>An error occurred. Please check your credit card details and try again.</p>')
$('#errors').append('<p>An error occurred. Please check your credit card details and try again.</p><br><p>If you continue to experience issues, please <a href="mailto:[email protected]?subject=Support request for a payment issue&body=PLEASE DESCRIBE YOUR PAYMENT ISSUES HERE">click here</a> to contact support.</p>')
$('#errors').show()
$('.loader').hide()
$button = $('button[type="submit"]')
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $( document ).ready(function() {
rules: {
"settings[site_name]": { required: true },
"settings[reply_to_email]": { required: true, email: true },
"settings[phone_number]": { phoneUS: true },
"settings[header_link_url]": { url: true },
"settings[tweet_text]": { maxlength: 120 },
"settings[facebook_app_id]": { digits: true },
Expand All @@ -34,6 +35,9 @@ $( document ).ready(function() {
required: "Please enter a reply to email address",
email: "Hmm. That doesn't look like a valid email"
},
"settings[phone_number]": {
phoneUS: "Hmm. That doesn't look like a valid phone number. <br> ex: 555-555-5555"
},
"settings[header_link_url]": {
url: "Hmm. That doesn't look like a valid URL. ex: http://crowdtilt.com"
},
Expand Down Expand Up @@ -234,7 +238,6 @@ $( document ).ready(function() {
rules: {
fullname: { required: true },
email: { required: true, email: true },
additional_info: { required: true },
address_one: { required: true },
city: { required: true },
state: { required: true },
Expand All @@ -253,9 +256,6 @@ $( document ).ready(function() {
required: "Please enter your email address.",
email: "Hmm. That doesn't look like a valid email."
},
additional_info: {
required: "We need this additional information to complete your contribution."
},
address_one: {
required: "We need your street address"
},
Expand Down
15 changes: 13 additions & 2 deletions app/controllers/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def checkout_payment

end

def checkout_confirmation
def checkout_process

ct_user_id = params[:ct_user_id]
ct_card_id = params[:ct_card_id]
Expand Down Expand Up @@ -151,7 +151,7 @@ def checkout_confirmation
logger.info response
rescue => exception
logger.info "ERROR WITH POST TO /payments: #{exception.message}"
redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment, please try again" } and return
redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment, please try again or contact support by emailing [email protected]" } and return
end

# Sync payment data
Expand All @@ -170,6 +170,17 @@ def checkout_confirmation
logger.info "ERROR WITH EMAIL RECEIPT: #{exception.message}"
end

redirect_to checkout_confirmation_url(@campaign), :status => 303, :flash => { payment_guid: @payment.ct_payment_id }

end

def checkout_confirmation
@payment = Payment.where(:ct_payment_id => flash[:payment_guid]).first
flash[:payment_guid] = nil # Unset flash because application renders all flash vars (long-term should be refactored)

if !@payment
redirect_to campaign_home_url(@campaign)
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Settings < ActiveRecord::Base
:logo_image, :logo_image_delete, :copyright_text, :facebook_title,
:facebook_description, :facebook_image, :facebook_image_delete, :homepage_content,
:custom_css, :header_link_text, :header_link_url, :ct_sandbox_guest_id, :ct_production_guest_id,
:ct_sandbox_admin_id, :ct_production_admin_id, :reply_to_email, :custom_js, :default_campaign_id, :indexable
:ct_sandbox_admin_id, :ct_production_admin_id, :reply_to_email, :custom_js, :default_campaign_id, :indexable, :phone_number

attr_accessor :logo_image_delete, :facebook_image_delete

Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/admin_website.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<label>Reply To Email</label>
<%= f.text_field :reply_to_email %>
</div>
<div class="field clearfix">
<p class="explanation">Enter a phone number where contributors can reach you.</p>
<label>Contact Phone Number (Optional)</label>
<%= f.text_field :phone_number %>
</div>

<div class="field clearfix">
<p class="explanation">If you would like to display a logo instead of your site name in the header, upload it here. Resize the image before uploading for best results in your template.</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/campaigns/checkout_payment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="well checkout_block" style="padding-bottom: 16px">

<form accept-charset="UTF-8" action="<%= checkout_confirmation_path(@campaign) %>" method="post" id="payment_form">
<form accept-charset="UTF-8" action="<%= checkout_process_path(@campaign) %>" method="post" id="payment_form">

<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>">
<h4 class="contact">Contact Information</h4>
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/payment_confirmation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Hi <%= @payment.fullname.split(' ')[0] %>,

<br/><br/>

This email is a confirmation of your $<%= number_with_precision(@payment.amount.to_f/100.0 + @payment.user_fee_amount.to_f/100.0, precision: 2) %> payment to <%= @campaign.name %>. If you have any questions about this campaign, please contact <%= @settings.reply_to_email %>.
This is an email receipt for your $<%= number_with_precision(@payment.amount.to_f/100.0 + @payment.user_fee_amount.to_f/100.0, precision: 2) %> contribution to <a href="<%= url_for campaign_home_url(@campaign) %>"><%= @campaign.name %></a>. If you have any questions about this campaign, please contact the campaign's organizer at <%= @settings.reply_to_email %><% if @settings.phone_number.present? %> or <%= @settings.phone_number %><% end %>.

<br/><br/>

Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/payment_confirmation.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Hi <%= @payment.fullname.split(' ')[0] %>,

This email is a confirmation of your $<%= number_with_precision(@payment.amount.to_f/100.0 + @payment.user_fee_amount.to_f/100.0, precision: 2) %> payment to <%= @campaign.name %>. If you have any questions about this campaign, please contact <%= @settings.reply_to_email %>.
This is an email receipt for your $<%= number_with_precision(@payment.amount.to_f/100.0 + @payment.user_fee_amount.to_f/100.0, precision: 2) %> contribution to <%= @campaign.name %> (<%= url_for campaign_home_url(@campaign) %>). If you have any questions about this campaign, please contact the campaign's organizer at <%= @settings.reply_to_email %><% if @settings.phone_number.present? %> or <%= @settings.phone_number %><% end %>.

<% if [email protected]_flag %>
This campaign is in sandbox mode, your card will not actually be charged.
Expand Down
18 changes: 14 additions & 4 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@

# Use a different logger for distributed setups
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Denser logs with lograge
config.lograge.enabled = true

config.lograge.custom_options = lambda do |event|
unwanted_keys = %w(action controller format)
params = event.payload[:params].reject { |key,_| unwanted_keys.include? key }

return {:params => params}
end

# Logging settings for heroku
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get((ENV["LOG_LEVEL"] || "INFO").upcase)

# Use a different cache store in production
# config.cache_store = :mem_cache_store
Expand Down Expand Up @@ -71,8 +85,4 @@
config.assets.prefix = "/#{ENV['APP_NAME']}/assets"
end

# Logging settings for heroku
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get((ENV["LOG_LEVEL"] || "INFO").upcase)

end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# CAMPAIGNS
match '/:id/checkout/amount', to: 'campaigns#checkout_amount', as: :checkout_amount
match '/:id/checkout/payment', to: 'campaigns#checkout_payment', as: :checkout_payment
match '/:id/checkout/process', to: 'campaigns#checkout_process', as: :checkout_process
match '/:id/checkout/confirmation', to: 'campaigns#checkout_confirmation', as: :checkout_confirmation
match '/:id', to: 'campaigns#home', as: :campaign_home

Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20131128003747_add_phone_number_to_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPhoneNumberToSettings < ActiveRecord::Migration
def change
add_column :settings, :phone_number, :string
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20131007231616) do
ActiveRecord::Schema.define(:version => 20131128003747) do

create_table "campaigns", :force => true do |t|
t.string "name"
Expand Down Expand Up @@ -171,8 +171,9 @@
t.string "mailgun_route_id"
t.string "ct_prod_api_key"
t.string "ct_prod_api_secret"
t.integer "default_campaign_id"
t.boolean "indexable", :default => true
t.integer "default_campaign_id"
t.string "phone_number"
end

create_table "users", :force => true do |t|
Expand Down

0 comments on commit a916335

Please sign in to comment.