summaryrefslogtreecommitdiffstats
path: root/hyperkitty/lib/__init__.py
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-07-15 11:39:45 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-07-15 11:39:45 +0200
commit1a339ac1f7dac6e63b83864b6421aed1b0fdde75 (patch)
tree36e547489dee3ba3e192dd5c3254dab3bec03e9d /hyperkitty/lib/__init__.py
parent6c60d43903503d01173098c456211e79a318221e (diff)
downloadhyperkitty-1a339ac1f7dac6e63b83864b6421aed1b0fdde75.tar.gz
hyperkitty-1a339ac1f7dac6e63b83864b6421aed1b0fdde75.tar.xz
hyperkitty-1a339ac1f7dac6e63b83864b6421aed1b0fdde75.zip
Show the unread icon in the overview page
Diffstat (limited to 'hyperkitty/lib/__init__.py')
-rw-r--r--hyperkitty/lib/__init__.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/hyperkitty/lib/__init__.py b/hyperkitty/lib/__init__.py
index a25dcd7..9bcded3 100644
--- a/hyperkitty/lib/__init__.py
+++ b/hyperkitty/lib/__init__.py
@@ -26,10 +26,11 @@ import datetime
from django.core.exceptions import SuspiciousOperation
from django.core.mail import EmailMessage
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from django.utils.timezone import utc
from mailmanclient import MailmanConnectionError
from hyperkitty.lib import mailman
-from hyperkitty.models import ThreadCategory
+from hyperkitty.models import ThreadCategory, LastView
from hyperkitty.views.forms import CategoryForm
@@ -214,3 +215,22 @@ def get_category_widget(request=None, current_category=None):
except ThreadCategory.DoesNotExist:
category = None
return category, category_form
+
+
+def is_thread_unread(request, mlist_name, thread):
+ """Returns True or False if the thread is unread or not."""
+ unread = False
+ if request.user.is_authenticated():
+ try:
+ last_view_obj = LastView.objects.get(
+ list_address=mlist_name,
+ threadid=thread.thread_id,
+ user=request.user)
+ except LastView.DoesNotExist:
+ unread = True
+ else:
+ if thread.date_active.replace(tzinfo=utc) \
+ > last_view_obj.view_date:
+ unread = True
+ return unread
+