Commit caad7cd7d1cc613841e181a6595d8a0d14a5c7a8
1 parent
03fd3b9f
Exists in
master
and in
39 other branches
Fixing migration to get facebook from get qs
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
src/accounts/migrations/0005_remove_host_from_social_accounts.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | import datetime |
3 | +import urlparse | |
3 | 4 | from south.db import db |
4 | 5 | from south.v2 import DataMigration |
5 | 6 | from django.db import models |
... | ... | @@ -11,7 +12,13 @@ class Migration(DataMigration): |
11 | 12 | if user.twitter: |
12 | 13 | user.twitter = user.twitter.split('/')[-1] |
13 | 14 | if user.facebook: |
14 | - user.facebook = user.facebook.split('/')[-1] | |
15 | + if '?' in user.facebook: | |
16 | + query_string = user.facebook.split('?')[-1] | |
17 | + query_dict = dict(urlparse.parse_qsl(query_string)) | |
18 | + user.facebook = query_dict.get('id') | |
19 | + else: | |
20 | + user.facebook = user.facebook.split('/')[-1] | |
21 | + | |
15 | 22 | user.save() |
16 | 23 | |
17 | 24 | def backwards(self, orm): | ... | ... |