Mercurial > kallithea
changeset 1767:468afe69f2a8 beta
garden
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 08 Dec 2011 01:47:11 +0200 |
parents | 6079061886fc |
children | 5610fd9b6803 |
files | rhodecode/lib/helpers.py |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Thu Dec 08 01:35:50 2011 +0200 +++ b/rhodecode/lib/helpers.py Thu Dec 08 01:47:11 2011 +0200 @@ -300,12 +300,13 @@ hide_credentials = lambda x: ''.join(credentials_filter(x)) -def email_or_none(x): - if email(x) != '': - return email(x) +def email_or_none(author): + _email = email(author) + if _email != '': + return _email # See if it contains a username we can get an email from - user = User.get_by_username(author_name(x), case_insensitive=True, + user = User.get_by_username(author_name(author), case_insensitive=True, cache=True) if user is not None: return user.email @@ -313,26 +314,27 @@ # No valid email, not a valid user in the system, none! return None -def person(x): - # Valid email in the attribute passed, see if they're in the system - +def person(author): # attr to return from fetched user person_getter = lambda usr: usr.username - - if email(x) != '': - user = User.get_by_email(email(x), case_insensitive=True, cache=True) + + # Valid email in the attribute passed, see if they're in the system + _email = email(author) + if _email != '': + user = User.get_by_email(_email, case_insensitive=True, cache=True) if user is not None: return person_getter(user) - return email(x) + return _email # Maybe it's a username? - user = User.get_by_username(author_name(x), case_insensitive=True, + _author = author_name(author) + user = User.get_by_username(_author, case_insensitive=True, cache=True) if user is not None: return person_getter(user) # Still nothing? Just pass back the author name then - return author_name(x) + return _author def bool2icon(value): """Returns True/False values represented as small html image of true/false