[PATCH 17 of 19] user: fall back to username in full_name_and_username if no name set

Thomas De Schampheleire patrickdepinguin at gmail.com
Tue Jun 30 16:43:27 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1435084091 -7200
#      Tue Jun 23 20:28:11 2015 +0200
# Node ID 678e992671c1591c2a0afd4e181aa36909401654
# Parent  c30928f2b0243029ebc3d14063da33a6f1d1313f
user: fall back to username in full_name_and_username if no name set

diff --git a/kallithea/model/db.py b/kallithea/model/db.py
--- a/kallithea/model/db.py
+++ b/kallithea/model/db.py
@@ -488,8 +488,10 @@ class User(Base, BaseModel):
     def full_name_and_username(self):
         """
         Show full name and username as 'Firstname Lastname (username)'.
+        If full name is not set, fall back to username.
         """
-        return '%s %s (%s)' % (self.firstname, self.lastname, self.username)
+        return ('%s %s (%s)' % (self.firstname, self.lastname, self.username)
+                if (self.firstname and self.lastname) else self.username)
 
     @property
     def full_contact(self):


More information about the kallithea-general mailing list