@@ -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):
@@ -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 %}
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@intel.com> --- patchwork/models.py | 11 +++++++++++ patchwork/templates/patchwork/patch.html | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)