From 4c9cdfd0f2564cf016a2e6b8da0f87b7e005ac3b Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Mon, 15 Apr 2013 00:10:05 -0400 Subject: [PATCH] Le sigh. Use Gravatar's 404 default response to check for images, not profile requests. --- fabfile.py | 19 ++++++------------- views.py | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/fabfile.py b/fabfile.py index ab324d6..9b44ffc 100644 --- a/fabfile.py +++ b/fabfile.py @@ -108,23 +108,16 @@ def gravatars(): print 'Email MD5: {}'.format(email_md5) - if user.profile.has_gravatar == False: - - greq = requests.get('http://en.gravatar.com/{}.json'.format(email_md5)) - - if greq.json() == 'User not found': - has_gravatar = False - else: - has_gravatar = True + greq = requests.get('https://secure.gravatar.com/avatar/{}?s=50&d=404'.format(email_md5)) + if greq.status_code == 404: + has_gravatar = False else: has_gravatar = True - print 'Already had Gravatar! Not checking again.' - if has_gravatar and not user.profile.has_gravatar: - profile = user.profile - profile.has_gravatar = True - profile.save() + profile = user.profile + profile.has_gravatar = has_gravatar + profile.save() try: from fabric.colors import green, red diff --git a/views.py b/views.py index ab197db..2a5d61c 100644 --- a/views.py +++ b/views.py @@ -18,7 +18,7 @@ from settings_local import STRIPE_SECRET_KEY @render_to('homepage.html') def homepage(request): - random_users = UserProfile.objects.filter(has_gravatar=True).order_by('?')[:100] + random_users = UserProfile.objects.filter(has_gravatar=True).order_by('?')[:50] coders = [] for random_user in random_users: