🚨 format python code using black
This commit is contained in:
1 parent
9c4a5b3d84
commit
a052397990
24 files changed
+643
-407
No files matched your search
@@ -1,4 +1,4 @@
|
||||
xfrom django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
import difflib
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
@@ -13,16 +13,17 @@ class Command(BaseCommand):
|
||||
- Matches names against the local DB
|
||||
- Saves the users Facebook picture in his/her user profile.
|
||||
"""
|
||||
KAK_GROUP_ID = '108265352570560'
|
||||
|
||||
KAK_GROUP_ID = "108265352570560"
|
||||
graph = None
|
||||
|
||||
def get_kak_members(self):
|
||||
members = self.graph.get_connections(id=self.KAK_GROUP_ID, connection_name='members')
|
||||
return [(member['name'], member['id']) for member in members['data']]
|
||||
members = self.graph.get_connections(id=self.KAK_GROUP_ID, connection_name="members")
|
||||
return [(member["name"], member["id"]) for member in members["data"]]
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if len(args) != 1:
|
||||
raise CommandError('Missing access token')
|
||||
raise CommandError("Missing access token")
|
||||
|
||||
access_token = args[0]
|
||||
self.graph = facebook.GraphAPI(access_token=access_token)
|
||||
@@ -31,8 +32,8 @@ class Command(BaseCommand):
|
||||
|
||||
names = [] # to fuzzy search for a name
|
||||
name_lookup = {} # to update the matching UserProfile object
|
||||
for u in User.objects.all().order_by('id'):
|
||||
fullname = u'{} {}'.format(u.first_name, u.last_name)
|
||||
for u in User.objects.all().order_by("id"):
|
||||
fullname = "{} {}".format(u.first_name, u.last_name)
|
||||
names.append(fullname)
|
||||
name_lookup[fullname] = u.id
|
||||
|
||||
@@ -41,6 +42,5 @@ class Command(BaseCommand):
|
||||
if match:
|
||||
u = UserProfile.objects.get(pk=name_lookup[match[0]])
|
||||
if str(u.image) is "":
|
||||
u.image = 'https://graph.facebook.com/{0}/picture'.format(member[1])
|
||||
u.image = "https://graph.facebook.com/{0}/picture".format(member[1])
|
||||
u.save()
|
||||
|
||||
Reference in new issue
Block a user