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
refactor accounts elsewhere #1369
Merged
Merged
Changes from all commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
6270daa
Participant pages work for Google users.
lyndsysimon 783b56d
WIP - Abstracting into a more generic architecture
lyndsysimon 5e878ca
Merge branch 'master' into elsewhere
chadwhitacre 2b0a7c0
Post-merge get_accounts_elsewhere
chadwhitacre 657cca2
Clean up wireup as well
chadwhitacre 3393dd9
Move Google config out into wireup
chadwhitacre f2e93e0
Get old accounts elsewhere barely working TTW
chadwhitacre 642ae09
Modernize a db API call
chadwhitacre 06c4342
Rip out Google auth from elsewhere branch
chadwhitacre ffd7c13
Trim up some imports on elsewhere page
chadwhitacre 6356e13
Clean up elsewhere page some more
chadwhitacre 5ad02a9
Merge branch 'master' into elsewhere
chadwhitacre 237d40c
Here's a failing test for an Aspen upgrade issue
chadwhitacre 5190ee7
Fix an Aspen upgrade issue (UnicodeWithParams)
chadwhitacre efffad9
Merge branch 'master' into elsewhere
chadwhitacre 6760eae
Standardize nomenclature on "platform"
chadwhitacre 86c1f5a
Add a little whitespace
chadwhitacre 808a7cc
Add .spt extension to a couple files
chadwhitacre ca9c7f4
Rough-in of an elsewhere refactor refactor; #1369
chadwhitacre 1ec5522
Eager-load participant when querying elsewhere
chadwhitacre d1748ba
Fix the test for eager-loading participant
chadwhitacre b6f63cf
Note lack of type inheritance in Postgres
chadwhitacre d57bf6a
Tweak whitespace in branch.sql
chadwhitacre 323c9d2
Upgrade Postgres.py to 2.1.0
chadwhitacre f3ddfaf
Upgrade to postgres 2.1.1
chadwhitacre 319748d
Implement subclassing of AccountElsewhere
chadwhitacre 7dbd70b
Get Twitter page barely working TTW
chadwhitacre a891e82
Reimplement nbackers
chadwhitacre 4195442
Prune crufty nbackers computed property stub
chadwhitacre ed4dee6
Remove cruft from configure-aspen.py
chadwhitacre a7589c3
Rip out _resolve
chadwhitacre 1a74332
Start in on oauth for Twitter
chadwhitacre 6c8be36
Rename website.elsewhere to .platforms
chadwhitacre efbc39c
Start fixing up tests for Participant
chadwhitacre c45122e
test_participant passing
chadwhitacre a20bdd9
Fix test_utils
chadwhitacre c83c5af
Fix test_elsewhere_twitter
chadwhitacre f567c39
Bring fetch_* into line with get_account
chadwhitacre bdec63b
Fix naming regressions in elsewhere
chadwhitacre 9b1f5c1
Fix test_anonymous_json
chadwhitacre 0785af7
Toe the waters on test_associate
chadwhitacre 65be9f2
Fix test_twitter_proxy.
sim6 f8881e1
Fix login links.
sim6 99aa1ef
Fix about/me.html login links.
sim6 0f2733d
Change from "Bad request" to "Forbidden" of the expected result of te…
sim6 acec955
Add PlatformOAuth1 class a Platform class with support for OAuth1.
sim6 8ac08ff
Twitter login with OAuth1.
sim6 b494400
Add PlatformOAuth2 class a Platform class with support for OAuth2.
sim6 3072a2c
Github login with OAuth2.
sim6 1fad280
Adapt OAuth1 to Bitbucket.
sim6 6ded2be
Bitbucket login with OAuth1.
sim6 9f06418
Fix links to connect accounts.
sim6 51597fd
Fix action to connect accounts.
sim6 ffb6043
Fix links to connect accounts, again :(
sim6 dd22ea8
Fix TestPages.test_homepage_with_anonymous_giver.
sim6 9b529bf
Fix return values of OAuth posts of mocks in test_associate.py.
sim6 bd0042e
Fix TestAccountElsewhere.test_bitbucket_oauth_url_percent_encodes_then.
sim6 dbc1e4c
Fix TestAccountElsewhere.test_github_oauth_url_not_susceptible_to_inj…
sim6 95562a0
Fix TestAccountElsewhere.test_opt_in_can_change_username.
sim6 9f0dda2
Fix TestAccountElsewhere.test_twitter_oauth_url_percent_encodes_then.
sim6 fcfe65e
Merge branch 'master' into 'elsewhere'
Changaco dab9933
WIP
Changaco 0fecb5e
clean up imports
Changaco e0e2418
Merge branch 'master' into elsewhere
Changaco 23433d1
Switch travis to postgres 9.3.
zbynekwinkler 302bd0f
remove files mistakenly added in merge
Changaco 80b7ff2
re-add mistakenly removed import
Changaco 771d3a8
fix test
Changaco dbef80c
don't deal with duplicates
Changaco 11337ab
don't propagate email to participant
Changaco 58023fc
move avatar_url propagation from DB trigger to python code
Changaco 27f6f10
Merge branch 'master' into elsewhere
Changaco 5282ece
add tests and fix spotted bugs
Changaco 82ec96f
fix problems detected by pyflakes
Changaco ae6bfbd
fix bug found by whit537 while testing bitbucket auth
Changaco c045cfa
fix typo
Changaco 2ec047c
fix bitbucket auth
Changaco 447a97e
small optimization
Changaco e3697e4
don't set oauth2 scope by default
Changaco 50316da
don't show an opt-in button when platform isn't in signin_platforms
Changaco 92713b3
use the default image when avatar_url is empty
Changaco 6e11fe0
reorganize branch.sql
Changaco 0cf40ea
Merge branch 'master' into elsewhere
chadwhitacre 00046c9
set a default oauth scope for venmo
Changaco e532ea2
fix bad test condition that resulted in user_id being None
Changaco 5d11e95
make sure user_id is neither None nor an empty string
Changaco 675aba8
add some docstrings
Changaco 80bde4c
small HTML fix (<p> can't contain <form>)
Changaco a9b4d0b
create UserInfo class
Changaco 12ddf91
extract type (single or team) of elsewhere accounts
Changaco 665567e
add var name alias to fix included template sign-in-using-to-give.html
Changaco 64ed97f
replace parse_user_info() by api_parser()
Changaco d88302e
minor changes (move some code, add some comments)
Changaco 211e780
add support for API response pagination
Changaco c11b420
small CSS fix
Changaco 43bf21a
more informative exception
Changaco b4397af
create get_team_members() method
Changaco cf5feff
bring back display of elsewhere team members
Changaco 5b229e9
Merge branch 'master' into elsewhere
Changaco f64c1db
fix the definition of the declines_gifts variable
Changaco 9ff12a9
Squish regression on "Giving" page; #1369
chadwhitacre 9739c23
Merge branch 'master' into elsewhere
Changaco 627df0d
Start making buttons look like buttons again
chadwhitacre 46d520a
Tweak whitespace; #1369
chadwhitacre f23bab6
Obey pyflakes
chadwhitacre ff83659
Add comment about DEBUG=1 flag
chadwhitacre 6c0db7b
fix venmo's default scope and user info extraction
Changaco e80ff73
Fix bug in extraction of Venmo user_info; #1369
chadwhitacre 54a25af
Not sure how this ended up back in; #1369
chadwhitacre 5508641
fix bug in extraction of Venmo user_info, again
Changaco 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
language: python | ||
addons: | ||
postgresql: 9.3 | ||
before_install: | ||
- node --version | ||
install: make env node_modules | ||
|
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,142 @@ | ||
------------------------------------------------------------------------------- | ||
-- https://github.com/gittip/www.gittip.com/pull/1369 | ||
|
||
BEGIN; | ||
|
||
|
||
-- Add new columns | ||
|
||
-- Note: using "user_name" instead of "username" avoids having the same | ||
-- column name in the participants and elsewhere tables. | ||
ALTER TABLE elsewhere ADD COLUMN user_name text; | ||
ALTER TABLE elsewhere ADD COLUMN display_name text; | ||
ALTER TABLE elsewhere ADD COLUMN email text; | ||
ALTER TABLE elsewhere ADD COLUMN avatar_url text; | ||
ALTER TABLE participants ADD COLUMN avatar_url text; | ||
ALTER TABLE elsewhere ADD COLUMN is_team boolean NOT NULL DEFAULT FALSE; | ||
|
||
|
||
|
||
-- Extract info | ||
|
||
-- Extract user_name from user_info | ||
UPDATE elsewhere SET user_name = user_id WHERE platform = 'bitbucket'; | ||
UPDATE elsewhere SET user_name = user_info->'display_name' WHERE platform = 'bountysource'; | ||
UPDATE elsewhere SET user_name = user_info->'login' WHERE platform = 'github'; | ||
UPDATE elsewhere SET user_name = user_info->'username' WHERE platform = 'openstreetmap'; | ||
UPDATE elsewhere SET user_name = user_info->'screen_name' WHERE platform = 'twitter'; | ||
UPDATE elsewhere SET user_name = user_info->'username' WHERE platform = 'venmo'; | ||
|
||
-- Extract display_name from user_info | ||
UPDATE elsewhere SET display_name = user_info->'display_name' WHERE platform = 'bitbucket'; | ||
UPDATE elsewhere SET display_name = user_info->'name' WHERE platform = 'github'; | ||
UPDATE elsewhere SET display_name = user_info->'username' WHERE platform = 'openstreetmap'; | ||
UPDATE elsewhere SET display_name = user_info->'name' WHERE platform = 'twitter'; | ||
UPDATE elsewhere SET display_name = user_info->'display_name' WHERE platform = 'venmo'; | ||
UPDATE elsewhere SET display_name = NULL WHERE display_name = 'None'; | ||
|
||
-- Extract available email addresses | ||
UPDATE elsewhere SET email = user_info->'email' WHERE user_info->'email' LIKE '%@%'; | ||
|
||
-- Extract available avatar URLs | ||
UPDATE elsewhere SET avatar_url = concat('https://www.gravatar.com/avatar/', | ||
user_info->'gravatar_id') | ||
WHERE platform = 'github' | ||
AND user_info->'gravatar_id' != '' | ||
AND user_info->'gravatar_id' != 'None'; | ||
UPDATE elsewhere SET avatar_url = concat('https://www.gravatar.com/avatar/', | ||
md5(lower(trim(email)))) | ||
WHERE email IS NOT NULL AND avatar_url IS NULL; | ||
UPDATE elsewhere SET avatar_url = user_info->'avatar' WHERE platform = 'bitbucket'; | ||
UPDATE elsewhere SET avatar_url = user_info->'avatar_url' | ||
WHERE platform = 'bitbucket' AND avatar_url IS NULL; | ||
UPDATE elsewhere SET avatar_url = substring(user_info->'links', $$u'avatar': {u'href': u'([^']+)$$) | ||
WHERE platform = 'bitbucket' AND avatar_url IS NULL; | ||
UPDATE elsewhere SET avatar_url = user_info->'image_url' WHERE platform = 'bountysource'; | ||
UPDATE elsewhere SET avatar_url = user_info->'avatar_url' WHERE platform = 'github' AND avatar_url IS NULL; | ||
UPDATE elsewhere SET avatar_url = user_info->'img_src' WHERE platform = 'openstreetmap'; | ||
UPDATE elsewhere SET avatar_url = replace(user_info->'profile_image_url_https', '_normal.', '.') | ||
WHERE platform = 'twitter'; | ||
UPDATE elsewhere SET avatar_url = user_info->'profile_picture_url' WHERE platform = 'venmo'; | ||
UPDATE elsewhere SET avatar_url = NULL WHERE avatar_url = 'None'; | ||
-- Propagate avatar_url to participants | ||
UPDATE participants p | ||
SET avatar_url = ( | ||
SELECT avatar_url | ||
FROM elsewhere | ||
WHERE participant = p.username | ||
ORDER BY platform = 'github' DESC, | ||
avatar_url LIKE '%gravatar.com%' DESC | ||
LIMIT 1 | ||
); | ||
|
||
-- Extract is_team from user_info | ||
UPDATE elsewhere SET is_team = true WHERE platform = 'bitbucket' AND user_info->'is_team' = 'True'; | ||
UPDATE elsewhere SET is_team = true WHERE platform = 'github' AND lower(user_info->'type') = 'organization'; | ||
|
||
|
||
|
||
-- Drop old columns and add new ones | ||
|
||
-- Update user_name constraints | ||
ALTER TABLE elsewhere ALTER COLUMN user_name SET NOT NULL, | ||
ALTER COLUMN user_name DROP DEFAULT; | ||
|
||
-- Replace user_info by a new column of type json (instead of hstore) | ||
ALTER TABLE elsewhere DROP COLUMN user_info, | ||
ADD COLUMN extra_info json; | ||
DROP EXTENSION hstore; | ||
|
||
-- Simplify homepage_top_* tables | ||
ALTER TABLE homepage_top_givers DROP COLUMN gravatar_id, | ||
DROP COLUMN twitter_pic, | ||
ADD COLUMN avatar_url text; | ||
ALTER TABLE homepage_top_receivers DROP COLUMN claimed_time, | ||
DROP COLUMN gravatar_id, | ||
DROP COLUMN twitter_pic, | ||
ADD COLUMN avatar_url text; | ||
|
||
-- The following lets us cast queries to elsewhere_with_participant to get the | ||
-- participant data dereferenced and returned in a composite type along with | ||
-- the elsewhere data. Then we can register orm.Models in the application for | ||
-- both participant and elsewhere_with_participant, and when we cast queries | ||
-- elsewhere.*::elsewhere_with_participant, we'll get a hydrated Participant | ||
-- object at .participant. Woo-hoo! | ||
|
||
CREATE TYPE elsewhere_with_participant AS | ||
( id integer | ||
, platform text | ||
, user_id text | ||
, user_name text | ||
, display_name text | ||
, email text | ||
, avatar_url text | ||
, extra_info json | ||
, is_locked boolean | ||
, is_team boolean | ||
, participant participants | ||
); -- If Postgres had type inheritance this would be even awesomer. | ||
|
||
CREATE OR REPLACE FUNCTION load_participant_for_elsewhere (elsewhere) | ||
RETURNS elsewhere_with_participant | ||
AS $$ | ||
SELECT $1.id | ||
, $1.platform | ||
, $1.user_id | ||
, $1.user_name | ||
, $1.display_name | ||
, $1.email | ||
, $1.avatar_url | ||
, $1.extra_info | ||
, $1.is_locked | ||
, $1.is_team | ||
, participants.*::participants | ||
FROM participants | ||
WHERE participants.username = $1.participant | ||
; | ||
$$ LANGUAGE SQL; | ||
|
||
CREATE CAST (elsewhere AS elsewhere_with_participant) | ||
WITH FUNCTION load_participant_for_elsewhere(elsewhere); | ||
|
||
END; |
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
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
Oops, something went wrong.
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.
I suspect you're attempting to avoid confusion by not simply using
username
in theelsewhere
table, yes? Is there a stronger reason? I'd be inclined to call them bothusername
and trust the table name to differentiate them. Unless they actually conflict somehow?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.
After spending more time with this PR I actually don't care about this. We've got
user_id
anddisplay_name
and you're right that it can be nice to distinguish fromparticipants.username
. TBH when I'm working with theelsewhere
table in psql I often forget that I wantelsewhere.participants
instead ofelsewhere.username
. Actually having anelsewhere.username
would no doubt trip me up. :-)