]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
patch: Single out the commit message
authorDamien Lespiau <damien.lespiau@intel.com>
Sat, 1 Nov 2014 19:01:50 +0000 (19:01 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 5 Nov 2015 03:56:05 +0000 (03:56 +0000)
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 <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
patchwork/models.py
patchwork/templates/patchwork/patch.html

index 0c8022cf8b7930754b5f809046f942686b4fd810..f206b188346d7bf313749945bbbbb889ab4d5738 100644 (file)
@@ -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):
index b222ebe46ace0f880214d85fd78245ab7d3e25b6..5a450162656d94980a14459dcc44fb89fe120f52 100644 (file)
@@ -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 %}