Merge pull request #156 from houdiniproject/p2p_fixes
Some fixes for federated campaigns
This commit is contained in:
commit
961695403c
5 changed files with 76 additions and 8 deletions
|
@ -6,4 +6,10 @@ class CampaignMailer < BaseMailer
|
|||
@campaign = campaign
|
||||
mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})")
|
||||
end
|
||||
|
||||
def federated_creation_followup(campaign)
|
||||
@creator_profile = campaign.profile
|
||||
@campaign = campaign
|
||||
mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,7 +101,12 @@ class Campaign < ActiveRecord::Base
|
|||
after_create do
|
||||
user = self.profile.user
|
||||
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
||||
CampaignMailer.delay.creation_followup(self)
|
||||
if child_campaign?
|
||||
CampaignMailer.delay.federated_creation_followup(self)
|
||||
else
|
||||
CampaignMailer.delay.creation_followup(self)
|
||||
end
|
||||
|
||||
NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, self.nonprofit_id)
|
||||
self
|
||||
end
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%>
|
||||
<% campaign_url = Format::Url.concat(root_url, @campaign.url) %>
|
||||
|
||||
<p>Dear <%= @creator_profile.name.blank? ? @creator_profile.user.email : @creator_profile.name %>,</p>
|
||||
<br>
|
||||
|
||||
<p>Congratulations on creating your campaign to support <%= @campaign.nonprofit.name %>!</p>
|
||||
<br>
|
||||
|
||||
<p>You can visit it here: <strong><a href='<%= campaign_url %>'><%= campaign_url %></a></strong>.</p>
|
||||
<br>
|
||||
|
||||
<p>Before you share your campaign with the world, we recommend you personalize
|
||||
your campaign by including a testimonial in your words about why
|
||||
you launched your campaign. You can also set a goal amount to inspire you and your donors.
|
||||
To edit your campaign, <strong><a href="<%= "#{profile_url(@creator_profile)}/fundraisers" %>">visit your fundraisers dashboard</a></strong> (you may be asked to login)
|
||||
and select <strong><a href='<%= campaign_url %>'><%= @campaign.name%></a></strong>.</p>
|
||||
<br>
|
||||
<p>Make sure to tell your friends and family why they should support your cause and how their contributions will make a difference. Your words and your passion can make a big difference.
|
||||
Share your fundraiser on:</p>
|
||||
<ul>
|
||||
<%- if ENV['FACEBOOK_APP_ID'] -%>
|
||||
<li><%= link_to("Facebook", "https://www.facebook.com/dialog/feed?app_id=#{ENV['FACEBOOK_APP_ID']}&display=popup&caption=#{url_encode(@campaign.name)}&link=#{campaign_url}") %></li>
|
||||
<%- end -%>
|
||||
<li><%= link_to("Twitter", "https://twitter.com/intent/tweet?url=#{campaign_url}&via=#{Settings.general.name}&text=#{url_encode("Join me in supporting: #{@campaign.name}")}") %></li>
|
||||
<li>Or copy and paste the link above into an email to your friends and family</li>
|
||||
</ul>
|
||||
|
||||
<p>If you need some help getting your campaign up and running, don't hesitate to contact <strong><%= Settings.devise.mailer_sender %></strong>.</p>
|
||||
|
||||
<%= render 'emails/sig' %>
|
|
@ -1,12 +1,12 @@
|
|||
<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%>
|
||||
<%- @location_array = []
|
||||
@location_array.push(profile.city) if profile.city.present?
|
||||
@location_array.push(profile.state_code) if profile.state_code.present?
|
||||
-%>
|
||||
<section class='box' style="font-style: italic">
|
||||
<div class="well" style="padding-left:16px;">
|
||||
<h4><%= profile.name %> <% if profile.state_code || profile.city -%>
|
||||
<small>(<% if profile.state_code && profile.city -%><%= profile.city %>, <%= profile.state_code -%>
|
||||
<% elsif profile.city -%>
|
||||
<%= profile.city -%>
|
||||
<% else -%>
|
||||
<%= profile.state_code -%>
|
||||
<% end -%>)</small><% end -%>
|
||||
<h4><%= profile.name %><%- if @location_array.any? -%>
|
||||
<small>(<%= @location_array.join(', ') %>)</small><%- end -%>
|
||||
</h4>
|
||||
<blockquote><p>"<%= reason_for_supporting %>"</p></blockquote></div>
|
||||
</section>
|
||||
|
|
26
spec/models/campaign_spec.rb
Normal file
26
spec/models/campaign_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Campaign, type: :model do
|
||||
describe 'sends correct email based on type of campaign' do
|
||||
let(:nonprofit) { force_create(:nonprofit)}
|
||||
let(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: nonprofit) }
|
||||
let(:child_campaign) do
|
||||
force_create(:campaign,
|
||||
name: 'Child campaign',
|
||||
parent_campaign_id: parent_campaign.id,
|
||||
slug: "twehotiheiotheiofnieoth",
|
||||
goal_amount_dollars: "1000", nonprofit: nonprofit )
|
||||
end
|
||||
|
||||
it 'parent campaign sends out general campaign email' do
|
||||
expect { parent_campaign }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
expect(ActionMailer::Base.deliveries.last.body.include?("Create one-time or recurring")).to be_truthy
|
||||
end
|
||||
|
||||
it 'child campaign sends out federated campaign email' do
|
||||
expect { child_campaign}.to change { ActionMailer::Base.deliveries.count }.by(2)
|
||||
expect(ActionMailer::Base.deliveries.last.body.include?("including a testimonial")).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue