From: Damien Lespiau Date: Sat, 1 Nov 2014 19:01:50 +0000 (+0000) Subject: patch: Single out the commit message X-Git-Tag: v1.1.0~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52bb2ef17bf85767caff8d370d2a30d2503a38d5;p=thirdparty%2Fpatchwork.git patch: Single out the commit message 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. v3: Fix docstrings 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 Signed-off-by: Stephen Finucane --- diff --git a/patchwork/models.py b/patchwork/models.py index 0c8022cf..f206b188 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 @@ -257,7 +258,22 @@ class Patch(models.Model): def __unicode__(self): return self.name + def commit_message(self): + """Retrieve the commit message.""" + return Comment.objects.filter(patch=self, msgid=self.msgid) + + def answers(self): + """Retrieve replies. + + This includes all repliess but not the commit message) + """ + return Comment.objects.filter(Q(patch=self) & ~Q(msgid=self.msgid)) + def comments(self): + """Retrieves all comments of this patch. + + This includes the commit message and all other replies. + """ 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 b222ebe4..5a450162 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 %}