Mercurial > public > sg101
diff gpp/forums/signals.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 | 3a4bbf9c2cce |
children | e0523e17ea43 |
line wrap: on
line diff
--- a/gpp/forums/signals.py Wed Mar 02 01:11:32 2011 +0000 +++ b/gpp/forums/signals.py Wed Mar 02 02:18:28 2011 +0000 @@ -4,7 +4,7 @@ from django.db.models.signals import post_save from django.db.models.signals import post_delete -from forums.models import Topic, Post +from forums.models import Forum, Topic, Post from forums.views.subscriptions import notify_topic_subscribers @@ -41,12 +41,18 @@ post = kwargs['instance'] # update the topic - post.topic.post_count_update() - post.topic.save() - - # update the forum - post.topic.forum.post_count_update() - post.topic.forum.save() + try: + post.topic.post_count_update() + post.topic.save() + except Topic.DoesNotExist: + pass + else: + # update the forum + try: + post.topic.forum.post_count_update() + post.topic.forum.save() + except Forum.DoesNotExist: + pass post_save.connect(on_topic_save, sender=Topic, dispatch_uid='forums.signals')