From 83cb9403363879d18ef4a9a93e817aa4e6706b29 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 27 Nov 2013 11:05:36 -0500 Subject: [PATCH 1/4] Here's a failing test for #1672 --- tests/test_elsewhere_bountysource.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_elsewhere_bountysource.py diff --git a/tests/test_elsewhere_bountysource.py b/tests/test_elsewhere_bountysource.py new file mode 100644 index 0000000000..92f3edd270 --- /dev/null +++ b/tests/test_elsewhere_bountysource.py @@ -0,0 +1,12 @@ +from __future__ import absolute_import, division, print_function, unicode_literals + +from gittip.testing import Harness +from gittip.testing.client import TestClient + + +class Tests(Harness): + + def test_redirect_redirects(self): + self.make_participant('alice') + actual = TestClient().get('/on/bountysource/redirect', user='alice').code + assert actual == 302 From a904b94f70a38a885ee8499fa9ed7173ab339ac2 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 27 Nov 2013 11:06:25 -0500 Subject: [PATCH 2/4] Fix regression in Bountysource connection; #1672 --- gittip/elsewhere/bountysource.py | 4 +++- www/on/bountysource/redirect.spt | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gittip/elsewhere/bountysource.py b/gittip/elsewhere/bountysource.py index 2da88a591a..272dc50422 100644 --- a/gittip/elsewhere/bountysource.py +++ b/gittip/elsewhere/bountysource.py @@ -5,11 +5,13 @@ from gittip.elsewhere import AccountElsewhere, _resolve +www_host = 'https://www.bountysource.com' + class BountysourceAccount(AccountElsewhere): platform = u'bountysource' def get_url(self): - url = "https://www.bountysource.com/#users/%s" % self.user_info["slug"] + url = "{}/#users/{}".format(www_host, self.user_info["slug"]) return url diff --git a/www/on/bountysource/redirect.spt b/www/on/bountysource/redirect.spt index 32933f4471..7562f12a1d 100644 --- a/www/on/bountysource/redirect.spt +++ b/www/on/bountysource/redirect.spt @@ -80,9 +80,9 @@ for account in user.participant.get_accounts_elsewhere(): connect_params['last_name'] = account.user_info.get('last_name') # build redirect URL to Bountysource from collected data -auth_url = "%s#auth/gittip/confirm?%s" % ( bountysource.www_host - , urlencode(connect_params) - ) +auth_url = "{}/#auth/gittip/confirm?{}".format( bountysource.www_host + , urlencode(connect_params) + ) log("Redirect to Bountysource for authorization: %s" % connect_params) request.redirect(auth_url) From b7387dc86da68e08fbe7fe2f232b9aeb76662e22 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 27 Nov 2013 13:34:00 -0500 Subject: [PATCH 3/4] Rip out problematic, unused nice-to-have; #1020 --- www/on/bountysource/redirect.spt | 58 -------------------------------- 1 file changed, 58 deletions(-) diff --git a/www/on/bountysource/redirect.spt b/www/on/bountysource/redirect.spt index 7562f12a1d..e1eb8f20cd 100644 --- a/www/on/bountysource/redirect.spt +++ b/www/on/bountysource/redirect.spt @@ -21,64 +21,6 @@ connect_params = { 'login': user.participant.username } - -# Collect extra params from accounts elsewhere. -# ============================================= -# The following attributes will be added to connect_params from linked accounts -# if present: email, first_name, last_name, avatar_url. These are used to -# prefill the account creation screen on Bountysource. - -for account in user.participant.get_accounts_elsewhere(): - # Note: returns None for accounts that haven't been linked yet - if account is None: - continue - - # from Github - if account.platform == 'github': - # split single name string into parts - name_parts = re.split('\s+', account.user_info.get('name', '').strip()) - - if not connect_params.get('login'): - connect_params['login'] = account.user_info.get('login') - if not connect_params.get('email'): - connect_params['email'] = account.user_info.get('email') - if not connect_params.get('avatar_url'): - connect_params['avatar_url'] = account.user_info.get('avatar_url') - if not connect_params.get('first_name'): - if len(name_parts) >= 1: - connect_params['first_name'] = name_parts[0] - if not connect_params.get('last_name'): - if len(name_parts) >= 2: - connect_params['last_name'] = name_parts[-1] - - # from Twitter - if account.platform == 'twitter': - # split single name string into parts - name_parts = re.split('/s+', account.user_info.get('name').strip()) - - if not connect_params.get('login'): - connect_params['login'] = account.user_info.get('screen_name') - if not connect_params.get('avatar_url'): - connect_params['avatar_url'] = \ - account.user_info.get('profile_image_url_https') - if not connect_params.get('first_name'): - if name_parts: - connect_params['first_name'] = name_parts[0] - if not connect_params.get('last_name'): - if len(name_parts) >= 2: - connect_params['last_name'] = name_parts[-1] - - # from Bitbucket - if account.platform == 'bitbucket': - if not connect_params.get('login'): - connect_params['login'] = account.user_info.get('username') - if not connect_params.get('avatar_url'): - connect_params['avatar_url'] = account.user_info.get('avatar') - if not connect_params.get('first_name'): - connect_params['first_name'] = account.user_info.get('first_name') - if not connect_params.get('last_name'): - connect_params['last_name'] = account.user_info.get('last_name') - # build redirect URL to Bountysource from collected data auth_url = "{}/#auth/gittip/confirm?{}".format( bountysource.www_host , urlencode(connect_params) From 243096d6cb0ef8c59dc3a9210a90a9ddeebf24c7 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 27 Nov 2013 14:11:42 -0500 Subject: [PATCH 4/4] Use BOUNTYSOURCE_WWW_HOST from the environment --- default_local.env | 4 ++-- default_tests.env | 4 ++-- gittip/elsewhere/bountysource.py | 9 +++++---- www/on/bountysource/redirect.spt | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/default_local.env b/default_local.env index 9e44aa6f62..ef090bf4b6 100644 --- a/default_local.env +++ b/default_local.env @@ -26,8 +26,8 @@ NANSWERS_THRESHOLD=2 NMEMBERS_THRESHOLD=50 UPDATE_HOMEPAGE_EVERY=10 BOUNTYSOURCE_API_SECRET=e2BbqjNY60kC7V-Uq1dv2oHgGavbWm9pUJmiRHCApFZHDiY9aZyAspInhZaZ94x9 -BOUNTYSOURCE_API_HOST=https://api-qa.bountysource.com/ -BOUNTYSOURCE_WWW_HOST=https://www-qa.bountysource.com/ +BOUNTYSOURCE_API_HOST=https://staging-qa.bountysource.com +BOUNTYSOURCE_WWW_HOST=https://staging.bountysource.com BOUNTYSOURCE_CALLBACK=http://127.0.0.1:8537/on/bountysource/associate GOOGLE_ANALYTICS_ID= GAUGES_ID= diff --git a/default_tests.env b/default_tests.env index 977bc0c656..3f3d6fc87b 100644 --- a/default_tests.env +++ b/default_tests.env @@ -26,8 +26,8 @@ NANSWERS_THRESHOLD=2 NMEMBERS_THRESHOLD=50 UPDATE_HOMEPAGE_EVERY=10 BOUNTYSOURCE_API_SECRET=e2BbqjNY60kC7V-Uq1dv2oHgGavbWm9pUJmiRHCApFZHDiY9aZyAspInhZaZ94x9 -BOUNTYSOURCE_API_HOST=https://api-qa.bountysource.com/ -BOUNTYSOURCE_WWW_HOST=https://www-qa.bountysource.com/ +BOUNTYSOURCE_API_HOST=https://staging-qa.bountysource.com +BOUNTYSOURCE_WWW_HOST=https://staging.bountysource.com BOUNTYSOURCE_CALLBACK=http://127.0.0.1:8537/on/bountysource/associate GOOGLE_ANALYTICS_ID= GAUGES_ID= diff --git a/gittip/elsewhere/bountysource.py b/gittip/elsewhere/bountysource.py index 272dc50422..6449007902 100644 --- a/gittip/elsewhere/bountysource.py +++ b/gittip/elsewhere/bountysource.py @@ -5,14 +5,15 @@ from gittip.elsewhere import AccountElsewhere, _resolve -www_host = 'https://www.bountysource.com' - class BountysourceAccount(AccountElsewhere): platform = u'bountysource' def get_url(self): - url = "{}/#users/{}".format(www_host, self.user_info["slug"]) - return url + + # I don't see that we actually use this. Leaving as a stub pending + # https://github.com/gittip/www.gittip.com/pull/1369. + + raise NotImplementedError def resolve(login): diff --git a/www/on/bountysource/redirect.spt b/www/on/bountysource/redirect.spt index e1eb8f20cd..fd758723ee 100644 --- a/www/on/bountysource/redirect.spt +++ b/www/on/bountysource/redirect.spt @@ -22,9 +22,9 @@ connect_params = { } # build redirect URL to Bountysource from collected data -auth_url = "{}/#auth/gittip/confirm?{}".format( bountysource.www_host - , urlencode(connect_params) - ) +auth_url = "{}/auth/gittip/confirm?{}".format( website.bountysource_www_host + , urlencode(connect_params) + ) log("Redirect to Bountysource for authorization: %s" % connect_params) request.redirect(auth_url)