This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd21b9a
commit a9f9dfe
Showing
9 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{ _("Claim {0} on Gratipay?", project) }} | ||
|
||
[---] text/html | ||
{{ _("We've received a request to connect {0} to the {1} account on Gratipay. Sound familiar?", | ||
('<b>%s</b>'|safe) % email, | ||
('<b><a href="https://gratipay.com/~{0}/">{0}</a></b>'|safe).format(username)) }} | ||
<br> | ||
<br> | ||
<a href="{{ link }}" style="{{ button_style }}">{{ _("Yes, proceed!") }}</a> | ||
|
||
[---] text/plain | ||
{{ _("We've received a request to connect {0} to the {1} account on Gratipay. Sound familiar?", | ||
email, username) }} | ||
|
||
{{ _("Follow this link to finish connecting your email:") }} | ||
|
||
{{ link }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
|
||
class PackageClaiming(object): | ||
|
||
"""Gratipay participants may claim packages on the Node package manager | ||
(npm), bringing them into Gratipay as projects similar to any other. The | ||
claiming process is handled via email: ``initiate_package_claim`` sends an | ||
email to an address registered with npm, and a link back from the email | ||
lands in ``claim_package`` to finalize the claim. | ||
Packages can also be unclaimed, and reclaimed. | ||
""" | ||
|
||
def initiate_package_claim(self, package, email): | ||
"""Initiate a claim on the given package. | ||
:param Package package: a ``Package`` instance | ||
:returns: ``None`` | ||
""" | ||
assert email in package.emails # sanity check | ||
|
||
r = self.send_email('claim_package', | ||
email=email, | ||
link=link.format(**locals()), | ||
include_unsubscribe=False) | ||
assert r == 1 # Make sure the verification email was sent | ||
if self.email_address: | ||
self.send_email('verification_notice', | ||
new_email=email, | ||
include_unsubscribe=False) | ||
return 2 | ||
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
from gratipay.models.account_elsewhere import AccountElsewhere | ||
from gratipay.models.exchange_route import ExchangeRoute | ||
from gratipay.models.participant import Participant | ||
from gratipay.models.package import NPM, Package | ||
from gratipay.security import user | ||
from gratipay.testing.vcr import use_cassette | ||
from psycopg2 import IntegrityError, InternalError | ||
|
@@ -181,14 +182,15 @@ def make_team(self, *a, **kw): | |
return team | ||
|
||
|
||
def make_package(self, package_manager='npm', name='foo', description='Foo', | ||
def make_package(self, package_manager=NPM, name='foo', description='Foo', | ||
emails=['[email protected]']): | ||
"""Factory for packages. | ||
""" | ||
return self.db.one( 'INSERT INTO packages (package_manager, name, description, emails) ' | ||
'VALUES (%s, %s, %s, %s) RETURNING *' | ||
, (package_manager, name, description, emails) | ||
) | ||
self.db.run( 'INSERT INTO packages (package_manager, name, description, emails) ' | ||
'VALUES (%s, %s, %s, %s) RETURNING *' | ||
, (package_manager, name, description, emails) | ||
) | ||
return Package.from_names(NPM, name) | ||
|
||
|
||
def make_participant(self, username, **kw): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,12 +237,12 @@ def test_cannot_resend_verification_too_frequently(self): | |
self.alice.add_email('[email protected]') | ||
time.sleep(0.05) | ||
with self.assertRaises(ResendingTooFast): | ||
self.alice.add_email('[email protected]', '0.1 seconds') | ||
self.alice.add_email('[email protected]', resend_threshold='0.1 seconds') | ||
|
||
def test_can_resend_verification_after_a_while(self): | ||
self.alice.add_email('[email protected]') | ||
time.sleep(0.15) | ||
self.alice.add_email('[email protected]', '0.1 seconds') | ||
self.alice.add_email('[email protected]', resend_threshold='0.1 seconds') | ||
|
||
def test_html_escaping(self): | ||
self.alice.add_email("foo'[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,10 +190,10 @@ def test_email_addresses_merging(self): | |
alice.verify_email('[email protected]', alice.get_email('[email protected]').nonce) | ||
bob_github = self.make_elsewhere('github', 2, 'bob') | ||
bob = bob_github.opt_in('bob')[0].participant | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]', resend_threshold='0 seconds') | ||
bob.verify_email('[email protected]', bob.get_email('[email protected]').nonce) | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]', resend_threshold='0 seconds') | ||
bob.add_email('[email protected]', resend_threshold='0 seconds') | ||
alice.take_over(bob_github, have_confirmation=True) | ||
|
||
alice_emails = {e.address: e for e in alice.get_emails()} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters