[PATCH 36/49] patch: Single out the commit message
Damien Lespiau
damien.lespiau at intel.com
Fri Oct 2 00:12:41 AEST 2015
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 <damien.lespiau at intel.com>
---
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 c2b8a9c..76ae5b8 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,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 }}</a>
{% endif %}
+{% for item in patch.commit_message %}
+<h2>Commit Message</h2>
+<div class="comment">
+<div class="meta">{{ item.submitter|personify:project }} - {{item.date}}</div>
+<pre class="content">
+{{ item|commentsyntax }}
+</pre>
+</div>
+{% endfor %}
+
+{% for item in patch.answers %}
+{% if forloop.first %}
<h2>Comments</h2>
-{% for comment in patch.comments %}
+{% endif %}
+
<div class="comment">
-<div class="meta">{{ comment.submitter|personify:project }} - {{comment.date}}</div>
+<div class="meta">{{ item.submitter|personify:project }} - {{item.date}}</div>
<pre class="content">
-{{ comment|commentsyntax }}
+{{ item|commentsyntax }}
</pre>
</div>
{% endfor %}
--
2.1.0
More information about the Patchwork
mailing list