changeset 4380:5ebd887522ea

helpers: user email can be unset Check for not being empty, not for ''. Also, don't call person() with email, as it can't be caught properly.
author Andrew Shadura <andrew@shadura.me>
date Sun, 12 Jan 2014 17:30:00 +0100
parents f2014e4249a4
children 55f2f2b4c462
files kallithea/lib/helpers.py kallithea/model/comment.py kallithea/model/pull_request.py
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Fri Jul 18 19:22:01 2014 +0200
+++ b/kallithea/lib/helpers.py	Sun Jan 12 17:30:00 2014 +0100
@@ -478,7 +478,7 @@
 def email_or_none(author):
     # extract email from the commit string
     _email = email(author)
-    if _email != '':
+    if _email:
         # check it against Kallithea database, and use the MAIN email for this
         # user
         user = User.get_by_email(_email, case_insensitive=True, cache=True)
@@ -506,7 +506,7 @@
 
     # Valid email in the attribute passed, see if they're in the system
     _email = email(author)
-    if _email != '':
+    if _email:
         user = User.get_by_email(_email, case_insensitive=True, cache=True)
         if user is not None:
             return person_getter(user)
--- a/kallithea/model/comment.py	Fri Jul 18 19:22:01 2014 +0200
+++ b/kallithea/model/comment.py	Sun Jan 12 17:30:00 2014 +0100
@@ -105,7 +105,7 @@
             recipients += [cs_author]
             email_kwargs = {
                 'status_change': status_change,
-                'cs_comment_user': h.person(user.email),
+                'cs_comment_user': h.person(user),
                 'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name,
                                         qualified=True),
                 'cs_comment_url': _url,
@@ -147,7 +147,7 @@
                 'status_change': status_change,
                 'closing_pr': closing_pr,
                 'pr_comment_url': _url,
-                'pr_comment_user': h.person(user.email),
+                'pr_comment_user': h.person(user),
                 'pr_target_repo': h.url('summary_home',
                                    repo_name=pull_request.other_repo.repo_name,
                                    qualified=True)
--- a/kallithea/model/pull_request.py	Fri Jul 18 19:22:01 2014 +0200
+++ b/kallithea/model/pull_request.py	Sun Jan 12 17:30:00 2014 +0100
@@ -134,7 +134,7 @@
         body = pr.description
         kwargs = {
             'pr_title': pr.title,
-            'pr_user_created': h.person(pr.author.email),
+            'pr_user_created': h.person(pr.author),
             'pr_repo_url': h.url('summary_home', repo_name=pr.other_repo.repo_name,
                                  qualified=True,),
             'pr_url': pr_url,