changeset 3080:39bbe5d31a54 beta

fixes issue #674, alternative gravatar url had an error when there was no valid email in commit data
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 08 Dec 2012 19:09:12 +0100
parents 8618b7811bf0
children b2c7f7c5ce11
files rhodecode/lib/helpers.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py	Sat Dec 08 14:57:13 2012 +0100
+++ b/rhodecode/lib/helpers.py	Sat Dec 08 19:09:12 2012 +0100
@@ -749,7 +749,13 @@
 #==============================================================================
 
 def gravatar_url(email_address, size=30):
-    from pylons import url  ## doh, we need to re-import url to mock it later
+    from pylons import url  # doh, we need to re-import url to mock it later
+
+    if (not str2bool(config['app_conf'].get('use_gravatar')) or
+        not email_address or email_address == 'anonymous@rhodecode.org'):
+        f = lambda a, l: min(l, key=lambda x: abs(x - a))
+        return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
+
     if(str2bool(config['app_conf'].get('use_gravatar')) and
        config['app_conf'].get('alternative_gravatar_url')):
         tmpl = config['app_conf'].get('alternative_gravatar_url', '')
@@ -761,11 +767,6 @@
                    .replace('{size}', str(size))
         return tmpl
 
-    if (not str2bool(config['app_conf'].get('use_gravatar')) or
-        not email_address or email_address == 'anonymous@rhodecode.org'):
-        f = lambda a, l: min(l, key=lambda x: abs(x - a))
-        return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
-
     ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
     default = 'identicon'
     baseurl_nossl = "http://www.gravatar.com/avatar/"