summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2013-08-18 16:16:12 +0000
committerMagnus Hagander2013-08-18 16:16:12 +0000
commit193a940fa0f62ceb4f36fd325a7b7eed2391d43e (patch)
tree550c31ab580cf10873beb616ff737e9467406b09
parent4419c6051b1ea87d5ab5d46255c821c4079415de (diff)
Track and show the last time an email was sent for a patch
This tracks all the emails that are sent on a patch. Note that this currently only picks up emalis when the attach thread function is used, since there is no cronjob that fetches this data yet. When that job is added, it should also update this field.
-rw-r--r--pgcommitfest/commitfest/ajax.py2
-rw-r--r--pgcommitfest/commitfest/models.py13
-rw-r--r--pgcommitfest/commitfest/templates/commitfest.html6
3 files changed, 18 insertions, 3 deletions
diff --git a/pgcommitfest/commitfest/ajax.py b/pgcommitfest/commitfest/ajax.py
index 469d630..97d00a4 100644
--- a/pgcommitfest/commitfest/ajax.py
+++ b/pgcommitfest/commitfest/ajax.py
@@ -106,6 +106,7 @@ def doAttachThread(cf, patch, msgid, user):
m.save()
parse_and_add_attachments(r, m)
PatchHistory(patch=patch, by=user, what='Attached mail thread %s' % r[0]['msgid']).save()
+ patch.update_lastmail()
patch.set_modified()
patch.save()
@@ -119,6 +120,7 @@ def detachThread(request):
thread.delete()
PatchHistory(patch=patch, by=request.user, what='Detached mail thread %s' % request.POST['msg']).save()
+ patch.update_lastmail()
patch.set_modified()
patch.save()
diff --git a/pgcommitfest/commitfest/models.py b/pgcommitfest/commitfest/models.py
index e7ac9c7..2538e08 100644
--- a/pgcommitfest/commitfest/models.py
+++ b/pgcommitfest/commitfest/models.py
@@ -77,6 +77,10 @@ class Patch(models.Model):
created = models.DateTimeField(blank=False, null=False, auto_now_add=True)
modified = models.DateTimeField(blank=False, null=False)
+ # Materialize the last time an email was sent on any of the threads
+ # that's attached to this message.
+ lastmail = models.DateTimeField(blank=True, null=True)
+
# Some accessors
@property
def authors_string(self):
@@ -101,6 +105,15 @@ class Patch(models.Model):
if not self.modified or newmod > self.modified:
self.modified = newmod
+ def update_lastmail(self):
+ # Update the lastmail field, based on the newest email in any of
+ # the threads attached to it.
+ threads = list(self.mailthread_set.all())
+ if len(threads) == 0:
+ self.lastmail = None
+ else:
+ self.lastmail = max(threads, key=lambda t:t.latestmessage).latestmessage
+
def __unicode__(self):
return self.name
diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html
index ae2f3ae..232dbe9 100644
--- a/pgcommitfest/commitfest/templates/commitfest.html
+++ b/pgcommitfest/commitfest/templates/commitfest.html
@@ -45,8 +45,8 @@
<th>Status</th>
<th>Author</th>
<th>Reviewers</th>
- <th>Last act</th>
- <th>Last mail</th>
+ <th>Latest act</th>
+ <th>Latest mail</th>
</tr>
</thead>
<tbody>
@@ -61,7 +61,7 @@
<td>{{p.author_names|default:''}}</td>
<td>{{p.reviewer_names|default:''}}</td>
<td style="white-space: nowrap;">{{p.modified|date:"Y-m-d"}}<br/>{{p.modified|date:"H:i"}}</td>
- <td>What?</td>
+ <td style="white-space: nowrap;">{{p.lastmail|date:"Y-m-d"}}<br/>{{p.lastmail|date:"H:i"}}</td>
</tr>
{%endfor%}
</tbody>