From 1a339ac1f7dac6e63b83864b6421aed1b0fdde75 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Mon, 15 Jul 2013 11:39:45 +0200 Subject: Show the unread icon in the overview page --- hyperkitty/lib/__init__.py | 22 +++++++++++++++++++++- .../static/hyperkitty/css/hyperkitty-common.css | 3 +++ .../hyperkitty/css/hyperkitty-threadslist.css | 4 ---- hyperkitty/templates/threads/summary_thread.html | 6 +++++- .../templates/threads/summary_thread_large.html | 2 +- hyperkitty/tests/test_views.py | 8 ++++++++ hyperkitty/views/list.py | 20 +++++--------------- hyperkitty/views/message.py | 16 +--------------- 8 files changed, 44 insertions(+), 37 deletions(-) (limited to 'hyperkitty') 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 + diff --git a/hyperkitty/static/hyperkitty/css/hyperkitty-common.css b/hyperkitty/static/hyperkitty/css/hyperkitty-common.css index a6f47ca..91c4556 100644 --- a/hyperkitty/static/hyperkitty/css/hyperkitty-common.css +++ b/hyperkitty/static/hyperkitty/css/hyperkitty-common.css @@ -92,6 +92,9 @@ form .buttons .submit { background-image: url("../img/discussion.png"); margin-right: 2em; } +i.unread { + vertical-align: baseline; +} /* diff --git a/hyperkitty/static/hyperkitty/css/hyperkitty-threadslist.css b/hyperkitty/static/hyperkitty/css/hyperkitty-threadslist.css index 7331f90..73f4864 100644 --- a/hyperkitty/static/hyperkitty/css/hyperkitty-threadslist.css +++ b/hyperkitty/static/hyperkitty/css/hyperkitty-threadslist.css @@ -91,10 +91,6 @@ margin-left: 2em; } -.thread.unread i.unread { - vertical-align: baseline; -} - .thread-content { margin-top: 0.5em; } diff --git a/hyperkitty/templates/threads/summary_thread.html b/hyperkitty/templates/threads/summary_thread.html index 82c9398..2176936 100644 --- a/hyperkitty/templates/threads/summary_thread.html +++ b/hyperkitty/templates/threads/summary_thread.html @@ -6,7 +6,11 @@ {% if counter %}#{{counter}}{% endif %} {{ thread.subject|strip_subject:mlist }} + >{{ thread.subject|strip_subject:mlist }} + {% if thread.unread %} + + {% endif %} +