AVATAR_DEFAULT_URL can start with http:// if for some reason it's hosted on another domain

Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
Mathieu Pillard 2010-03-17 16:21:02 +01:00 committed by Jannis Leidel
parent 3be0c2ca01
commit 61879cee7e

View file

@ -8,6 +8,9 @@ def get_default_avatar_url():
base_url = getattr(settings, 'STATIC_URL', None)
if not base_url:
base_url = getattr(settings, 'MEDIA_URL', '')
# Don't use base_url if the default avatar url starts with http://
if AVATAR_DEFAULT_URL.startswith('http://'):
return AVATAR_DEFAULT_URL
# We'll be nice and make sure there are no duplicated forward slashes
ends = base_url.endswith('/')
begins = AVATAR_DEFAULT_URL.startswith('/')
@ -34,4 +37,4 @@ def get_primary_avatar(user, size=80):
if avatar:
if not avatar.thumbnail_exists(size):
avatar.create_thumbnail(size)
return avatar
return avatar