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
UI to send confirmation email for unclaimed packages #4309
Merged
nobodxbodon
merged 7 commits into
project/claim-packages
from
project/claim-packages-confirm
Feb 14, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb000ed
Start fleshing out send confirmation flow
chadwhitacre aa9b3e1
Failing ttw test for sending a confirmation link
chadwhitacre 83a9ab1
Prune a console.log while we're paying attention
chadwhitacre d7560d9
Rough in sending a confirmation email
chadwhitacre 12659d1
Round out confirmation form for zero and ∞
chadwhitacre 3586969
Use constant
chadwhitacre 455f06c
Lightly style the email list
chadwhitacre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,29 @@ | ||
Gratipay.packages = {}; | ||
|
||
Gratipay.packages.post = function(e) { | ||
e.preventDefault(); | ||
var $this = $(this); | ||
var action = 'add-email-and-claim-package'; | ||
var package_id = $('input[name=package_id]').val(); | ||
var email = $('input[name=email]:checked').val(); | ||
|
||
var $inputs = $('input, button'); | ||
$inputs.prop('disabled', true); | ||
|
||
$.ajax({ | ||
url: '/~' + Gratipay.username + '/emails/modify.json', | ||
type: 'POST', | ||
data: {action: action, address: email, package_id: package_id}, | ||
dataType: 'json', | ||
success: function (msg) { | ||
if (msg) { | ||
Gratipay.notification(msg, 'success'); | ||
} | ||
$inputs.prop('disabled', false); | ||
}, | ||
error: [ | ||
function () { $inputs.prop('disabled', false); }, | ||
Gratipay.error | ||
], | ||
}); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
.sorry { | ||
text-align: center; | ||
font: normal 12px/15px $Ideal; | ||
color: $medium-gray; | ||
} | ||
|
||
table.listing { | ||
width: 100%; | ||
|
||
|
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,8 @@ | ||
#package { | ||
.emails { | ||
margin: 1em 0; | ||
li { | ||
list-style: none; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from gratipay.models.package import NPM | ||
from gratipay.testing import Harness | ||
|
||
|
||
class TestAnon(Harness): | ||
class TestClaimingWorkflow(Harness): | ||
|
||
def setUp(self): | ||
self.make_package() | ||
|
||
def test_gets_signin_page(self): | ||
assert 'npm/foo</a> has not been claimed' in self.client.GET('/on/npm/foo/').body | ||
def test_anon_gets_signin_page_from_unclaimed(self): | ||
body = self.client.GET('/on/npm/foo/').body | ||
assert 'npm/foo</a> has not been claimed' in body | ||
assert 'with a couple clicks' in body | ||
|
||
def test_auth_gets_send_confirmation_page_from_unclaimed(self): | ||
self.make_participant('bob', claimed_time='now') | ||
body = self.client.GET('/on/npm/foo/', auth_as='bob').body | ||
assert 'npm/foo</a> has not been claimed' in body | ||
assert 'using any email address' in body | ||
assert '[email protected]' in body | ||
|
||
def test_auth_gets_multiple_options_if_present(self): | ||
self.make_package(NPM, 'bar', 'Bar', ['[email protected]', '[email protected]']) | ||
self.make_participant('bob', claimed_time='now') | ||
body = self.client.GET('/on/npm/bar/', auth_as='bob').body | ||
assert 'using any email address' in body | ||
assert '[email protected]' in body | ||
assert '[email protected]' in body | ||
|
||
def test_auth_gets_something_if_no_emails(self): | ||
self.make_package(NPM, 'bar', 'Bar', []) | ||
self.make_participant('bob', claimed_time='now') | ||
body = self.client.GET('/on/npm/bar/', auth_as='bob').body | ||
assert "didn't find any email addresses" in body |
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,28 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from gratipay.testing import BrowserHarness | ||
|
||
|
||
class TestSendConfirmationLink(BrowserHarness): | ||
|
||
def check(self, choice=0): | ||
self.make_participant('bob', claimed_time='now') | ||
self.sign_in('bob') | ||
self.visit('/on/npm/foo/') | ||
self.css('input[type=radio]')[choice].click() | ||
self.css('button')[0].click() | ||
assert self.has_element('.notification.notification-success', 1) | ||
assert self.has_text('Check [email protected] for a confirmation link.') | ||
|
||
def test_appears_to_work(self): | ||
self.make_package() | ||
self.check() | ||
|
||
def test_works_when_there_are_multiple_addresses(self): | ||
self.make_package(emails=['[email protected]', '[email protected]']) | ||
self.check() | ||
|
||
def test_can_send_to_second_email(self): | ||
self.make_package(emails=['[email protected]', '[email protected]']) | ||
self.check(choice=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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it's
None
?