From 2fa3326df18bbfd8b15a6f12b3b66629e93af59c Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Fri, 24 May 2013 14:44:11 +0200 Subject: Add a unit test for unread posts --- hyperkitty/views/thread.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'hyperkitty/views/thread.py') diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 22710d7..34fc5d9 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -55,9 +55,7 @@ def _get_thread_replies(request, thread, offset=1, limit=None): # XXX: Storm-specific emails = emails.find() - emails.config(offset=offset) - if limit is not None: - emails.config(limit=limit) + emails.config(offset=offset, limit=limit) emails = list(emails) for email in emails: @@ -151,7 +149,8 @@ def thread_index(request, mlist_fqdn, threadid, month=None, year=None): if is_bot: # Don't rely on AJAX to load the replies - context["replies"] = _get_thread_replies(request, thread) + # The limit is a safety measure, don't let a bot kill the DB + context["replies"] = _get_thread_replies(request, thread, limit=1000) return render(request, "thread.html", context) -- cgit