diff mbox

[14/51] model: Split a user_name() helper out of UserProfile

Message ID 1441986924-26689-15-git-send-email-damien.lespiau@intel.com
State Superseded
Headers show

Commit Message

Damien Lespiau Sept. 11, 2015, 3:54 p.m. UTC
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 patchwork/models.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/patchwork/models.py b/patchwork/models.py
index 742a08d..1990989 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -78,6 +78,11 @@  class Project(models.Model):
     class Meta:
         ordering = ['linkname']
 
+def user_name(user):
+    if user.first_name or user.last_name:
+        names = filter(bool, [user.first_name, user.last_name])
+        return u' '.join(names)
+    return user.username
 
 class UserProfile(models.Model):
     user = models.OneToOneField(User, unique = True, related_name='profile')
@@ -92,10 +97,7 @@  class UserProfile(models.Model):
             help_text = 'Number of patches to display per page')
 
     def name(self):
-        if self.user.first_name or self.user.last_name:
-            names = filter(bool, [self.user.first_name, self.user.last_name])
-            return u' '.join(names)
-        return self.user.username
+        return user_name(self.user)
 
     def contributor_projects(self):
         submitters = Person.objects.filter(user = self.user)