summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-05-24 11:19:42 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-05-24 11:19:42 +0200
commitd7960dd61479b254506fc7869144ff91f3481e9a (patch)
tree97bdfe6836f35c02f1538ab71c8d6c67b21767bb
parentd6e6803ebcd75763d243404af5d8c3dfcb2ba8a9 (diff)
downloadhyperkitty-d7960dd61479b254506fc7869144ff91f3481e9a.tar.gz
hyperkitty-d7960dd61479b254506fc7869144ff91f3481e9a.tar.xz
hyperkitty-d7960dd61479b254506fc7869144ff91f3481e9a.zip
Display the number of unread replies
-rw-r--r--hyperkitty/templates/ajax/last_views.html7
-rw-r--r--hyperkitty/views/accounts.py7
2 files changed, 12 insertions, 2 deletions
diff --git a/hyperkitty/templates/ajax/last_views.html b/hyperkitty/templates/ajax/last_views.html
index 5455413..25fe995 100644
--- a/hyperkitty/templates/ajax/last_views.html
+++ b/hyperkitty/templates/ajax/last_views.html
@@ -27,7 +27,12 @@
<td>{{ lv.thread.starting_email.sender_name }}</td>
<td>{{ lv.thread.starting_email|viewer_date|date:"l, j F Y H:i:s" }}</td>
<td>{{ lv.thread|viewer_date|timesince }}</td>
- <td>{{ lv.thread|length }}</td>
+ <td>
+ {{ lv.thread|length }}
+ {% if thread.unread %}
+ / {{ thread.unread }} new
+ {% endif %}
+ </td>
</tr>
{% endfor %}
</tbody>
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py
index b283392..e35b6eb 100644
--- a/hyperkitty/views/accounts.py
+++ b/hyperkitty/views/accounts.py
@@ -190,7 +190,12 @@ def last_views(request):
last_views = last_views_paginator.page(last_views_paginator.num_pages)
for last_view in last_views:
thread = store.get_thread(last_view.list_address, last_view.threadid)
- thread.unread = bool( thread.date_active > last_view.view_date )
+ if thread.date_active > last_view.view_date:
+ # small optimization: only query the replies if necessary
+ # XXX: Storm-specific (count method)
+ thread.unread = thread.replies_after(last_view.view_date).count()
+ else:
+ thread.unread = 0
last_view.thread = thread
return render(request, 'ajax/last_views.html', {