Le sigh. Use Gravatar's 404 default response to check for images, not profile requests.

master
Nick Sergeant 2013-04-15 00:10:05 -04:00
parent 58a83fee3f
commit 4c9cdfd0f2
2 changed files with 7 additions and 14 deletions

19
fabfile.py vendored
View File

@ -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

View File

@ -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: