From ceb10c7f78dbea9dad6381b0e7c58d83834da029 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Tue, 12 May 2015 11:50:28 -0400 Subject: [PATCH] Remove email notifications related to pledging Sorry, @rohitpaulk. :-( --- emails/notify_patron.spt | 14 ------ gratipay/models/account_elsewhere.py | 1 - gratipay/models/participant.py | 18 -------- sql/branch.sql | 1 + tests/py/test_email_notifs.py | 58 ------------------------- www/~/%username/settings/index.html.spt | 5 --- 6 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 emails/notify_patron.spt delete mode 100644 tests/py/test_email_notifs.py diff --git a/emails/notify_patron.spt b/emails/notify_patron.spt deleted file mode 100644 index a6e3a1df26..0000000000 --- a/emails/notify_patron.spt +++ /dev/null @@ -1,14 +0,0 @@ -{{ _("{0} from {1} has joined Gratipay!", user_name, platform) }} - -[---] text/html -{{ _("Your pledge to give {0} every week to {1} will be turned into action now that they have joined Gratipay. Huzzah!", - format_currency(amount, 'USD'), - ('{1}'|safe).format(profile_url, user_name)) }} -[---] text/plain -{{ _("Your pledge to give {0} every week to {1} will be turned into action now that they have joined Gratipay. Huzzah!", - format_currency(amount, 'USD'), - user_name) }} - -{{ _("Follow this link to view {0}'s profile:", user_name) }} - -{{ profile_url }} diff --git a/gratipay/models/account_elsewhere.py b/gratipay/models/account_elsewhere.py index 2353b37c51..b33f540c83 100644 --- a/gratipay/models/account_elsewhere.py +++ b/gratipay/models/account_elsewhere.py @@ -233,7 +233,6 @@ def opt_in(self, desired_username): else: newly_claimed = True user.participant.set_as_claimed() - user.participant.notify_patrons(self) try: user.participant.change_username(desired_username) except ProblemChangingUsername: diff --git a/gratipay/models/participant.py b/gratipay/models/participant.py index 17f4c8bb78..0866dd2c9f 100644 --- a/gratipay/models/participant.py +++ b/gratipay/models/participant.py @@ -658,19 +658,6 @@ def render(t, context): self._mailer.messages.send(message=message) return 1 # Sent - def notify_patrons(self, elsewhere, tips=None): - tips = self.get_tips_receiving() if tips is None else tips - for t in tips: - p = Participant.from_username(t.tipper) - if p.email_address and p.notify_on_opt_in: - p.queue_email( - 'notify_patron', - user_name=elsewhere.user_name, - platform=elsewhere.platform_data.display_name, - amount=t.amount, - profile_url=elsewhere.gratipay_url, - ) - def queue_email(self, spt_name, **context): self.db.run(""" INSERT INTO email_queue @@ -1602,8 +1589,6 @@ def take_over(self, account, have_confirmation=False): # this is a no op - trying to take over itself return - # Save old tips so we can notify patrons that they've been claimed - old_tips = None if other.is_claimed else other.get_tips_receiving() # Make sure we have user confirmation if needed. # ============================================== @@ -1740,9 +1725,6 @@ def take_over(self, account, have_confirmation=False): if new_balance is not None: self.set_attributes(balance=new_balance) - if old_tips: - self.notify_patrons(elsewhere, tips=old_tips) - self.update_avatar() # Note: the order matters here, receiving needs to be updated before giving diff --git a/sql/branch.sql b/sql/branch.sql index d059b3c41b..c21a8e8522 100644 --- a/sql/branch.sql +++ b/sql/branch.sql @@ -1,5 +1,6 @@ BEGIN; ALTER TABLE participants DROP COLUMN pledging; + ALTER TABLE participants DROP COLUMN notify_on_opt_in; END; diff --git a/tests/py/test_email_notifs.py b/tests/py/test_email_notifs.py deleted file mode 100644 index b1cb8d8cbf..0000000000 --- a/tests/py/test_email_notifs.py +++ /dev/null @@ -1,58 +0,0 @@ -from gratipay.models.account_elsewhere import AccountElsewhere -from gratipay.models.participant import Participant -from gratipay.testing.emails import EmailHarness - - -class TestTransactionalEmails(EmailHarness): - - def setUp(self): - EmailHarness.setUp(self) - self.bob = self.make_participant('bob', claimed_time='now', email_address='bob@example.com') - self.dan = self.make_participant('dan', claimed_time='now', email_address='dan@example.com') - self.alice = self.make_participant('alice', claimed_time='now', email_address='alice@example.com') - - def test_opt_in_sends_notifications_to_patrons(self): - carl_twitter = self.make_elsewhere('twitter', 1, 'carl') - roy = self.make_participant('roy', claimed_time='now', email_address='roy@example.com') - self.client.POST( '/~roy/emails/notifications.json' - , data={'toggle': 'notify_on_opt_in'} - , auth_as='roy' - ) - - self.bob.set_tip_to(carl_twitter.participant.username, '100') - self.dan.set_tip_to(carl_twitter.participant.username, '100') - roy.set_tip_to(carl_twitter.participant.username, '100') # Roy will NOT receive an email. - - AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl') - - Participant.dequeue_emails() - assert self.mailer.call_count == 2 # Emails should only be sent to bob and dan - last_email = self.get_last_email() - assert last_email['to'][0]['email'] == 'dan@example.com' - expected = "to carl" - assert expected in last_email['text'] - - def test_take_over_sends_notifications_to_patrons(self): - dan_twitter = self.make_elsewhere('twitter', 1, 'dan') - - self.alice.set_tip_to(self.dan, '100') # Alice shouldn't receive an email. - self.bob.set_tip_to(dan_twitter.participant.username, '100') # Bob should receive an email. - - self.dan.take_over(dan_twitter, have_confirmation=True) - - Participant.dequeue_emails() - assert self.mailer.call_count == 1 - last_email = self.get_last_email() - assert last_email['to'][0]['email'] == 'bob@example.com' - expected = "to dan" - assert expected in last_email['text'] - - def test_opt_in_notification_includes_unsubscribe(self): - carl_twitter = self.make_elsewhere('twitter', 1, 'carl') - roy = self.make_participant('roy', claimed_time='now', email_address='roy@example.com', notify_on_opt_in=1) - roy.set_tip_to(carl_twitter.participant.username, '100') - - AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl') - - Participant.dequeue_emails() - assert "To stop receiving" in self.get_last_email()['text'] diff --git a/www/~/%username/settings/index.html.spt b/www/~/%username/settings/index.html.spt index 9b13f5ba43..89bb0a5370 100644 --- a/www/~/%username/settings/index.html.spt +++ b/www/~/%username/settings/index.html.spt @@ -205,11 +205,6 @@ emails = participant.get_emails()
{{ _("Send me notifications via email:") }}
-
{{ _("When my credit card is charged:") }}