Changeset - 716194520cc0
[Not reviewed]
default
0 6 0
Mads Kiilerich - 11 years ago 2015-01-06 00:54:36
madski@unity3d.com
user: use h.person(obj.user) instead of h.person(obj.user.username) - don't fail if user is None

h.person prefer a user object anyway - just pass it obj.user and make sure
h.person doesn't crash on getting a None user.
6 files changed with 13 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/repo_groups.py
Show inline comments
 
@@ -146,7 +146,7 @@ class RepoGroupsController(BaseControlle
 
                "group_name": repo_group_name(repo_gr.group_name, children_groups),
 
                "desc": repo_gr.group_description,
 
                "repos": repo_count,
 
                "owner": h.person(repo_gr.user.username),
 
                "owner": h.person(repo_gr.user),
 
                "action": repo_group_actions(repo_gr.group_id, repo_gr.group_name,
 
                                             repo_count)
 
            })
kallithea/lib/helpers.py
Show inline comments
 
@@ -519,6 +519,8 @@ def email_or_none(author):
 

	
 

	
 
def person(author, show_attr="username"):
 
    """Find the user identified by 'author', return one of the users attributes,
 
    default to the username attribute, None if there is no user"""
 
    # attr to return from fetched user
 
    person_getter = lambda usr: getattr(usr, show_attr)
 

	
kallithea/lib/vcs/utils/__init__.py
Show inline comments
 
@@ -158,6 +158,8 @@ def author_email(author):
 

	
 
    Regex taken from http://www.regular-expressions.info/email.html
 
    """
 
    if not author:
 
        return ''
 
    import re
 
    r = author.find('>')
 
    l = author.find('<')
 
@@ -180,9 +182,9 @@ def author_name(author):
 
    It'll try to find an email in the author string and just cut it off
 
    to get the username
 
    """
 

	
 
    if not author:
 
        return ''
 
    if not '@' in author:
 
        return author
 
    else:
 
        return author.replace(author_email(author), '').replace('<', '')\
 
            .replace('>', '').strip()
 
    return author.replace(author_email(author), '').replace('<', '')\
 
        .replace('>', '').strip()
kallithea/model/repo.py
Show inline comments
 
@@ -241,7 +241,7 @@ class RepoModel(BaseModel):
 
                "last_changeset": last_rev(repo.repo_name, cs_cache),
 
                "last_rev_raw": cs_cache.get('revision'),
 
                "desc": desc(repo.description),
 
                "owner": h.person(repo.user.username),
 
                "owner": h.person(repo.user),
 
                "state": state(repo.repo_state),
 
                "rss": rss_lnk(repo.repo_name),
 
                "atom": atom_lnk(repo.repo_name),
 
@@ -251,7 +251,7 @@ class RepoModel(BaseModel):
 
                row.update({
 
                    "action": repo_actions(repo.repo_name),
 
                    "owner": owner_actions(repo.user.user_id,
 
                                           h.person(repo.user.username))
 
                                           h.person(repo.user))
 
                })
 
            repos_data.append(row)
 

	
kallithea/templates/admin/repo_groups/repo_group_edit_advanced.html
Show inline comments
 
@@ -7,7 +7,7 @@
 
    (_('Total repositories'), c.repo_group.repositories_recursive_count, ''),
 
    (_('Children groups'), c.repo_group.children.count(), ''),
 
    (_('Created on'), h.fmt_date(c.repo_group.created_on), ''),
 
    (_('Owner'), h.person(c.repo_group.user.username), '')
 
    (_('Owner'), h.person(c.repo_group.user), '')
 
 ]
 
%>
 
%for dt, dd, tt in elems:
kallithea/templates/admin/user_groups/user_group_edit_advanced.html
Show inline comments
 
@@ -5,7 +5,7 @@
 
 elems = [
 
    (_('Members'), len(c.group_members_obj), ''),
 
    (_('Created on'), h.fmt_date(c.user_group.created_on), ''),
 
    (_('Owner'), h.person(c.user_group.user.username), '')
 
    (_('Owner'), h.person(c.user_group.user), '')
 
    ]
 
%>
 
%for dt, dd, tt in elems:
0 comments (0 inline, 0 general)