docbow: username should return user.username when first_name and last_name are both empty

fix bug introduced in f25be11
This commit is contained in:
Benjamin Dauvergne 2013-11-15 12:02:55 +01:00
parent f25be1102f
commit c884fb8dc8
2 changed files with 5 additions and 2 deletions

View File

@ -139,8 +139,9 @@ class Content(Model):
def username(user):
'''Return the full name of a user if it has one, the username otherwise.'''
full_name = u'{last_name} {first_name}'.format(**user.__dict__)
return full_name or user.username
if user.first_name or user.last_name:
return u'{last_name} {first_name}'.format(**user.__dict__)
return user.username
def all_emails(user):

View File

@ -137,6 +137,8 @@ class UtilsTestCase(BaseTestCase):
list(models.Document.objects.all())
def test_document_accessors(self):
import pdb
pdb.set_trace()
document = self.documents[0]
self.assertEqual(document.filenames(),
'file0.pdf, file1.pdf')