diff --git a/Gemfile b/Gemfile index 2add685c..effadb20 100644 --- a/Gemfile +++ b/Gemfile @@ -70,6 +70,8 @@ gem 'react-rails', '~> 0.8.0.0' gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby' +gem "letter_opener", :group => :development + # Needed for the new asset pipeline group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index 2cf09e89..fbfce2ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -174,6 +174,10 @@ GEM i18n (0.6.9) journey (1.0.4) json (1.8.1) + launchy (2.4.2) + addressable (~> 2.3) + letter_opener (1.2.0) + launchy (~> 2.2) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -336,6 +340,7 @@ DEPENDENCIES haml (~> 4.0.0) http_accept_language! json (~> 1.8.1) + letter_opener memcache-client (~> 1.8.5) mini_magick (~> 3.4) msgpack (~> 0.5.3) diff --git a/app/assets/javascripts/static/donate.js b/app/assets/javascripts/static/donate.js index 3efde440..ca78514d 100644 --- a/app/assets/javascripts/static/donate.js +++ b/app/assets/javascripts/static/donate.js @@ -2,6 +2,8 @@ var donationForm = document.getElementById('donation-form'); var amountField = donationForm.querySelector( '[name=donation\\[amount\\]]'); + var emailField = donationForm.querySelector( + '[name=donation\\[donor_email\\]]'); var tokenField = donationForm.querySelector( '[name=donation\\[stripe_token\\]]'); @@ -10,6 +12,7 @@ image: donationForm.getAttribute('data-checkout-image'), token: function(token) { tokenField.value = token.id; + emailField.value = token.email; donationForm.submit(); } }); diff --git a/app/mailers/donation_mailer.rb b/app/mailers/donation_mailer.rb new file mode 100644 index 00000000..97a26abe --- /dev/null +++ b/app/mailers/donation_mailer.rb @@ -0,0 +1,8 @@ +class DonationMailer < ActionMailer::Base + default from: "matchu@openneo.net" + + def thank_you_email(donation, recipient) + @donation = donation + mail(to: recipient, subject: 'Thanks for donating to Dress to Impress!') + end +end diff --git a/app/models/donation.rb b/app/models/donation.rb index 2f3b5ce5..5495c5a0 100644 --- a/app/models/donation.rb +++ b/app/models/donation.rb @@ -29,6 +29,7 @@ class Donation < ActiveRecord::Base donation.charge_id = charge.id donation.user_id = user.try(:id) donation.donor_name = user.try(:name) + donation.donor_email = params[:donor_email] donation.secret = new_secret num_features = amount / FEATURE_COST @@ -42,6 +43,8 @@ class Donation < ActiveRecord::Base features.each(&:save!) end + DonationMailer.thank_you_email(donation, customer.email).deliver + donation end diff --git a/app/views/donation_mailer/thank_you_email.html.erb b/app/views/donation_mailer/thank_you_email.html.erb new file mode 100644 index 00000000..87da2924 --- /dev/null +++ b/app/views/donation_mailer/thank_you_email.html.erb @@ -0,0 +1,38 @@ +

+ Hello, hello! I'm Matchu, loving father of Dress to Impress. + I started building the site on a whim one day, and never expected it to + really catch on—but here you are, proving that someone else out there loves + Dress to Impress as much as I do <3 Thank you so much! +

+ +

+ Before I forget, let's get to receipt business. + You donated + <%= number_to_currency @donation.amount / 100.0 %> + (thanks again, by the way!), + and you can update the name and outfits on that donation whenever you like at + <%= link_to donation_url(@donation), donation_url(@donation) %>. +

+ +

+ Anyway. I hope you enjoy our little thank-you gift (you do have some + beautiful outfits for me to show off, right?), and that Dress to Impress + continues to bring you joy :) +

+ +

+ Oh! And, if you ever have anything to say to me, please let me know + at <%= mail_to 'matchu@openneo.net' %>. I'm looking forward to any and all + questions, comments, concerns, insults, treasure maps, love letters, or memes + you send my way :D +

+ +

+ Thanks again for your help! DTI <3s you.
+ —Matchu +

+ +

+ P.S. Seriously. Reply to this email and tell me something. + It'll make my day :D +

