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,
|
||||
'contribution': contribution,
|
||||
'contributor': user,
|
||||
# 'contributor': None,
|
||||
'funded': '50',
|
||||
'proposal_url': 'http://someproposal.com',
|
||||
'contributor_url': 'http://someuser.com',
|
||||
# 'contributor_url': None,
|
||||
},
|
||||
'proposal_comment': {
|
||||
'author': user,
|
||||
|
|
|
@ -86,7 +86,7 @@ def proposal_contribution(email_args):
|
|||
'subject': 'You just got a contribution!',
|
||||
'title': 'You just got a contribution',
|
||||
'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['proposal'].title,
|
||||
),
|
||||
|
|
|
@ -375,6 +375,7 @@ def post_proposal_update(proposal_id, title, content):
|
|||
# Send email to all contributors (even if contribution failed)
|
||||
contributions = ProposalContribution.query.filter_by(proposal_id=proposal_id).all()
|
||||
for c in contributions:
|
||||
if c.user:
|
||||
send_email(c.user.email_address, 'contribution_update', {
|
||||
'proposal': g.current_proposal,
|
||||
'proposal_update': update,
|
||||
|
@ -553,6 +554,7 @@ def post_contribution_confirmation(contribution_id, to, amount, txid):
|
|||
|
||||
else:
|
||||
# Send to the user
|
||||
if contribution.user:
|
||||
send_email(contribution.user.email_address, 'contribution_confirmed', {
|
||||
'contribution': contribution,
|
||||
'proposal': contribution.proposal,
|
||||
|
@ -567,7 +569,7 @@ def post_contribution_confirmation(contribution_id, to, amount, txid):
|
|||
'contributor': contribution.user,
|
||||
'funded': contribution.proposal.funded,
|
||||
'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
|
||||
|
|
|
@ -78,6 +78,7 @@ class ProposalDeadline:
|
|||
'proposal': proposal,
|
||||
})
|
||||
for c in proposal.contributions:
|
||||
if c.user:
|
||||
send_email(c.user.email_address, 'contribution_proposal_failed', {
|
||||
'contribution': c,
|
||||
'proposal': proposal,
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<p style="margin: 0 0 20px;">
|
||||
Your proposal <strong>{{ args.proposal.title }}</strong> just got a
|
||||
<strong>{{ args.contribution.amount }} ZEC</strong> contribution from
|
||||
{% if args.contributor %}
|
||||
<a href="{{ args.contributor_url }}" target="_blank">{{ args.contributor.display_name }}</a>.
|
||||
{% else %}
|
||||
an anonymous contributor.
|
||||
{% endif %}
|
||||
Your proposal is now at
|
||||
<strong>{{ args.funded }} / {{ args.proposal.target }} ZEC</strong>.
|
||||
</p>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
Your proposal "{{ args.proposal.title }}" just got a
|
||||
{{ args.contribution.amount }} ZEC contribution from
|
||||
{{ args.contributor.display_name }}. Your proposal is now at {{ args.funded }} / {{ args.proposal.target }} ZEC.
|
||||
{{ args.contribution.amount }} ZEC contribution from {{ args.contributor.display_name if args.contributor else 'an anonymous contributor' }}.
|
||||
Your proposal is now at {{ args.funded }} / {{ args.proposal.target }} ZEC.
|
||||
|
||||
{% if args.contributor %}
|
||||
See {{ args.contributor.display_name }}'s profile: {{ args.contributor_url }}
|
||||
{% endif %}
|
||||
View your proposal: {{ args.proposal_url }}
|
|
@ -2,7 +2,7 @@
|
|||
anonymous_user = {
|
||||
'userid': 0,
|
||||
'display_name': 'Anonymous',
|
||||
'title': 'Anonymous',
|
||||
'title': 'N/A',
|
||||
'avatar': None,
|
||||
'social_medias': [],
|
||||
'email_verified': True,
|
||||
|
|
Loading…
Reference in New Issue