From patchwork Fri Sep 11 15:54:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EBED1140180 for ; Sat, 12 Sep 2015 01:57:54 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id D0F201A0795 for ; Sat, 12 Sep 2015 01:57:54 +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 5CFC61A2BCE 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:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559867015" 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:40 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 15/51] models: Monkey patch User to have a name() method Date: Fri, 11 Sep 2015 16:54:48 +0100 Message-Id: <1441986924-26689-16-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" The name is really a poperty of the User. Not always having to retrieve the profile for that makes things simpler. Signed-off-by: Damien Lespiau --- patchwork/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/patchwork/models.py b/patchwork/models.py index 1990989..1f13722 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -19,6 +19,7 @@ from django.db import models from django.db.models import Q +from django.contrib import auth from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.contrib.sites.models import Site @@ -84,6 +85,8 @@ def user_name(user): return u' '.join(names) return user.username +auth.models.User.add_to_class('name', user_name) + class UserProfile(models.Model): user = models.OneToOneField(User, unique = True, related_name='profile') primary_project = models.ForeignKey(Project, null = True, blank = True)