Merge pull request #137 from houdiniproject/p2p_improvements
P2P improvements
This commit is contained in:
commit
f8992794e7
9 changed files with 97 additions and 26 deletions
|
@ -5,16 +5,23 @@
|
|||
|
||||
<form class='form--flatFields' autosubmit action='/nonprofits/<%=@nonprofit.id%>/campaigns/<%=@campaign.id%>' method='put' data-reload parsley-validate>
|
||||
<% if @campaign.child_campaign? %>
|
||||
<div class='modal-body'>
|
||||
<section class='layout--three'>
|
||||
<fieldset>
|
||||
<label>Goal</label>
|
||||
<div class='prepend--dollar u-inlineBlock'>
|
||||
<input type='number' parsley-type='number' class='input--150' name='campaign[goal_amount_dollars]' value='<%= sprintf("%.2f", @campaign.goal_amount / 100.0) %>'>
|
||||
</div>
|
||||
</fieldset>
|
||||
</section>
|
||||
</div>
|
||||
<div class='modal-body'>
|
||||
<div class='u-margin--auto'>
|
||||
<fieldset class='col-right-12'>
|
||||
<label>What's your reason for supporting <%= @parent_campaign.name %>?</label>
|
||||
<p>Your passion is contagious! Inspire giving by telling your network why you’re getting involved in this campaign.</p>
|
||||
|
||||
<textarea class='u-marginTop--15' rows='4' name='campaign[reason_for_supporting]' required><%= @campaign.reason_for_supporting %></textarea>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class='group u-marginBottom--0'>
|
||||
<label class='u-paddingTop--5'>Goal Amount</label>
|
||||
<div class='prepend--dollar'>
|
||||
<input class='input--100 u-marginBottom--5' value='1000' type='number' name='campaign[goal_amount_dollars]' required min='1' value='<%= sprintf("%.2f", @campaign.goal_amount / 100.0) %>'>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<div class='modal-body'>
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<section class='box' style="font-style: italic">
|
||||
<div class="well" style="padding-left:16px;">
|
||||
<h4><%= profile.name %> <small>(<%= profile.city %><% if profile.state_code && profile.city %><%= profile.city_state %> <%= profile.state_code %><% end %>)</small></h4>
|
||||
<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>
|
||||
<blockquote><p>"<%= reason_for_supporting %>"</p></blockquote></div>
|
||||
</section>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<% if donation.campaign %>
|
||||
<tr>
|
||||
<td><strong>Campaign</strong></td>
|
||||
<td> <a href='<%= nonprofit_campaign_url(donation.nonprofit, donation.campaign) %>'><%= donation.campaign.name %></a> </td>
|
||||
<td><a href='<%= nonprofit_campaign_url(donation.nonprofit, donation.campaign) %>'><%= donation.campaign.name %></a><small>(Campaign Id: <%= donation.campaign.id%>, Creator: <a href="mailto:<%= donation.campaign.profile.user.email %>"><%= donation.campaign.profile.user.email %></a>)</small></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<% if donation.campaign && donation.campaign.published %>
|
||||
<tr>
|
||||
<td><strong><%= t('donation.campaign') %></strong></td>
|
||||
<td> <a href='<%= nonprofit_campaign_url(donation.nonprofit, donation.campaign) %>'><%= donation.campaign.name %></a> </td>
|
||||
<td><a href='<%= nonprofit_campaign_url(donation.nonprofit, donation.campaign) %>'><%= donation.campaign.name %></a><small>(Campaign Id: <%= donation.campaign.id%>, Creator: <a href="mailto:<%= donation.campaign.profile.user.email %>"><%= donation.campaign.profile.user.email %></a>)</small></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<% if donation.campaign && donation.campaign.published %>
|
||||
<tr>
|
||||
<td><strong>Campaign</strong></td>
|
||||
<td> <%= donation.campaign.name %></td>
|
||||
<td><a href='<%= nonprofit_campaign_url(donation.nonprofit, donation.campaign) %>'><%= donation.campaign.name %></a><small>(Campaign Id: <%= donation.campaign.id%>, Creator: <a href="mailto:<%= donation.campaign.profile.user.email %>"><%= donation.campaign.profile.user.email %></a>)</small></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ const root = state => {
|
|||
h('th', 'Name'),
|
||||
h('th', 'Total'),
|
||||
h('th', 'Gift options'),
|
||||
h('th', 'Latest gift')
|
||||
h('th', 'Latest gift'),
|
||||
h('th', 'Campaign creator')
|
||||
]),
|
||||
thunk(trs, supporters.get('data')),
|
||||
]),
|
||||
|
@ -52,6 +53,11 @@ const supporterRow = supporter =>
|
|||
, h('td', '$' + utils.cents_to_dollars(supporter.get('total_raised'))),
|
||||
h('td', supporter.get('campaign_gift_names').toJS().join(', ')),
|
||||
h('td', supporter.get('latest_gift')),
|
||||
h('td', {}, supporter.get('campaign_creator_emails').toJS().map(
|
||||
function(i, index, array) {
|
||||
return h('a', {href: `mailto:${i}`},
|
||||
i + ((i < (array.length - 1)) ? ", " : ""))
|
||||
})),
|
||||
])
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -14,7 +14,18 @@ module QueryDonations
|
|||
].concat(QuerySupporters.supporter_export_selections)
|
||||
.concat([
|
||||
"supporters.id AS \"Supporter ID\"",
|
||||
])
|
||||
]).concat([
|
||||
"coalesce(donations.designation, 'None') AS designation",
|
||||
"#{QueryPayments.get_dedication_or_empty('type')}::text AS \"Dedication Type\"",
|
||||
"#{QueryPayments.get_dedication_or_empty('name')}::text AS \"Dedicated To: Name\"",
|
||||
"#{QueryPayments.get_dedication_or_empty('supporter_id')}::text AS \"Dedicated To: Supporter ID\"",
|
||||
"#{QueryPayments.get_dedication_or_empty('contact', 'email')}::text AS \"Dedicated To: Email\"",
|
||||
"#{QueryPayments.get_dedication_or_empty('contact', "phone")}::text AS \"Dedicated To: Phone\"",
|
||||
"#{QueryPayments.get_dedication_or_empty( "contact", "address")}::text AS \"Dedicated To: Address\"",
|
||||
"#{QueryPayments.get_dedication_or_empty( "note")}::text AS \"Dedicated To: Note\"",
|
||||
"donations.campaign_id AS \"Campaign Id\"",
|
||||
"users.email AS \"Campaign Creator Email\""
|
||||
])
|
||||
).from(:donations)
|
||||
.join(:supporters, "supporters.id=donations.supporter_id")
|
||||
.left_outer_join(:campaign_gifts, "campaign_gifts.donation_id=donations.id")
|
||||
|
@ -22,10 +33,16 @@ module QueryDonations
|
|||
.left_outer_join(:recurring_donations, "recurring_donations.donation_id = donations.id")
|
||||
.join_lateral(:payments,
|
||||
get_first_payment_for_donation.parse, true)
|
||||
.where("donations.campaign_id IN (#{QueryCampaigns
|
||||
.get_campaign_and_children(campaign_id)
|
||||
.parse})")
|
||||
.group_by("donations.id", "supporters.id", "payments.id", "payments.gross_amount")
|
||||
.join(Qx.select('id, profile_id').from('campaigns')
|
||||
.where("id IN (#{QueryCampaigns
|
||||
.get_campaign_and_children(campaign_id)
|
||||
.parse})").as('campaigns').parse,
|
||||
'donations.campaign_id=campaigns.id')
|
||||
.join(Qx.select('users.id, profiles.id AS profiles_id, users.email')
|
||||
.from('users')
|
||||
.add_join('profiles', 'profiles.user_id = users.id')
|
||||
.as("users").parse, "users.profiles_id=campaigns.profile_id")
|
||||
.group_by("donations.id", "supporters.id", "payments.id", "payments.gross_amount", "users.email")
|
||||
.order_by("donations.date")
|
||||
)
|
||||
end
|
||||
|
|
|
@ -18,10 +18,16 @@ module QuerySupporters
|
|||
.where('payments.donation_id = donations.id')
|
||||
.order_by('payments.created_at ASC')
|
||||
.limit(1).parse, true)
|
||||
.join(Qx.select('id, profile_id').from('campaigns')
|
||||
.where("id IN (#{QueryCampaigns
|
||||
.get_campaign_and_children(campaign_id)
|
||||
.parse})").as('campaigns').parse,
|
||||
'donations.campaign_id=campaigns.id')
|
||||
.join(Qx.select('users.id, profiles.id AS profiles_id, users.email')
|
||||
.from('users')
|
||||
.add_join('profiles', 'profiles.user_id = users.id')
|
||||
.as("users").parse, "users.profiles_id=campaigns.profile_id")
|
||||
.where("supporters.nonprofit_id=$id", id: np_id)
|
||||
.where("donations.campaign_id IN (#{QueryCampaigns
|
||||
.get_campaign_and_children(campaign_id)
|
||||
.parse})")
|
||||
.group_by('supporters.id')
|
||||
.order_by('MAX(donations.date) DESC')
|
||||
|
||||
|
@ -49,6 +55,7 @@ module QuerySupporters
|
|||
'SUM(payments.gross_amount) AS total_raised',
|
||||
'ARRAY_AGG(DISTINCT campaign_gift_options.name) AS campaign_gift_names',
|
||||
'DATE(MAX(donations.created_at)) AS latest_gift',
|
||||
'ARRAY_AGG(DISTINCT users.email) AS campaign_creator_emails'
|
||||
).limit(limit).offset(offset)
|
||||
)
|
||||
|
||||
|
|
|
@ -6,10 +6,27 @@ describe QueryDonations do
|
|||
describe :campaign_export do
|
||||
let(:nonprofit) {force_create(:nonprofit)}
|
||||
let(:supporter) {force_create(:supporter)}
|
||||
let(:campaign) {force_create(:campaign, nonprofit:nonprofit, show_total_count:false, show_total_raised: false, goal_amount: 16000)}
|
||||
let(:campaign_child) {force_create(:campaign, nonprofit:nonprofit, parent_campaign:campaign, show_total_count:true, show_total_raised: true, goal_amount: 8000)}
|
||||
|
||||
let(:campaign_child_2) {force_create(:campaign, nonprofit:nonprofit, parent_campaign:campaign, show_total_count:true, show_total_raised: true, goal_amount: 4000 )}
|
||||
let(:profile_email) { 'something@profile_email.com'}
|
||||
let(:profile) do
|
||||
u = force_create(:user, email: profile_email)
|
||||
profile = force_create(:profile, user: u)
|
||||
end
|
||||
let(:campaign) {force_create(:campaign, nonprofit:nonprofit, show_total_count:false, show_total_raised: false, goal_amount: 16000, profile: profile)}
|
||||
|
||||
let(:profile_email1) { 'something1@profile_email.com'}
|
||||
let(:profile1) {
|
||||
u = force_create(:user, email: profile_email1)
|
||||
profile = force_create(:profile, user: u)
|
||||
}
|
||||
let(:campaign_child) {force_create(:campaign, nonprofit:nonprofit, parent_campaign:campaign, show_total_count:true, show_total_raised: true, goal_amount: 8000, profile: profile1)}
|
||||
|
||||
let(:profile_email2) { 'something2@profile_email.com'}
|
||||
let(:profile2) {
|
||||
u = force_create(:user, email: profile_email2)
|
||||
profile = force_create(:profile, user: u)
|
||||
}
|
||||
let(:campaign_child_2) {force_create(:campaign, nonprofit:nonprofit, parent_campaign:campaign, show_total_count:true, show_total_raised: true, goal_amount: 4000, profile: profile2 )}
|
||||
|
||||
let(:donation) { force_create(:donation, campaign: campaign, amount: 1000, supporter:supporter)}
|
||||
let(:payment) { force_create(:payment, donation: donation, gross_amount:1000, supporter:supporter)}
|
||||
|
@ -45,6 +62,16 @@ describe QueryDonations do
|
|||
|
||||
expect(export.map{|i| i['Amount']}).to match_array(['$10.00', '$20.00', '$40.00', '$80.00'])
|
||||
end
|
||||
|
||||
it 'includes the campaign ids' do
|
||||
export = vector_to_hash(campaign_export)
|
||||
expect(export.map{|i| i['Campaign Id']}).to match_array([campaign.id, campaign.id, campaign_child.id, campaign_child_2.id])
|
||||
end
|
||||
|
||||
it 'includes user email' do
|
||||
export = vector_to_hash(campaign_export)
|
||||
expect(export.map{|i| i['Campaign Creator Email']}).to match_array([profile_email, profile_email, profile_email1, profile_email2])
|
||||
end
|
||||
end
|
||||
|
||||
## move to common area
|
||||
|
|
Loading…
Reference in a new issue