diff --git a/app/views/donations/show.html.haml b/app/views/donations/show.html.haml index ab992408..f56a932d 100644 --- a/app/views/donations/show.html.haml +++ b/app/views/donations/show.html.haml @@ -14,14 +14,15 @@ %p %strong But enough about us. Let's talk about you! - When we brag about you on our donors list, what should we say? + When we brag about you on our #{link_to 'donors list', donate_path}, + what should we say? (If you'd rather take care of this later, no worries! Check your email for a copy of this URL.) = form_for @donation, html: {id: 'edit-donation'} do |f| %ul %li.name - = f.label :donor_name, "Your name on the donors page" + = f.label :donor_name, "Your name on the donors list" = f.text_field :donor_name, placeholder: 'Anonymous' - @features.each do |feature| diff --git a/app/views/static/donate.html.haml b/app/views/static/donate.html.haml index 034b84cb..d0c36606 100644 --- a/app/views/static/donate.html.haml +++ b/app/views/static/donate.html.haml @@ -10,10 +10,14 @@ 'data-checkout-image' => image_path('default-preview.png'), 'data-checkout-publishable-key' => Rails.configuration.stripe[:publishable_key] do = hidden_field_tag 'donation[stripe_token]' + = hidden_field_tag 'donation[donor_email]' %header %p#donation-form-title Thanks for supporting Dress to Impress! %p#donation-form-subtitle + Securely powered by #{link_to 'Stripe', 'https://stripe.com/'}. + We never, ever see your payment info. + %br All donations go directly to our hosting costs. Thanks for your help! %div = precede '$' do diff --git a/config/environments/development.rb b/config/environments/development.rb index 60312fd4..6eda8d2a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -15,6 +15,8 @@ OpenneoImpressItems::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = {host: "impress.dev.openneo.net"} + config.action_mailer.delivery_method = :letter_opener config.active_support.deprecation = :log diff --git a/config/environments/development_async.rb b/config/environments/development_async.rb index 6f7f8c49..7c40fbe5 100644 --- a/config/environments/development_async.rb +++ b/config/environments/development_async.rb @@ -18,6 +18,8 @@ OpenneoImpressItems::Application.configure do config.action_mailer.raise_delivery_errors = false config.active_support.deprecation = :log + + config.action_mailer.default_url_options[:host] = 'impress.dev.openneo.net' config.threadsafe! end diff --git a/config/environments/production.rb b/config/environments/production.rb index 361292e5..daaf18fc 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -61,6 +61,21 @@ OpenneoImpressItems::Application.configure do # config.force_ssl = true config.react.variant = :production + + config.action_mailer.default_url_options = {host: "impress.openneo.net"} + + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + :address => "mail.openneo.net", + :port => 587, + :domain => "openneo.net", + :authentication => :login, + :user_name => "matchu@openneo.net", + :password => ENV.fetch("MATCHU_EMAIL_PASSWORD"), + :enable_starttls_auto => false + } + config.action_mailer.raise_delivery_errors = true + config.action_mailer.perform_deliveries = true end LocalImpressHost = 'newimpress.openneo.net' diff --git a/db/migrate/20140910181819_add_email_to_donations.rb b/db/migrate/20140910181819_add_email_to_donations.rb new file mode 100644 index 00000000..a187ff2d --- /dev/null +++ b/db/migrate/20140910181819_add_email_to_donations.rb @@ -0,0 +1,5 @@ +class AddEmailToDonations < ActiveRecord::Migration + def change + add_column :donations, :donor_email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index b47e72cf..720ef3cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140910030549) do +ActiveRecord::Schema.define(:version => 20140910181819) do create_table "auth_servers", :force => true do |t| t.string "short_name", :limit => 10, :null => false @@ -107,13 +107,14 @@ ActiveRecord::Schema.define(:version => 20140910030549) do end create_table "donations", :force => true do |t| - t.integer "amount", :null => false - t.string "charge_id", :null => false + t.integer "amount", :null => false + t.string "charge_id", :null => false t.integer "user_id" t.string "donor_name" t.string "secret" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "donor_email" end create_table "donations_old", :force => true do |t| diff --git a/spec/mailers/donation_mailer_spec.rb b/spec/mailers/donation_mailer_spec.rb new file mode 100644 index 00000000..97227bf6 --- /dev/null +++ b/spec/mailers/donation_mailer_spec.rb @@ -0,0 +1,5 @@ +require "spec_helper" + +describe DonationMailer do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/vendor/cache/launchy-2.4.2.gem b/vendor/cache/launchy-2.4.2.gem new file mode 100644 index 00000000..23763cc6 Binary files /dev/null and b/vendor/cache/launchy-2.4.2.gem differ diff --git a/vendor/cache/letter_opener-1.2.0.gem b/vendor/cache/letter_opener-1.2.0.gem new file mode 100644 index 00000000..adbfc291 Binary files /dev/null and b/vendor/cache/letter_opener-1.2.0.gem differ