Mercurial > public > sg101
diff gpp/forums/unread.py @ 307:7e19180b128d
Fixing #97; adding a management command to remove old forum and topic last visit records.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 16 Jan 2011 20:18:26 +0000 |
parents | d77e0dc772ad |
children | e9a066db3f54 |
line wrap: on
line diff
--- a/gpp/forums/unread.py Sat Jan 15 21:55:37 2011 +0000 +++ b/gpp/forums/unread.py Sun Jan 16 20:18:26 2011 +0000 @@ -1,5 +1,5 @@ """ -This file contains routines for implementing the "has unread" feature. +This file contains routines for implementing the "has unread" feature. Forums, topics, and posts are displayed with a visual indication if they have been read or not. """ @@ -10,7 +10,7 @@ from forums.models import ForumLastVisit, TopicLastVisit, Topic, Forum -THRESHOLD = datetime.timedelta(days=7) +THRESHOLD = datetime.timedelta(days=14) ####################################################################### @@ -25,7 +25,7 @@ # retrieve ForumLastVisit records in one SQL query forum_ids = [forum.id for forum in qs] - flvs = ForumLastVisit.objects.filter(user=user, + flvs = ForumLastVisit.objects.filter(user=user, forum__in=forum_ids).select_related() flvs = dict([(flv.forum.id, flv) for flv in flvs]) @@ -74,7 +74,7 @@ TopicLastVisit.objects.filter(user=user, topic__forum=forum, last_visit__lt=min_date).delete() - topics = Topic.objects.filter(forum=forum, + topics = Topic.objects.filter(forum=forum, creation_date__gt=flv.begin_date) tracked_topics = TopicLastVisit.objects.filter(user=user, topic__forum=forum, last_visit__gt=flv.begin_date)