def avatar_url(user, size=80): """ get user's avatar url. if user=str show default avatar. """ if isinstance(user, User) and avatar_thumbnail_exists(user, size): return avatar_thumbnail_url(user, size) else: if AVATAR_GRAVATAR_BACKUP: params = {"s": str(size)} if AVATAR_GRAVATAR_DEFAULT: params["d"] = AVATAR_GRAVATAR_DEFAULT return "http://www.gravatar.com/avatar/%s/?%s" % (md5.md5(user.email).hexdigest(), urllib.urlencode(params)) else: return AVATAR_DEFAULT_URL
def avatar_url(user, size=80): """ get user's avatar url. if user=str show default avatar. """ if isinstance(user, User) and avatar_thumbnail_exists(user, size): return avatar_thumbnail_url(user, size) else: if AVATAR_GRAVATAR_BACKUP: params = {'s': str(size)} if AVATAR_GRAVATAR_DEFAULT: params['d'] = AVATAR_GRAVATAR_DEFAULT return "http://www.gravatar.com/avatar/%s/?%s" % (md5_constructor( user.email).hexdigest(), urllib.urlencode(params)) else: return AVATAR_DEFAULT_URL
def avatar_url(user, size=80): """ get user's avatar url. if user=str show default avatar. """ if isinstance(user, User) and avatar_thumbnail_exists(user, size): return avatar_thumbnail_url(user, size) else: if AVATAR_GRAVATAR_BACKUP: params = {'s': str(size)} if AVATAR_GRAVATAR_DEFAULT: params['d'] = AVATAR_GRAVATAR_DEFAULT return "/static/avatars/default.gif"# % ( #md5_constructor(user.email).hexdigest(), #urllib.urlencode(params)) else: return AVATAR_DEFAULT_URL
def avatar_url(user, size=80): """ get user's avatar url. if user=str show default avatar. """ if isinstance(user, django.contrib.auth.get_user_model()) and avatar_thumbnail_exists(user, size): return avatar_thumbnail_url(user, size) else: if AVATAR_GRAVATAR_BACKUP: params = {'s': str(size)} if AVATAR_GRAVATAR_DEFAULT: params['d'] = AVATAR_GRAVATAR_DEFAULT return "http://www.gravatar.com/avatar/%s/?%s" % ( hashlib.md5(user.email).hexdigest(), urllib.urlencode(params)) else: return AVATAR_DEFAULT_URL