Browse files

Merge pull request #450 from Sancus/gravatarfix

[Fix Bug 854950] Fix gravatar urls
  • Loading branch information...
2 parents 28e67a3 + e059cff commit c6ed18f9e5245e4c38aa9aa559c81f18ad71b5c3 @Sancus Sancus committed Apr 5, 2013
Showing with 7 additions and 3 deletions.
  1. +1 −1 apps/common/helpers.py
  2. +1 −1 apps/users/models.py
  3. +5 −1 settings/default.py
View
2 apps/common/helpers.py
@@ -14,7 +14,7 @@
absolutify = register.function(absolutify)
-def gravatar(email, default=settings.DEFAULT_AVATAR, size=175, rating='pg'):
+def gravatar(email, default=settings.DEFAULT_AVATAR_URL, size=175, rating='pg'):
"""Return the Gravatar URL for an email address."""
return 'http://www.gravatar.com/avatar/%s?%s' % (
View
2 apps/users/models.py
@@ -457,7 +457,7 @@ def get_photo_thumbnail(self, geometry='160x160', **kwargs):
kwargs['crop'] = 'center'
if self.photo:
return get_thumbnail(self.photo, geometry, **kwargs)
- return get_thumbnail(settings.DEFAULT_AVATAR, geometry, **kwargs)
+ return get_thumbnail(settings.DEFAULT_AVATAR_PATH, geometry, **kwargs)
def get_photo_url(self, geometry='160x160', **kwargs):
"""Return photo url.
View
6 settings/default.py
@@ -8,6 +8,7 @@
from funfactory.manage import path
from funfactory import settings_base as base
from settings import MEDIA_URL, MEDIA_ROOT
+from urlparse import urljoin
from apps.users.helpers import calculate_username
from django.utils.functional import lazy
@@ -288,4 +289,7 @@ def _allowed_hosts():
'^/browserid/verify/',
'^/api']
-DEFAULT_AVATAR = os.path.join(MEDIA_ROOT, 'img/unknown.png')
+# Set default avatar for user profiles
+DEFAULT_AVATAR= 'img/unknown.png'
+DEFAULT_AVATAR_URL = urljoin(MEDIA_URL, DEFAULT_AVATAR)
+DEFAULT_AVATAR_PATH = os.path.join(MEDIA_ROOT, DEFAULT_AVATAR)

0 comments on commit c6ed18f

Please sign in to comment.