diff --git a/js/gratipay/packages.js b/js/gratipay/packages.js new file mode 100644 index 0000000000..9edffa7fca --- /dev/null +++ b/js/gratipay/packages.js @@ -0,0 +1,35 @@ +Gratipay.packages = {}; + +Gratipay.packages.post = function(e) { + e.preventDefault(); + var $this = $(this); + var action = 'add-email-and-claim-package'; + var $inputs = $('input, button'); + var $selection = $('input[name=email]:checked'); + var address = $selection.val(); + var package_id = $selection.parent().parent().data('package-id'); + + $inputs.prop('disabled', true); + + $.ajax({ + url: '/~' + Gratipay.username + '/emails/modify.json', + type: 'POST', + data: {action: action, address: address, package_id: package_id}, + dataType: 'json', + success: function (msg) { + if (msg) { + Gratipay.notification(msg, 'success'); + } + if (action == 'add-email') { + $('input.add-email').val(''); + setTimeout(function(){ window.location.reload(); }, 3000); + return; + } + $inputs.prop('disabled', false); + }, + error: [ + function () { $inputs.prop('disabled', false); }, + Gratipay.error + ], + }); +}; diff --git a/tests/ttw/test_package_claiming.py b/tests/ttw/test_package_claiming.py index 4d6a9b7c86..7de9d2de82 100644 --- a/tests/ttw/test_package_claiming.py +++ b/tests/ttw/test_package_claiming.py @@ -8,10 +8,11 @@ class Tests(BrowserHarness): def test_sending_a_confirmation_email_works(self): self.make_package() - self.make_participant('alice', claimed_time='now') - self.sign_in('alice') + self.make_participant('bob', claimed_time='now') + self.sign_in('bob') self.visit('/on/npm/foo/') - self.css('input[type=radio]').click() - self.css('button').click() + self.css('input[type=radio]')[0].click() + #import pdb; pdb.set_trace() + self.css('button')[0].click() assert self.has_element('.notification.notification-success', 1) - assert self.has_text('A confirmation email has been sent') + assert self.has_text('Check your inbox for a confirmation email.') diff --git a/www/on/npm/%package/index.html.spt b/www/on/npm/%package/index.html.spt index 5fa163ba7f..b97a787f9b 100644 --- a/www/on/npm/%package/index.html.spt +++ b/www/on/npm/%package/index.html.spt @@ -26,6 +26,15 @@ url = 'https://npmjs.com/package/' + package.name {% endblock %} +{% block scripts %} + +{{ super() }} +{% endblock %} + {% block content %}
{{ _('Is this yours? You can claim it on Gratipay with one of these email addresses:') }}
- + +