File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from django .conf import settings
6
6
from requests_oauthlib import OAuth1Session , OAuth2Session
7
+ from allauth .socialaccount .models import SocialAccount
7
8
8
9
from .models import GithubProject , GithubOrganization , BitbucketProject
9
10
from readthedocs .restapi .client import api
@@ -152,13 +153,17 @@ def import_bitbucket(user, sync):
152
153
""" Do the actual github import """
153
154
154
155
session = get_oauth_session (user , provider = 'bitbucket' )
156
+ try :
157
+ social_account = user .socialaccount_set .get (provider = 'bitbucket' )
158
+ except SocialAccount .DoesNotExist :
159
+ log .exception ('User tried to import from Bitbucket without a Social Account' )
155
160
if sync and session :
156
161
# Get user repos
157
162
try :
158
163
owner_resp = bitbucket_paginate (
159
164
session ,
160
165
'https://bitbucket.org/api/2.0/repositories/{owner}' .format (
161
- owner = user . username ))
166
+ owner = social_account . uid ))
162
167
process_bitbucket_json (user , owner_resp )
163
168
except TypeError , e :
164
169
print e
You can’t perform that action at this time.
0 commit comments