From patchwork Fri Sep 11 15:54:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A59B5140180 for ; Sat, 12 Sep 2015 01:58:03 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 8BDD01A2BCE for ; Sat, 12 Sep 2015 01:58:03 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id 556FC1A2BB9 for ; Sat, 12 Sep 2015 01:55:41 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Sep 2015 08:55:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559867004" Received: from jeffzhua-mobl.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.88.85]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2015 08:55:39 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 14/51] model: Split a user_name() helper out of UserProfile Date: Fri, 11 Sep 2015 16:54:47 +0100 Message-Id: <1441986924-26689-15-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> References: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: Damien Lespiau --- patchwork/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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)