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

Thomas De Schampheleire patrickdepinguin at gmail.com
Tue Jun 23 15:59:58 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 20f661572d9e67ada5021a9a660f2bf4c9ad6920
# Parent  0bd7300d815257423acca7984472d207676008cb
user: fall back to username in full_name_and_username if no name set

Additionally, clarify both full_name_or_username and full_name_and_username
with docstrings.

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


More information about the kallithea-general mailing list