models: fix bug in username() when first_name and last_name are not both defined
This commit is contained in:
parent
9a94816476
commit
af28eb63f3
|
@ -140,7 +140,9 @@ class Content(Model):
|
|||
def username(user):
|
||||
'''Return the full name of a user if it has one, the username otherwise.'''
|
||||
if user.first_name or user.last_name:
|
||||
return u'{last_name} {first_name}'.format(**user.__dict__)
|
||||
d = dict(last_name='', first_name='')
|
||||
d.update(user.__dict__)
|
||||
return u'{last_name} {first_name}'.format(**d)
|
||||
return user.username
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue