Le sigh. Use Gravatar's 404 default response to check for images, not profile requests.
parent
58a83fee3f
commit
4c9cdfd0f2
|
@ -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
|
||||
|
|
2
views.py
2
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:
|
||||
|
|
Loading…
Reference in New Issue