# HG changeset patch # User Marcin Kuzminski # Date 2012-12-08 18:09:12 # Node ID 39bbe5d31a54679623eb3c800b7b928fb7390f9d # Parent 8618b7811bf03eb201b69c6c6860e9c1bab101aa fixes issue #674, alternative gravatar url had an error when there was no valid email in commit data diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -749,7 +749,13 @@ HasRepoPermissionAny, HasRepoPermissionA #============================================================================== 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 @@ def gravatar_url(email_address, size=30) .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/"