diff --git a/app/lib/utils.py b/app/lib/utils.py index 3498c10..45799c2 100644 --- a/app/lib/utils.py +++ b/app/lib/utils.py @@ -3,6 +3,8 @@ import sys import json import requests import urlparse +import hashlib + from app import app from distutils.version import StrictVersion @@ -145,3 +147,7 @@ def pdns_api_extended_uri(version): return "/api/v1" else: return "" + +def email_to_gravatar_url(email, size=100): + hash_string = hashlib.md5(email).hexdigest() + return "https://s.gravatar.com/avatar/%s?s=%s" % (hash_string, size) diff --git a/app/templates/base.html b/app/templates/base.html index fd25cc7..06f239b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -65,7 +65,7 @@ {% if current_user.avatar %} {% else %} - + {% endif %} {{ current_user.firstname }} @@ -76,7 +76,7 @@ {% if current_user.avatar %} {% else %} - + {% endif %} {{ current_user.firstname }} {{ current_user.lastname }} @@ -111,7 +111,7 @@ {% if current_user.avatar %} {% else %} - + {% endif %} diff --git a/app/templates/user_profile.html b/app/templates/user_profile.html index b69d227..19201dc 100644 --- a/app/templates/user_profile.html +++ b/app/templates/user_profile.html @@ -67,7 +67,7 @@ src="{{ url_for('user_avatar', filename=current_user.avatar) }}" alt="" / style="width: 200px; height: 200px;"> {% else %} {% endif %} diff --git a/app/views.py b/app/views.py index 8675e3e..75eb3b4 100644 --- a/app/views.py +++ b/app/views.py @@ -22,6 +22,7 @@ from optparse import Values jinja2.filters.FILTERS['display_record_name'] = utils.display_record_name jinja2.filters.FILTERS['display_master_name'] = utils.display_master_name jinja2.filters.FILTERS['display_second_to_time'] = utils.display_time +jinja2.filters.FILTERS['email_to_gravatar_url'] = utils.email_to_gravatar_url # Flag for pdns v4.x.x # TODO: Find another way to do this @@ -68,6 +69,7 @@ def before_request(): g.user = current_user login_manager.anonymous_user = Anonymous + @login_manager.user_loader def load_user(id): """
{{ current_user.firstname }} {{ current_user.lastname }} @@ -111,7 +111,7 @@ {% if current_user.avatar %} {% else %} - + {% endif %}