Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
fix payday notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Apr 9, 2015
1 parent bd5f789 commit 047b0c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions emails/charge_failed.spt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
{{ ngettext(
"We tried to charge your credit card {0} today, to fund your weekly payment to {1}, but it failed.",
"We tried to charge your credit card {0} today, to fund your weekly payments to {1}, but it failed.",
ntippees,
format_currency(exchange.amount, 'USD'),
top_tippee.username if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee.username)
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee)
) }}

{{ _("The error message we received from our payment processor is:") }}<pre>
Expand All @@ -19,8 +20,9 @@
{{ ngettext(
"We tried to charge your credit card {0} today, to fund your weekly payment to {1}, but it failed.",
"We tried to charge your credit card {0} today, to fund your weekly payments to {1}, but it failed.",
ntippees,
format_currency(exchange.amount, 'USD'),
top_tippee.username if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee.username)
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee)
) }}

{{ _("The error message we received from our payment processor is:") }}
Expand Down
6 changes: 4 additions & 2 deletions emails/charge_succeeded.spt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
{{ ngettext(
"We charged your credit card {0} today, to fund your weekly payment to {1}. Thanks for using Gratipay!",
"We charged your credit card {0} today, to fund your weekly payments to {1}. Thanks for using Gratipay!",
ntippees,
format_currency(exchange.amount, 'USD'),
('<b><a href="{0}">{1}</a></b>'|safe).format(
participant.profile_url+'giving/',
top_tippee.username if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee.username)
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee)
)) }}

[---] text/plain
{{ ngettext(
"We charged your credit card {0} today, to fund your weekly payment to {1}. Thanks for using Gratipay!",
"We charged your credit card {0} today, to fund your weekly payments to {1}. Thanks for using Gratipay!",
ntippees,
format_currency(exchange.amount, 'USD'),
top_tippee.username if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee.username)
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', '{0} and {n} others', ntippees - 1, top_tippee)
) }}

{{ _("Follow this link if you want to view or modify your payments:") }} {{ participant.profile_url+'giving/' }}
11 changes: 5 additions & 6 deletions gratipay/billing/payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,30 +729,29 @@ def notify_participants(self):
username = p.username
ntippees, top_tippee = self.db.one("""
WITH tippees AS (
SELECT p.*::participants
SELECT p.username, amount
FROM ( SELECT DISTINCT ON (tippee) tippee, amount
FROM tips
WHERE mtime < %(ts_start)s
AND tipper = %(username)s
ORDER BY tippee, mtime DESC
)
) t
JOIN participants p ON p.username = t.tippee
WHERE t.amount > 0
AND (p.goal IS NULL or p.goal >= 0)
AND p.is_suspicious IS NOT true
AND p.claimed_time < %(ts_start)s
)
SELECT ( SELECT count(*) FROM tippees ) AS ntippees
, ( SELECT t.*
FROM tippees t
, ( SELECT username
FROM tippees
ORDER BY amount DESC
LIMIT 1
) AS top_tippee
""", locals())
p.queue_email(
'charge_'+e.status,
exchange=e,
participant=p,
exchange=dict(amount=e.amount, fee=e.fee, note=e.note),
ntippees=ntippees,
top_tippee=top_tippee,
)
Expand Down
1 change: 1 addition & 0 deletions gratipay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ def remove_email(self, address):
(self.username, address))

def send_email(self, spt_name, **context):
context['participant'] = self
context['username'] = self.username
context['button_style'] = (
"color: #fff; text-decoration:none; display:inline-block; "
Expand Down

0 comments on commit 047b0c2

Please sign in to comment.