# HG changeset patch # User Brian Neal # Date 1301703160 0 # Node ID 7e0997b08b500736a940f5ad989fdd9367d77e8d # Parent 42a4e66972d5c8acfc84e2cc89c8ece5ddb9560f Fixes for #200; fix bug in deciding which forums have unread posts. diff -r 42a4e66972d5 -r 7e0997b08b50 gpp/forums/unread.py --- a/gpp/forums/unread.py Fri Apr 01 01:18:44 2011 +0000 +++ b/gpp/forums/unread.py Sat Apr 02 00:12:40 2011 +0000 @@ -7,7 +7,6 @@ import logging from django.db import IntegrityError -from django.db.models import Q from forums.models import ForumLastVisit, TopicLastVisit, Topic, Forum @@ -85,8 +84,10 @@ 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) + tracked_topics = TopicLastVisit.objects.filter( + user=user, + topic__forum=forum, + last_visit__gt=flv.begin_date).select_related('topic') # If the number of topics created since our window was started # is greater than the tracked topic records, then there are new @@ -95,7 +96,7 @@ forum.has_unread = True continue - tracked_dict = dict([(t.id, t) for t in tracked_topics]) + tracked_dict = dict((t.topic.id, t) for t in tracked_topics) for topic in topics: if topic.id in tracked_dict: