diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/blog/models.py | 11 | ||||
-rw-r--r-- | app/lib/templatetags/templatetags/gravatar_local.py | 9 |
2 files changed, 8 insertions, 12 deletions
diff --git a/app/blog/models.py b/app/blog/models.py index 1b828fe..afa7158 100644 --- a/app/blog/models.py +++ b/app/blog/models.py @@ -221,14 +221,3 @@ def cache_gravatar(sender, comment, **kwargs): os.makedirs(grav_dir) local_grav = '%s/%s.jpg' % (grav_dir, calculate_gravatar_hash(comment.email)) urllib.request.urlretrieve(url, local_grav) - else: - dest = '%s/%s.jpg' % (grav_dir, calculate_gravatar_hash(comment.email)) - src = settings.IMAGES_ROOT + '/gravcache/default.jpg' - try: - shutil.copy(src, dest) - # eg. src and dest are the same file - except shutil.Error as e: - print('Error: %s' % e) - # eg. source or destination doesn't exist - except IOError as e: - print('Error: %s' % e.strerror) diff --git a/app/lib/templatetags/templatetags/gravatar_local.py b/app/lib/templatetags/templatetags/gravatar_local.py index 985ed03..5ed9a7f 100644 --- a/app/lib/templatetags/templatetags/gravatar_local.py +++ b/app/lib/templatetags/templatetags/gravatar_local.py @@ -1,7 +1,7 @@ from django import template from django.utils.html import escape -from django_gravatar.helpers import calculate_gravatar_hash +from django_gravatar.helpers import calculate_gravatar_hash, has_gravatar # Get template.Library instance register = template.Library() @@ -17,4 +17,11 @@ def gravatar_hash(user_or_email): except: return '' +@register.filter +def has_grav(email): + if has_gravatar(email): + return True + else: + return False + register.simple_tag(gravatar_hash) |