diff --git a/gratipay/exceptions.py b/gratipay/exceptions.py index 9ab044de40..47b75d3b13 100644 --- a/gratipay/exceptions.py +++ b/gratipay/exceptions.py @@ -44,15 +44,15 @@ def lazy_body(self, _): class EmailNotOnFile(ProblemChangingEmail): def lazy_body(self, _): - return _("That email address is not on file for this package.") + return _("That email address is not on file for this package.") class EmailNotVerified(ProblemChangingEmail): def lazy_body(self, _): - return _("That email address is not verified.") + return _("That email address is not verified.") class TooManyEmailAddresses(ProblemChangingEmail): def lazy_body(self, _): - return _("You've reached the maximum number of email addresses we allow.") + return _("You've reached the maximum number of email addresses we allow.") class NoEmailAddress(Exception): @@ -60,7 +60,7 @@ class NoEmailAddress(Exception): class Throttled(LocalizedErrorResponse): def lazy_body(self, _): - return _("You've initiated too many emails too quickly. Please try again in a minute or two.") + return _("You've initiated too many emails too quickly. Please try again in a minute or two.") class ProblemChangingNumber(Exception): diff --git a/gratipay/models/participant/email.py b/gratipay/models/participant/email.py index c5da38de8a..ea50224502 100644 --- a/gratipay/models/participant/email.py +++ b/gratipay/models/participant/email.py @@ -348,7 +348,7 @@ def get_verified_email_addresses(self, cursor=None): return [email.address for email in self.get_emails(cursor) if email.verified] - def remove_email(self, address): + def unlink_email_address(self, address): """Remove the given email address from the participant's account. Raises ``CannotRemovePrimaryEmail`` if the address is primary. It's a noop if the email address is not on file. diff --git a/sql/branch.sql b/sql/branch.sql index 32354e28ce..546379bc22 100644 --- a/sql/branch.sql +++ b/sql/branch.sql @@ -11,3 +11,16 @@ BEGIN; -- assume success for the rest UPDATE email_messages SET result='' WHERE result is null; END; + +BEGIN; + ALTER TABLE email_addresses RENAME TO email_address_to_participant; + + CREATE TABLE email_addresses + ( address text NOT NULL UNIQUE + , link_to_participant bigint REFERENCES email_address_to_participant(id) + ) + + -- initialize + INSERT INTO email_verifications (address, verification) VALUES + INSERT INTO email_addresses (address, verification) VALUES +END; diff --git a/tests/py/test_participant_emails.py b/tests/py/test_participant_emails.py index 2f7abba0a6..07f83bc14c 100644 --- a/tests/py/test_participant_emails.py +++ b/tests/py/test_participant_emails.py @@ -241,7 +241,7 @@ def test_cannot_set_primary_to_unverified(self): with self.assertRaises(EmailNotVerified): self.hit_email_spt('set-primary', 'alice@example.com') - def test_remove_email(self): + def test_unlink_email_address(self): # Can remove unverified self.hit_email_spt('add-email', 'alice@example.com') self.hit_email_spt('remove', 'alice@example.com') @@ -547,14 +547,14 @@ def test_finishing_verification_clears_competing_claims_and_emails(self): assert result == (_email.VERIFICATION_FAILED, None, None) -class RemoveEmail(Alice): +class UnlinkEmailAddress(Alice): - def test_removing_email_clears_claims(self): + def test_unlinking_email_address_clears_claims(self): foo = self.make_package() self.alice.start_email_verification('alice@example.com', foo) _claims = lambda: self.db.all('select package_id from claims') assert _claims() == [foo.id] - self.alice.remove_email('alice@example.com') + self.alice.unlink_email_address('alice@example.com') assert _claims() == []