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()
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()
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):
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
<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>
<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>