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

Persist email verifications #4573

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions gratipay/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ 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):
pass

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):
Expand Down
2 changes: 1 addition & 1 deletion gratipay/models/participant/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions sql/branch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 4 additions & 4 deletions tests/py/test_participant_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_cannot_set_primary_to_unverified(self):
with self.assertRaises(EmailNotVerified):
self.hit_email_spt('set-primary', '[email protected]')

def test_remove_email(self):
def test_unlink_email_address(self):
# Can remove unverified
self.hit_email_spt('add-email', '[email protected]')
self.hit_email_spt('remove', '[email protected]')
Expand Down Expand Up @@ -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('[email protected]', foo)
_claims = lambda: self.db.all('select package_id from claims')
assert _claims() == [foo.id]
self.alice.remove_email('[email protected]')
self.alice.unlink_email_address('[email protected]')
assert _claims() == []


Expand Down