From patchwork Mon Aug 24 18:23:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 510249 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 E12AD1402A0 for ; Tue, 25 Aug 2015 04:30:30 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id BF0881A1D9D for ; Tue, 25 Aug 2015 04:30:30 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lists.ozlabs.org (Postfix) with ESMTP id D96651A1D6F for ; Tue, 25 Aug 2015 04:24:33 +1000 (AEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Aug 2015 11:24:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,739,1432623600"; d="scan'208";a="789969376" Received: from smarupud-mobl2.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.186.249]) by fmsmga002.fm.intel.com with ESMTP; 24 Aug 2015 11:24:30 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 37/51] patch: Single out the commit message Date: Mon, 24 Aug 2015 19:23:26 +0100 Message-Id: <1440440620-25937-38-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1440440620-25937-1-git-send-email-damien.lespiau@intel.com> References: <1440440620-25937-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" All 'Comments' are stored the same way in the db, but I believe it's worth making the distinction between introducing what the patch does and eventual review comments. v2: Use two new Patch methods to retrieve the commit message and the other comments (called answers here) (Jeremy Kerr) Signed-off-by: Damien Lespiau --- patchwork/models.py | 11 +++++++++++ patchwork/templates/patchwork/patch.html | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/patchwork/models.py b/patchwork/models.py index 4a1a432..cbc8b51 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -18,6 +18,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from django.db import models +from django.db.models import Q from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.contrib.sites.models import Site @@ -260,7 +261,17 @@ class Patch(models.Model): def __unicode__(self): return self.name + def commit_message(self): + """Retrieves the commit message""" + return Comment.objects.filter(patch=self, msgid=self.msgid) + + def answers(self): + """Retrieves the answers (ie all comments but the commit message)""" + return Comment.objects.filter(Q(patch=self) & ~Q(msgid=self.msgid)) + def comments(self): + """Retrieves all comments of this patch ie. the commit message and the + answers""" return Comment.objects.filter(patch = self) def _set_tag(self, tag, count): diff --git a/patchwork/templates/patchwork/patch.html b/patchwork/templates/patchwork/patch.html index b222ebe..5a45016 100644 --- a/patchwork/templates/patchwork/patch.html +++ b/patchwork/templates/patchwork/patch.html @@ -177,12 +177,25 @@ function toggle_headers(link_id, headers_id) >{{ patch.pull_url }} {% endif %} +{% for item in patch.commit_message %} +

Commit Message

+
+
{{ item.submitter|personify:project }} - {{item.date}}
+
+{{ item|commentsyntax }}
+
+
+{% endfor %} + +{% for item in patch.answers %} +{% if forloop.first %}

Comments

-{% for comment in patch.comments %} +{% endif %} +
-
{{ comment.submitter|personify:project }} - {{comment.date}}
+
{{ item.submitter|personify:project }} - {{item.date}}
-{{ comment|commentsyntax }}
+{{ item|commentsyntax }}
 
{% endfor %}