diff options
author | Marcin Kuzminski <marcin@python-works.com> | 2013-01-21 23:14:43 +0100 |
---|---|---|
committer | Marcin Kuzminski <marcin@python-works.com> | 2013-01-21 23:14:43 +0100 |
commit | e3e1ee0efc10310b63ca64b60cda093425df1446 (patch) | |
tree | 966af15874ffc457afe57ca882e620d92124acbc /rhodecode/model/db.py | |
parent | c6bf09028ff3caf31a02030a86f63d6ac02e1eaa (diff) |
improved extraction of user from changeset when sending notification.
Fallback to repo owner if we cannot get the user
--HG--
branch : beta
extra : amend_source : d55aa77b41ea3e7b8e5cb8a3a267ca320a1cff1b
Diffstat (limited to 'rhodecode/model/db.py')
-rwxr-xr-x | rhodecode/model/db.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py index 7a2924e4..7a188f8f 100755 --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -454,6 +454,26 @@ class User(Base, BaseModel): return ret + @classmethod + def get_from_cs_author(cls, author): + """ + Tries to get User objects out of commit author string + + :param author: + """ + from rhodecode.lib.helpers import email, author_name + # Valid email in the attribute passed, see if they're in the system + _email = email(author) + if _email: + user = cls.get_by_email(_email, case_insensitive=True) + if user: + return user + # Maybe we can match by username? + _author = author_name(author) + user = cls.get_by_username(_author, case_insensitive=True) + if user: + return user + def update_lastlogin(self): """Update user lastlogin""" self.last_login = datetime.datetime.now() |