Changeset - 5ebd887522ea
[Not reviewed]
default
0 3 0
Andrew Shadura - 12 years ago 2014-01-12 17:30:00
andrew@shadura.me
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.
3 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -475,13 +475,13 @@ def is_hg(repository):
 
    return _type == 'hg'
 

	
 

	
 
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)
 
        if user is not None:
 
            return user.email
 
        return _email
 
@@ -503,13 +503,13 @@ def person(author, show_attr="username")
 
    # if author is already an instance use it for extraction
 
    if isinstance(author, User):
 
        return person_getter(author)
 

	
 
    # 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)
 

	
 
    # Maybe it's a username?
 
    _author = author_name(author)
kallithea/model/comment.py
Show inline comments
 
@@ -102,13 +102,13 @@ class ChangesetCommentsModel(BaseModel):
 
            if not cs_author:
 
                #use repo owner if we cannot extract the author correctly
 
                cs_author = repo.user
 
            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,
 
                'raw_id': revision,
 
                'message': cs.message
 
            }
 
@@ -144,13 +144,13 @@ class ChangesetCommentsModel(BaseModel):
 
            email_kwargs = {
 
                'pr_title': pull_request.title,
 
                'pr_id': pull_request.pull_request_id,
 
                '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)
 
            }
 

	
 
        return subj, body, recipients, notification_type, email_kwargs, email_subject
kallithea/model/pull_request.py
Show inline comments
 
@@ -131,13 +131,13 @@ class PullRequestModel(BaseModel):
 
                 'pr_id': pr.pull_request_id},
 
                pr_url)
 
            )
 
        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,
 
            'pr_revisions': revision_data}
 

	
 
        NotificationModel().create(created_by=pr.author, subject=subject, body=body,
0 comments (0 inline, 0 general)