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.
Merge pull request #4309 from gratipay/project/claim-packages-confirm
UI to send confirmation email for unclaimed packages
- Loading branch information
Showing
11 changed files
with
146 additions
and
17 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
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