Make contribution code handle not having a user in all cases.
This commit is contained in:
parent
a2d89f2910
commit
31d458e067
|
@ -80,9 +80,11 @@ example_email_args = {
|
||||||
'proposal': proposal,
|
'proposal': proposal,
|
||||||
'contribution': contribution,
|
'contribution': contribution,
|
||||||
'contributor': user,
|
'contributor': user,
|
||||||
|
# 'contributor': None,
|
||||||
'funded': '50',
|
'funded': '50',
|
||||||
'proposal_url': 'http://someproposal.com',
|
'proposal_url': 'http://someproposal.com',
|
||||||
'contributor_url': 'http://someuser.com',
|
'contributor_url': 'http://someuser.com',
|
||||||
|
# 'contributor_url': None,
|
||||||
},
|
},
|
||||||
'proposal_comment': {
|
'proposal_comment': {
|
||||||
'author': user,
|
'author': user,
|
||||||
|
|
|
@ -86,7 +86,7 @@ def proposal_contribution(email_args):
|
||||||
'subject': 'You just got a contribution!',
|
'subject': 'You just got a contribution!',
|
||||||
'title': 'You just got a contribution',
|
'title': 'You just got a contribution',
|
||||||
'preview': '{} just contributed {} to your proposal {}'.format(
|
'preview': '{} just contributed {} to your proposal {}'.format(
|
||||||
email_args['contributor'].display_name,
|
email_args['contributor'].display_name if email_args['contributor'] else 'An anonymous contributor',
|
||||||
email_args['contribution'].amount,
|
email_args['contribution'].amount,
|
||||||
email_args['proposal'].title,
|
email_args['proposal'].title,
|
||||||
),
|
),
|
||||||
|
|
|
@ -375,11 +375,12 @@ def post_proposal_update(proposal_id, title, content):
|
||||||
# Send email to all contributors (even if contribution failed)
|
# Send email to all contributors (even if contribution failed)
|
||||||
contributions = ProposalContribution.query.filter_by(proposal_id=proposal_id).all()
|
contributions = ProposalContribution.query.filter_by(proposal_id=proposal_id).all()
|
||||||
for c in contributions:
|
for c in contributions:
|
||||||
send_email(c.user.email_address, 'contribution_update', {
|
if c.user:
|
||||||
'proposal': g.current_proposal,
|
send_email(c.user.email_address, 'contribution_update', {
|
||||||
'proposal_update': update,
|
'proposal': g.current_proposal,
|
||||||
'update_url': make_url(f'/proposals/{proposal_id}?tab=updates&update={update.id}'),
|
'proposal_update': update,
|
||||||
})
|
'update_url': make_url(f'/proposals/{proposal_id}?tab=updates&update={update.id}'),
|
||||||
|
})
|
||||||
|
|
||||||
dumped_update = proposal_update_schema.dump(update)
|
dumped_update = proposal_update_schema.dump(update)
|
||||||
return dumped_update, 201
|
return dumped_update, 201
|
||||||
|
@ -553,11 +554,12 @@ def post_contribution_confirmation(contribution_id, to, amount, txid):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Send to the user
|
# Send to the user
|
||||||
send_email(contribution.user.email_address, 'contribution_confirmed', {
|
if contribution.user:
|
||||||
'contribution': contribution,
|
send_email(contribution.user.email_address, 'contribution_confirmed', {
|
||||||
'proposal': contribution.proposal,
|
'contribution': contribution,
|
||||||
'tx_explorer_url': f'{EXPLORER_URL}transactions/{txid}',
|
'proposal': contribution.proposal,
|
||||||
})
|
'tx_explorer_url': f'{EXPLORER_URL}transactions/{txid}',
|
||||||
|
})
|
||||||
|
|
||||||
# Send to the full proposal gang
|
# Send to the full proposal gang
|
||||||
for member in contribution.proposal.team:
|
for member in contribution.proposal.team:
|
||||||
|
@ -567,7 +569,7 @@ def post_contribution_confirmation(contribution_id, to, amount, txid):
|
||||||
'contributor': contribution.user,
|
'contributor': contribution.user,
|
||||||
'funded': contribution.proposal.funded,
|
'funded': contribution.proposal.funded,
|
||||||
'proposal_url': make_url(f'/proposals/{contribution.proposal.id}'),
|
'proposal_url': make_url(f'/proposals/{contribution.proposal.id}'),
|
||||||
'contributor_url': make_url(f'/profile/{contribution.user.id}'),
|
'contributor_url': make_url(f'/profile/{contribution.user.id}') if contribution.user else '',
|
||||||
})
|
})
|
||||||
|
|
||||||
# TODO: Once we have a task queuer in place, queue emails to everyone
|
# TODO: Once we have a task queuer in place, queue emails to everyone
|
||||||
|
|
|
@ -78,12 +78,13 @@ class ProposalDeadline:
|
||||||
'proposal': proposal,
|
'proposal': proposal,
|
||||||
})
|
})
|
||||||
for c in proposal.contributions:
|
for c in proposal.contributions:
|
||||||
send_email(c.user.email_address, 'contribution_proposal_failed', {
|
if c.user:
|
||||||
'contribution': c,
|
send_email(c.user.email_address, 'contribution_proposal_failed', {
|
||||||
'proposal': proposal,
|
'contribution': c,
|
||||||
'refund_address': c.user.settings.refund_address,
|
'proposal': proposal,
|
||||||
'account_settings_url': make_url('/profile/settings?tab=account')
|
'refund_address': c.user.settings.refund_address,
|
||||||
})
|
'account_settings_url': make_url('/profile/settings?tab=account')
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
JOBS = {
|
JOBS = {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<p style="margin: 0 0 20px;">
|
<p style="margin: 0 0 20px;">
|
||||||
Your proposal <strong>{{ args.proposal.title }}</strong> just got a
|
Your proposal <strong>{{ args.proposal.title }}</strong> just got a
|
||||||
<strong>{{ args.contribution.amount }} ZEC</strong> contribution from
|
<strong>{{ args.contribution.amount }} ZEC</strong> contribution from
|
||||||
|
{% if args.contributor %}
|
||||||
<a href="{{ args.contributor_url }}" target="_blank">{{ args.contributor.display_name }}</a>.
|
<a href="{{ args.contributor_url }}" target="_blank">{{ args.contributor.display_name }}</a>.
|
||||||
|
{% else %}
|
||||||
|
an anonymous contributor.
|
||||||
|
{% endif %}
|
||||||
Your proposal is now at
|
Your proposal is now at
|
||||||
<strong>{{ args.funded }} / {{ args.proposal.target }} ZEC</strong>.
|
<strong>{{ args.funded }} / {{ args.proposal.target }} ZEC</strong>.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
Your proposal "{{ args.proposal.title }}" just got a
|
Your proposal "{{ args.proposal.title }}" just got a
|
||||||
{{ args.contribution.amount }} ZEC contribution from
|
{{ args.contribution.amount }} ZEC contribution from {{ args.contributor.display_name if args.contributor else 'an anonymous contributor' }}.
|
||||||
{{ args.contributor.display_name }}. Your proposal is now at {{ args.funded }} / {{ args.proposal.target }} ZEC.
|
Your proposal is now at {{ args.funded }} / {{ args.proposal.target }} ZEC.
|
||||||
|
|
||||||
|
{% if args.contributor %}
|
||||||
See {{ args.contributor.display_name }}'s profile: {{ args.contributor_url }}
|
See {{ args.contributor.display_name }}'s profile: {{ args.contributor_url }}
|
||||||
|
{% endif %}
|
||||||
View your proposal: {{ args.proposal_url }}
|
View your proposal: {{ args.proposal_url }}
|
|
@ -2,7 +2,7 @@
|
||||||
anonymous_user = {
|
anonymous_user = {
|
||||||
'userid': 0,
|
'userid': 0,
|
||||||
'display_name': 'Anonymous',
|
'display_name': 'Anonymous',
|
||||||
'title': 'Anonymous',
|
'title': 'N/A',
|
||||||
'avatar': None,
|
'avatar': None,
|
||||||
'social_medias': [],
|
'social_medias': [],
|
||||||
'email_verified': True,
|
'email_verified': True,
|
||||||
|
|
Loading…
Reference in New Issue