Mercurial > public > sg101
comparison gpp/forums/signals.py @ 181:500e5875a306
Implementing #61: adding a forum topic subscription feature.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 28 Mar 2010 01:07:47 +0000 |
parents | 374b24dd2f9a |
children | a46788862737 |
comparison
equal
deleted
inserted
replaced
180:aef00df91165 | 181:500e5875a306 |
---|---|
1 """ | 1 """ |
2 Signal handlers for the forums application. | 2 Signal handlers for the forums application. |
3 """ | 3 """ |
4 from django.db.models.signals import post_save | 4 from django.db.models.signals import post_save |
5 from django.db.models.signals import post_delete | 5 from django.db.models.signals import post_delete |
6 from models import Topic | 6 |
7 from models import Post | 7 from forums.models import Topic, Post |
8 from forums.subscriptions import notify_topic_subscribers | |
8 | 9 |
9 | 10 |
10 def on_topic_save(sender, **kwargs): | 11 def on_topic_save(sender, **kwargs): |
11 if kwargs['created']: | 12 if kwargs['created']: |
12 topic = kwargs['instance'] | 13 topic = kwargs['instance'] |
30 | 31 |
31 # update the forum | 32 # update the forum |
32 post.topic.forum.post_count_update() | 33 post.topic.forum.post_count_update() |
33 post.topic.forum.save() | 34 post.topic.forum.save() |
34 | 35 |
36 # send out any email notifications | |
37 notify_topic_subscribers(post) | |
38 | |
35 | 39 |
36 def on_post_delete(sender, **kwargs): | 40 def on_post_delete(sender, **kwargs): |
37 post = kwargs['instance'] | 41 post = kwargs['instance'] |
38 | 42 |
39 # update the topic | 43 # update the topic |