comparison gpp/forums/tools.py @ 348:d1b11096595b

Fix #168; when nailing a spammer, clear their profile text fields. Guard against topics and forums that don't exist when deleting posts in the signal handler. Make the forum stats template tag only display the latest active users.
author Brian Neal <bgneal@gmail.com>
date Wed, 02 Mar 2011 02:18:28 +0000
parents 767cedc7d12a
children e0523e17ea43
comparison
equal deleted inserted replaced
347:69d0306a6fe7 348:d1b11096595b
50 if forum.post_count > 0: 50 if forum.post_count > 0:
51 forum.last_post = forum_posts.latest() 51 forum.last_post = forum_posts.latest()
52 else: 52 else:
53 forum.last_post = None 53 forum.last_post = None
54 forum.save() 54 forum.save()
55 55
56 # Delete pending topics now because forums have just adjusted their 56 # Delete pending topics now because forums have just adjusted their
57 # foreign keys into Post 57 # foreign keys into Post
58 if pending_delete: 58 if pending_delete:
59 topic_ids = [topic.pk for topic in pending_delete] 59 topic_ids = [topic.pk for topic in pending_delete]
60 Topic.objects.filter(pk__in=topic_ids).delete() 60 Topic.objects.filter(pk__in=topic_ids).delete()
61 61
62 # Topics have been deleted, re-compute topic counts for forums 62 # Topics have been deleted, re-compute topic counts for forums
63 for forum in forums: 63 for forum in forums:
64 forum.topic_count = Topic.objects.filter(forum=forum).count() 64 forum.topic_count = Topic.objects.filter(forum=forum).count()
65 forum.save() 65 forum.save()
66 66
67 # All foreign keys are accounted for, we can now delete the posts in bulk. 67 # All foreign keys are accounted for, we can now delete the posts in bulk.
68 # Since some posts in our original queryset may have been deleted already, 68 # Since some posts in our original queryset may have been deleted already,
69 # run a new query (although it may be ok) 69 # run a new query (although it may be ok)
70 Post.objects.filter(pk__in=post_ids).delete() 70 Post.objects.filter(pk__in=post_ids).delete()
71 71