# HG changeset patch # User Marcin Kuzminski # Date 2013-02-12 22:15:55 # Node ID 2cd0c8251aa2c0491fd8fd70e9d042fb67ece0e8 # Parent bbd72d82060a08805e23e5edb6c43086423be562 #763 gravatar helper function should fallback into default image if somehow email provided is empty. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -750,14 +750,14 @@ HasRepoPermissionAny, HasRepoPermissionA def gravatar_url(email_address, size=30): 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'): + _def = 'anonymous@rhodecode.org' + use_gravatar = str2bool(config['app_conf'].get('use_gravatar')) + email_address = email_address or _def + if (not use_gravatar or not email_address or email_address == _def): 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')): + if use_gravatar and config['app_conf'].get('alternative_gravatar_url'): tmpl = config['app_conf'].get('alternative_gravatar_url', '') parsed_url = urlparse.urlparse(url.current(qualified=True)) tmpl = tmpl.replace('{email}', email_address)\